Преглед изворни кода

fix 修改名称以及类型

zoujiajian пре 3 година
родитељ
комит
1da67dd004

+ 1 - 1
netflix-dao/src/main/java/com/cyksj/model/dto/AuthRedirect.java

@@ -41,6 +41,6 @@ public class AuthRedirect {
     /**
      * 微信公众号wx_app id
      */
-    private Integer type;
+    private Long tid;
 
 }

+ 1 - 1
netflix-service/src/main/java/com/cyksj/service/authorization/AuthorizationService.java

@@ -16,7 +16,7 @@ public interface AuthorizationService {
      * @param authType
      * @return
      */
-    String createUrl(String state, String authType, Integer type);
+    String createUrl(String state, String authType, Long tid);
 
     JsSdkTicket getJsTicket(String appId, String url) throws Exception;
 

+ 2 - 2
netflix-service/src/main/java/com/cyksj/service/authorization/impl/AuthorizationServiceImpl.java

@@ -27,9 +27,9 @@ public class AuthorizationServiceImpl implements AuthorizationService {
 
 
     @Override
-    public String createUrl(String state, String authType, Integer type) {
+    public String createUrl(String state, String authType, Long tid) {
         return weChatService.createUrl(state, weChatConfig.getDomain() + WeChatAuthRedirectUrl.get(authType).getUrl()
-                , weChatService.getWxAppId(type), WeChatAuthRedirectUrl.get(authType).getScope());
+                , weChatService.getWxAppId(tid), WeChatAuthRedirectUrl.get(authType).getScope());
     }
 
     @Override

+ 1 - 1
netflix-service/src/main/java/com/cyksj/service/wechat/WeChatService.java

@@ -92,7 +92,7 @@ public interface WeChatService {
     /**
      * 获取微信公众号appid
      */
-    String getWxAppId(Integer type);
+    String getWxAppId(Long tid);
 
     /**
      * 根据用户关注公众号关系,获取公众号appid

+ 3 - 3
netflix-service/src/main/java/com/cyksj/service/wechat/impl/WeChatServiceImpl.java

@@ -568,10 +568,10 @@ public class WeChatServiceImpl implements WeChatService {
     }
 
     @Override
-    public String getWxAppId(Integer type) {
+    public String getWxAppId(Long tid) {
         String appId = weChatConfig.getAppid();
-        if (type != null) {
-            WxApp wxApp = wxAppMapper.selectById(type);
+        if (tid != null) {
+            WxApp wxApp = wxAppMapper.selectById(tid);
             if (wxApp != null) {
                 appId = wxApp.getAppId();
             }

+ 7 - 7
netflix-web/src/main/java/com/cyksj/web/controller/user/AuthorizationController.java

@@ -91,7 +91,7 @@ public class AuthorizationController {
     private final DistributeService distributeService;
 
     @GetMapping(value = "/weChat")
-    public void base(String url, Long sharedId, Integer dsType, Long popularizeId, String authType, Integer type, HttpServletResponse response) throws Exception {
+    public void base(String url, Long sharedId, Integer dsType, Long popularizeId, String authType, Long tid, HttpServletResponse response) throws Exception {
 
         log.info("微信授权转跳. url: {},authType:{}", url, authType);
 
@@ -101,10 +101,10 @@ public class AuthorizationController {
 
         Long mappingId = SEQUENCE.nextId();
         redisService.set(mappingId.toString(), url, 60 * 60 * 24L);
-        AuthRedirect redirect = new AuthRedirect().setMappingId(mappingId).setSharedId(sharedId).setDsType(dsType).setPid(popularizeId).setType(type);
+        AuthRedirect redirect = new AuthRedirect().setMappingId(mappingId).setSharedId(sharedId).setDsType(dsType).setPid(popularizeId).setTid(tid);
         String state = Codec.DoBase64.custom().setData(Jsons.toJson(redirect)).encodeAsText();
 
-        response.sendRedirect(authorizationService.createUrl(state, authType, type));
+        response.sendRedirect(authorizationService.createUrl(state, authType, tid));
 
     }
 
@@ -121,7 +121,7 @@ public class AuthorizationController {
         String json = Codec.DoBase64.custom().setData(state).decodeAsText();
         AuthRedirect re = Jsons.parseObject(json, AuthRedirect.class);
 
-        AuthToken token = weChatService.getAuthToken(code, weChatService.getWxAppId(re.getType()));
+        AuthToken token = weChatService.getAuthToken(code, weChatService.getWxAppId(re.getTid()));
 
         // 根据openid 与 access_token 获取用户信息
         GzhOAuth2UserInfo userinfo = weChatService.getUserInfo(token.getAccessToken(), token.getOpenid());
@@ -167,7 +167,7 @@ public class AuthorizationController {
         String json = Codec.DoBase64.custom().setData(state).decodeAsText();
         AuthRedirect re = Jsons.parseObject(json, AuthRedirect.class);
 
-        AuthToken token = weChatService.getAuthToken(code, weChatService.getWxAppId(re.getType()));
+        AuthToken token = weChatService.getAuthToken(code, weChatService.getWxAppId(re.getTid()));
 
         //  查询用户期望转跳的url
         String url = redisService.getStr(re.getMappingId().toString());
@@ -187,11 +187,11 @@ public class AuthorizationController {
      * 微信js-sdk 权限验证
      */
     @RequestMapping(value = "/jsTicket", method = RequestMethod.GET)
-    public Result<JsSdkTicket> ticket(String url, Integer type) throws Exception {
+    public Result<JsSdkTicket> ticket(String url, Long tid) throws Exception {
         if (StringUtils.isBlank(url)) {
             throw BusinessRuntimeException.getInstance("请输入授权网址.");
         }
-        return GatewayResponse.SUCCESS.newBuilder().toResult(authorizationService.getJsTicket(weChatService.getWxAppId(type), url));
+        return GatewayResponse.SUCCESS.newBuilder().toResult(authorizationService.getJsTicket(weChatService.getWxAppId(tid), url));
 
     }