Ver Fonte

数据汇聚

孙永军 há 2 anos atrás
pai
commit
108dcc7a8b

+ 9 - 14
src/main/java/com/sxtvs/open/api/odata/controller/OauthRestController.java

@@ -14,6 +14,7 @@ import com.sxtvs.open.api.odata.wxutil.WxXmlUtil;
 import com.sxtvs.open.core.advice.NoAPIResponse;
 import com.sxtvs.open.core.auth.HttpContextUtil;
 import com.sxtvs.open.core.auth.LoginRequired;
+import com.sxtvs.open.core.conf.Constant;
 import com.sxtvs.open.core.conf.OauthConfig;
 import com.sxtvs.open.core.sls.AliyunLogger;
 import jakarta.annotation.Resource;
@@ -39,7 +40,10 @@ public class OauthRestController {
     @Autowired
     private OauthService oauthService;
 
-    @RequestMapping("weixin/auth/v2")
+    @Autowired
+    private WxTicketService wxTicketService;
+
+    @RequestMapping("weixin/auth")
     @NoAPIResponse
     public String authV2(@RequestBody String body) {
         logger.info("body", body, "key", "oauth/weixin/auth");
@@ -50,28 +54,19 @@ public class OauthRestController {
         String componentVerifyTicket = WxXmlUtil.getComponentVerifyTicket(xml);
         logger.debug("data", componentVerifyTicket);
         redisTemplate.opsForValue().set("WX_TICKET", componentVerifyTicket);
-        return "success";
-    }
-
-    @Autowired
-    private WxTicketService wxTicketService;
 
-    @RequestMapping("weixin/auth")
-    @NoAPIResponse
-    public String auth(@RequestBody String body) {
-        logger.info("body {} ", body);
-        String xml = WxCrypt.decrypt(WxXmlUtil.getEncrypt(body));
-        String componentVerifyTicket = WxXmlUtil.getComponentVerifyTicket(xml);
-        logger.info("weixin componentVerifyTicket {}", componentVerifyTicket);
+        //老逻辑,更库
         WxTicket wxTicket = new WxTicket();
         wxTicket.setId(1);
         wxTicket.setTicket(componentVerifyTicket);
         wxTicket.setUpdateTime(new Date());
 
         wxTicketService.updateById(wxTicket);
+
         return "success";
     }
 
+
     @RequestMapping("douyin/code")
     @LoginRequired
     public RedirectDto douyinQrCode() {
@@ -93,7 +88,7 @@ public class OauthRestController {
         logger.info("key", "oauth/douyin/code", "state", state, "token", token);
         oauthService.saveStateMapping(token, state);
         return new RedirectDto("http://open.kuaishou.com/oauth2/connect?" +
-                "app_id=" + OauthConfig.kuaishouClientKey + "&response_type=code&" +
+                "app_id=" + Constant.kuaishouClientKey + "&response_type=code&" +
                 "scope=user_info%2Cuser_video_info&" +
                 "redirect_uri=http%3A%2F%2Fimport.smcic.net%2Fkuaishou%2Fcallback&state=" + state);
 

+ 2 - 2
src/main/java/com/sxtvs/open/api/odata/service/OauthService.java

@@ -52,11 +52,11 @@ public class OauthService {
     public WxApiCreatePreAuthCodeResponse createPreAuthCodeResponse() {
         var ticket = redisTemplate.opsForValue().get("WX_TICKET");
         WxApiCreatePreAuthCodeRequest authCodeRequest = new WxApiCreatePreAuthCodeRequest();
-        authCodeRequest.setComponentAppid(OauthConfig.wxClientKey);
+        authCodeRequest.setComponentAppid(Constant.wxClientKey);
         authCodeRequest.setComponentAccessToken(ticket);
         var body = Request.post("https://api.weixin.qq.com/cgi-bin/component/api_create_preauthcode?" +
                         "component_access_token=" + ticket)
-                .bodyString(objectMapper.writeValueAsString(Map.of("component_appid", OauthConfig.wxClientKey)),
+                .bodyString(objectMapper.writeValueAsString(Map.of("component_appid", Constant.wxClientKey)),
                         ContentType.APPLICATION_JSON)
                 .execute()
                 .returnContent()