Przeglądaj źródła

修改:appId从数据库取

jk-GitHub-coder 4 lat temu
rodzic
commit
a86e04d25d

+ 10 - 10
YijiaRestful/src/main/java/com/platform/yijia/controller/AppUserInfoController.java

@@ -35,8 +35,8 @@ public class AppUserInfoController {
     private AppUserInfoService appUserInfoService;
     @Resource
     private StationService stationService;
-    String appId = "wxe1135cd390b38a54";        //微信小程序appID
-    String appSecret = "0532c7d9ae876c4ad636df0b1e3b9ddb";      //微信小程序密钥
+//    String appId = "wxe1135cd390b38a54";        //微信小程序appID
+//    String appSecret = "0532c7d9ae876c4ad636df0b1e3b9ddb";      //微信小程序密钥
 
     /*
      * 微信小程序根据code获取用户openId和sessionKey
@@ -46,14 +46,14 @@ public class AppUserInfoController {
      */
     @ResponseBody
     @RequestMapping(value = "/getSessionKeyAndOpenID")
-    public Map<String, Object> getSessionKeyAndOpenID(@RequestParam("code") String code){
-//        String appId = "";        //微信小程序appID
-//        String appSecret = "";      //微信小程序密钥
-//        if(stationId !=null && stationId !=""){
-//            Map<String, String> map = stationService.getStationAppIdAndAppSecret(stationId);
-//            appId = map.get("appId");        //微信小程序appID
-//            appSecret = map.get("appSecret");      //微信小程序密钥
-//        }
+    public Map<String, Object> getSessionKeyAndOpenID(@RequestParam("code") String code, @RequestParam("stationId") String stationId){
+        String appId = "";        //微信小程序appID
+        String appSecret = "";      //微信小程序密钥
+        if(stationId !=null && stationId !=""){
+            Map<String, String> map = stationService.getStationAppIdAndAppSecret(stationId);
+            appId = map.get("appId");        //微信小程序appID
+            appSecret = map.get("appSecret");      //微信小程序密钥
+        }
         //获取session_key 和 openid
         return WeiXinUserUtil.getUserSessionKeyAndOpenID(appId, appSecret, code);
     }