Przeglądaj źródła

Merge branch 'dev' of http://git.ycjcjy.com/SpaceOfCheng/services into dev

wangfei 6 lat temu
rodzic
commit
1f4ee29c08

+ 1
- 1
conf/log.conf Wyświetl plik

@@ -1,4 +1,4 @@
1 1
 [common]
2
-filename="E:\\GoProject\\src\\spaceofcheng\\services\\log\\common.log"
2
+filename="E:\\GoProjects\\src\\spaceofcheng\\services\\log\\common.log"
3 3
 # log level "emergency", "alert", "critical", "error", "warning", "notice", "info", "debug"
4 4
 level="debug"

+ 48
- 10
controllers/luckdraw/luckdraw.go Wyświetl plik

@@ -143,7 +143,7 @@ func (c *LuckDrawController) GetRecordByID() {
143 143
 		c.ResponseError(errors.New("校验奖品记录失败"))
144 144
 	}
145 145
 
146
-	c.ResponseJson(map[string]interface{}{
146
+	c.ResponseJSON(map[string]interface{}{
147 147
 		"record":      record,
148 148
 		"prize":       prize,
149 149
 		"caseAddress": caseAddress,
@@ -151,50 +151,84 @@ func (c *LuckDrawController) GetRecordByID() {
151 151
 }
152 152
 
153 153
 func (c *LuckDrawController) SaveShareRecord() {
154
+	errIgnore := "error-ignore"
155
+
154 156
 	id := c.GetString(":id")
155 157
 
156 158
 	fromID := c.GetString("from")
157 159
 	if fromID == "" {
158
-		c.ResponseError(errors.New("没有分享人ID"))
160
+		c.ResponseData(
161
+			errIgnore,
162
+			"没有分享人ID",
163
+			http.StatusBadRequest,
164
+		)
159 165
 	}
160 166
 
161 167
 	from, err := c.bodydao.GetCustomerByID(fromID)
162 168
 	if err != nil {
163 169
 		utils.LogError("获取分享人信息失败: " + err.Error())
164
-		c.ResponseError(errors.New("获取分享人信息失败"))
170
+		c.ResponseData(
171
+			errIgnore,
172
+			"获取分享人信息失败",
173
+			http.StatusBadRequest,
174
+		)
165 175
 	}
166 176
 
167 177
 	if from == nil || from.CustomerId == "" {
168 178
 		utils.LogError("分享人信息不存在: " + err.Error())
169
-		c.ResponseError(errors.New("分享人信息不存在"))
179
+		c.ResponseData(
180
+			errIgnore,
181
+			"分享人信息不存在",
182
+			http.StatusBadRequest,
183
+		)
170 184
 	}
171 185
 
172 186
 	current = c.Context.Get("customer")
173 187
 
174 188
 	// 自己分享给自己
175 189
 	if from.CustomerId == current.CustomerId {
176
-		c.ResponseError(errors.New("本人分享内容无效"))
190
+		c.ResponseData(
191
+			errIgnore,
192
+			"本人分享内容无效",
193
+			http.StatusBadRequest,
194
+		)
177 195
 	}
178 196
 
179 197
 	luckdraw, err := c.dao.GetLuckDrawByID(id)
180 198
 	if err != nil {
181 199
 		utils.LogError("获取抽奖信息失败: " + err.Error())
182
-		c.ResponseError(errors.New("获取抽奖信息失败"))
200
+		c.ResponseData(
201
+			errIgnore,
202
+			"获取抽奖信息失败",
203
+			http.StatusBadRequest,
204
+		)
183 205
 	}
184 206
 
185 207
 	if luckdraw == nil {
186 208
 		utils.LogError("获取抽奖信息失败: " + err.Error())
187
-		c.ResponseError(errors.New("没有找到 id (" + id + ") 对应的抽奖信息"))
209
+		c.ResponseData(
210
+			errIgnore,
211
+			"没有找到 id ("+id+") 对应的抽奖信息",
212
+			http.StatusBadRequest,
213
+		)
188 214
 	}
189 215
 
190 216
 	existsRec, err := c.dao.GetLuckDrawShareData(from.Id, current.Id, luckdraw.Id, luckdraw.CaseId)
191 217
 	if err != nil {
192 218
 		utils.LogError("获取已有分享信息失败: " + err.Error())
193
-		c.ResponseError(errors.New("获取已有分享信息失败"))
219
+		c.ResponseData(
220
+			errIgnore,
221
+			"获取已有分享信息失败",
222
+			http.StatusBadRequest,
223
+		)
194 224
 	}
195 225
 
196 226
 	if existsRec != nil && len(existsRec) > 0 {
197
-		c.ResponseError(errors.New("已分享记录, 再次分享无效"))
227
+		c.ResponseData(
228
+			errIgnore,
229
+			"已分享记录, 再次分享无效",
230
+			http.StatusBadRequest,
231
+		)
198 232
 	}
199 233
 
200 234
 	shareDt := model.TaShareLuckyRecord{
@@ -213,7 +247,11 @@ func (c *LuckDrawController) SaveShareRecord() {
213 247
 
214 248
 	if err := c.dao.SaveLuckDrawShareData(&shareDt); err != nil {
215 249
 		utils.LogError("保存分享记录失败: " + err.Error())
216
-		c.ResponseError(errors.New("保存分享记录失败"))
250
+		c.ResponseData(
251
+			errIgnore,
252
+			"保存分享记录失败",
253
+			http.StatusBadRequest,
254
+		)
217 255
 	}
218 256
 
219 257
 	c.ResponseJSON("ok")

+ 1
- 0
controllers/user/user.go Wyświetl plik

@@ -209,6 +209,7 @@ func (c *UserController) SignOut() {
209 209
 	user := c.Context.Get("user").(model.SysUser)
210 210
 	c.Context.Set("user", nil)
211 211
 	c.SetTokenExipre(user.UserId)
212
+	c.ResponseJSON("ok")
212 213
 }
213 214
 
214 215
 // GetEnvVars 获取当前用户相关

+ 1
- 1
models/luckdraw/luckdraw.go Wyświetl plik

@@ -278,7 +278,7 @@ func (m *LuckDrawDao) GetPrizeStock(luckdrawid string) ([]model.TaLuckdrawPrize,
278 278
 }
279 279
 
280 280
 // GetPrizeByID 根据id获取奖品信息
281
-func (m *LuckDrawDao) GetPrizeByID(id int) (model.TaLuckdrawPrize, error) {
281
+func (m *LuckDrawDao) GetPrizeByID(id string) (model.TaLuckdrawPrize, error) {
282 282
 	var prize = model.TaLuckdrawPrize{}
283 283
 	_, err := m.db.Where("id=?", id).Get(&prize)
284 284
 	return prize, err