|
@@ -140,18 +140,24 @@ public class AppUserInfoController {
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
@RequestMapping(value = "/getSessionKeyAndOpenID")
|
|
|
- public Map<String, Object> getSessionKeyAndOpenID(@RequestParam("code") String code, @RequestParam("stationId") Integer stationId){
|
|
|
+ public String getSessionKeyAndOpenID(@RequestParam String code, Integer stationId){
|
|
|
logger.info("微信小程序获取用户openId和sessionKey入参code和stationId: "+code +"-----" +stationId);
|
|
|
- String appId = ""; //微信小程序appID
|
|
|
- String appSecret = ""; //微信小程序密钥
|
|
|
- if(stationId !=null){
|
|
|
+ Gson gson =new Gson();
|
|
|
+ //返回结果集
|
|
|
+ ResultData resultData = null;
|
|
|
+ if(stationId !=null && StringUtils.isNotBlank(code)){
|
|
|
+ String appId = ""; //微信小程序appID
|
|
|
+ String appSecret = ""; //微信小程序密钥
|
|
|
Map<String, String> map = stationService.getStationAppIdAndAppSecret(stationId);
|
|
|
appId = map.get("appId"); //微信小程序appID
|
|
|
appSecret = map.get("appSecret"); //微信小程序密钥
|
|
|
logger.info("油站信息:"+map.toString());
|
|
|
+ Map<String, Object> userSessionKeyAndOpenID = WeiXinUserUtil.getUserSessionKeyAndOpenID(appId, appSecret, code);
|
|
|
+ resultData = ResultData.success(userSessionKeyAndOpenID);
|
|
|
+ }else {
|
|
|
+ resultData = ResultData.error(CodeMsg.REQUEST_FAIL);
|
|
|
}
|
|
|
- //获取session_key 和 openid
|
|
|
- return WeiXinUserUtil.getUserSessionKeyAndOpenID(appId, appSecret, code);
|
|
|
+ return gson.toJson(resultData);
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -165,7 +171,19 @@ public class AppUserInfoController {
|
|
|
@RequestMapping(value = "/decryptEncryptedData", method = RequestMethod.POST, consumes = "application/json")
|
|
|
public String decryptEncryptedData(@RequestBody JSONObject jsonObject){
|
|
|
logger.info("解密获取手机号前台传入参数:" +jsonObject.toString());
|
|
|
- return AesDecryptUtil.decryptEncryptedData(jsonObject.get("encryptedData").toString(), jsonObject.get("sessionKey").toString(), jsonObject.get("iv").toString(), "UTF-8").toString();
|
|
|
+ Gson gson =new Gson();
|
|
|
+ //返回结果集
|
|
|
+ ResultData resultData = null;
|
|
|
+ String encryptedData = jsonObject.get("encryptedData").toString();
|
|
|
+ String sessionKey = jsonObject.get("sessionKey").toString();
|
|
|
+ String iv = jsonObject.get("iv").toString();
|
|
|
+ if(StringUtils.isNotBlank(encryptedData) && StringUtils.isNotBlank(sessionKey) && StringUtils.isNotBlank(iv) ){
|
|
|
+ net.sf.json.JSONObject jsonObject1 = AesDecryptUtil.decryptEncryptedData(encryptedData, sessionKey, iv, "UTF-8");
|
|
|
+ resultData = ResultData.success(jsonObject1);
|
|
|
+ }else {
|
|
|
+ resultData = ResultData.error(CodeMsg.REQUEST_FAIL);
|
|
|
+ }
|
|
|
+ return gson.toJson(resultData);
|
|
|
}
|
|
|
|
|
|
/*
|