Quellcode durchsuchen

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

wangfei vor 6 Jahren
Ursprung
Commit
8c7b03863c
5 geänderte Dateien mit 22 neuen und 13 gelöschten Zeilen
  1. 1
    1
      conf/log.conf
  2. 1
    1
      controllers/luckdrawlist/luckdrawlist.go
  3. 2
    2
      routers/common.go
  4. 14
    9
      service/sys.go
  5. 4
    0
      utils/wechat.go

+ 1
- 1
conf/log.conf Datei anzeigen

@@ -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"

+ 1
- 1
controllers/luckdrawlist/luckdrawlist.go Datei anzeigen

@@ -83,7 +83,7 @@ func (c *LuckdrawlistController) GetVerifyList() {
83 83
 func (c *LuckdrawlistController) VerifyLuckdraw() {
84 84
 	sysUser := c.Context.Get("user").(model.SysUser)
85 85
 	userId := sysUser.UserId
86
-	luckdrawId := c.GetString("luckdrawId")
86
+	luckdrawId := c.GetString(":luckdrawId")
87 87
 	if luckdrawId == "" {
88 88
 		c.ResponseError(errors.New("无效二维码"))
89 89
 	}

+ 2
- 2
routers/common.go Datei anzeigen

@@ -190,8 +190,8 @@ func getCommonRoutes() beego.LinkNamespace {
190 190
 		//luckdrawlist 抽奖
191 191
 		beego.NSRouter("luckdrawlist", &luckdrawlist.LuckdrawlistController{}, "get:GetLuckdrawList"),
192 192
 		beego.NSRouter("luckdrawlist/share", &luckdrawlist.LuckdrawlistController{}, "get:GetLuckShareList"),
193
-		beego.NSRouter("luckdrawlist/:luckdrawId", &luckdrawlist.LuckdrawlistController{}, "get:GetVerifyList"),
194
-		beego.NSRouter("luckdrawlist/:luckdrawId", &luckdrawlist.LuckdrawlistController{}, "put:VerifyLuckdraw"),
193
+		beego.NSRouter("luckdrawlist/verify/:luckdrawId", &luckdrawlist.LuckdrawlistController{}, "get:GetVerifyList"),
194
+		beego.NSRouter("luckdrawlist/verify/:luckdrawId", &luckdrawlist.LuckdrawlistController{}, "put:VerifyLuckdraw"),
195 195
 
196 196
 		// bodychecklist 体检列表
197 197
 		beego.NSRouter("bodychecklist", &bodychecklist.BodychecklistController{}, "get:GetBodyCheckList"),

+ 14
- 9
service/sys.go Datei anzeigen

@@ -177,18 +177,21 @@ func (s *SysServ) authWechat(gctx *context.Context) map[string]interface{} {
177 177
 		// 获取 token
178 178
 		token, err := s.getToken(gctx)
179 179
 		if err != nil {
180
-			// token 报错一律视为需要重新登录
181
-			return map[string]interface{}{
182
-				"code":  http.StatusUnauthorized,
183
-				"error": err,
184
-				"message": map[string]interface{}{
185
-					"appid": utils.GetWxAppID(s.org.OrgId),
186
-				},
180
+			tokenStr := s.ctx.Get("token").(string)
181
+			if tokenStr != "" {
182
+				// token 报错一律视为需要重新登录
183
+				return map[string]interface{}{
184
+					"code":  http.StatusUnauthorized,
185
+					"error": err,
186
+					"message": map[string]interface{}{
187
+						"appid": utils.GetWxAppID(s.org.OrgId),
188
+					},
189
+				}
187 190
 			}
188 191
 		}
189 192
 
190 193
 		// 未登录 或 未验证
191
-		if token.ID == "" {
194
+		if token == nil || token.ID == "" {
192 195
 			if code == "" {
193 196
 				return map[string]interface{}{
194 197
 					"code":  http.StatusUnauthorized,
@@ -216,6 +219,8 @@ func (s *SysServ) authWechat(gctx *context.Context) map[string]interface{} {
216 219
 				}
217 220
 			}
218 221
 
222
+			utils.LogError("获取到微信人员: ", wxUser)
223
+
219 224
 			openID = wxUser.OpenID
220 225
 		} else {
221 226
 			openID = token.ID
@@ -242,7 +247,7 @@ func (s *SysServ) authWechat(gctx *context.Context) map[string]interface{} {
242 247
 	// 如果尚无人员映射信息, 代表人员初次使用本系统
243 248
 	if userMapping == nil {
244 249
 		// 如果没有微信用户信息, 代表产生了未知异常
245
-		if wxUser == nil || wxUser.UnionID == "" {
250
+		if wxUser == nil || wxUser.OpenID == "" {
246 251
 			return map[string]interface{}{
247 252
 				"code":  http.StatusInternalServerError,
248 253
 				"error": errors.New("系统异常, 请清空缓存后重试"),

+ 4
- 0
utils/wechat.go Datei anzeigen

@@ -87,6 +87,10 @@ func MapToWechatUser(data map[string]interface{}) *WechatUser {
87 87
 		user.Sex = data["sex"].(float64)
88 88
 	}
89 89
 
90
+	if data["nickname"] != nil {
91
+		user.NickName = data["nickname"].(string)
92
+	}
93
+
90 94
 	if data["province"] != nil {
91 95
 		user.Province = data["province"].(string)
92 96
 	}