Selaa lähdekoodia

调整微信登录逻辑

tianboguang 3 vuotta sitten
vanhempi
commit
601965dbc2

+ 9 - 9
platform-api/src/main/java/com/platform/api/ApiAuthController.java

@@ -15,11 +15,13 @@ import com.platform.service.TokenService;
 import com.platform.service.custom.MyApiTmBrandAdminService;
 import com.platform.service.custom.MySysUserBrandService;
 import com.platform.service.impl.SysUserServiceImpl;
+import com.platform.service.impl.ZhiHouseService;
 import com.platform.util.ApiBaseAction;
 import com.platform.util.ApiUserUtils;
 import com.platform.util.CommonUtil;
 import com.platform.utils.*;
 import com.platform.validator.Assert;
+import com.platform.vos.ReturnDTO;
 import com.qiniu.util.StringUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
@@ -69,6 +71,9 @@ public class ApiAuthController extends ApiBaseAction {
     @Autowired
     private MySysUserBrandService mySysUserBrandService;
 
+    @Autowired
+    private ZhiHouseService zhiHouseService;
+
     /**
      * 登录
      */
@@ -158,12 +163,6 @@ public class ApiAuthController extends ApiBaseAction {
             logger.error("登录失败");
             return toResponsFail("登录失败");
         }
-        //验证用户信息完整性
-//        String sha1 = CommonUtil.getSha1(fullUserInfo.getRawData());
-//        if (!fullUserInfo.getSignature().equals(sha1)) {
-//            logger.error("登录失败");
-//            return toResponsFail("登录失败");
-//        }
         Date nowTime = new Date();
         UserVo userVo = userService.queryByOpenId(sessionData.getString("openid"));
         if (null == userVo) {
@@ -203,10 +202,11 @@ public class ApiAuthController extends ApiBaseAction {
             }
         }
 
-        Map<String, Object> tokenMap = tokenService.createToken(userVo.getUserId());
-        String token = MapUtils.getString(tokenMap, "token");
+        // 调用zfb 登录
+        ReturnDTO returnDTO = zhiHouseService.wcLogin(sessionData.getString("openid"),userVo.getMobile());
+        String token = JSONObject.parseObject(JSONObject.toJSONString(returnDTO.getMessage())).getString("token");
 
-        if (null == userInfo || StringUtils.isNullOrEmpty(token)) {
+        if (StringUtils.isNullOrEmpty(token)) {
             logger.error("登录失败");
             return toResponsFail("登录失败");
         }

+ 19 - 0
platform-common/src/main/java/com/platform/service/impl/ZhiHouseService.java

@@ -124,4 +124,23 @@ public class ZhiHouseService {
             throw new CommonBaseException(ResultCodeEnum.D100,responseEntity.getBody().getError());
         }
     }
+
+    public ReturnDTO wcLogin(String appId,String userName) {
+        String url = zhiHouseHost + "wcLogin";
+        if(org.apache.commons.lang3.StringUtils.isBlank(appId)){
+            throw new CommonBaseException(ResultCodeEnum.D101 , "入参不全");
+        }
+        Map<String ,Object> params = new HashMap<>(1);
+        params.put("appid",appId);
+        params.put("userName",userName);
+        ResponseEntity<ReturnDTO> responseEntity = restTemplate.postForEntity(url,params,ReturnDTO.class);
+        if(responseEntity.getStatusCode()!= HttpStatus.OK){
+            throw new CommonBaseException(ResultCodeEnum.D100,"登录失败");
+        }
+        if (responseEntity.getBody().getCode() != 200) {
+            throw new CommonBaseException(ResultCodeEnum.D100,responseEntity.getBody().getError());
+        }
+
+        return responseEntity.getBody();
+    }
 }