|
|
|
@@ -4,6 +4,9 @@ import cn.binarywang.wx.miniapp.api.WxMaService; |
|
|
|
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; |
|
|
|
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; |
|
|
|
import cn.binarywang.wx.miniapp.bean.WxMaUserInfo; |
|
|
|
import cn.binarywang.wx.miniapp.util.crypt.WxMaCryptUtils; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.iformall.annotation.AuthIgnore; |
|
|
|
import com.iformall.common.ErrorCode; |
|
|
|
import com.iformall.common.Result; |
|
|
|
@@ -234,7 +237,6 @@ public class WxUserGrantController extends BaseController { |
|
|
|
* @param map |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
|
|
|
|
@PostMapping("/getUserPhone") |
|
|
|
@ApiOperation(value = "授权后获取用户的手机号", notes="{\"encryptedData\":\"string\",\"iv\":\"string\"}") |
|
|
|
public ResultData getUserPhone(@RequestBody Map<String, String> map) { |
|
|
|
@@ -412,5 +414,43 @@ public class WxUserGrantController extends BaseController { |
|
|
|
out.close(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 授权后获取用户的手机号等信息 |
|
|
|
* @param map |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@PostMapping("/getWeRunData") |
|
|
|
@ApiOperation(value = "获取用户过去三十天微信运动步数", notes="{\"encryptedData\":\"string\",\"iv\":\"string\"}") |
|
|
|
public ResultData getWeRunData(@RequestBody Map<String, String> map) { |
|
|
|
logger.debug(map.toString()); |
|
|
|
String encryptedData = map.get("encryptedData"); |
|
|
|
String iv = map.get("iv"); |
|
|
|
|
|
|
|
//登录凭证不能为空 |
|
|
|
if (StringUtils.isBlank(encryptedData)) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "encryptedData 不能为空"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(iv)) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "iv 不能为空"); |
|
|
|
} |
|
|
|
|
|
|
|
WxCUser user = getUser(); |
|
|
|
|
|
|
|
String session_key = user.getSessionKey(); |
|
|
|
try { |
|
|
|
// 解密 |
|
|
|
String weRunDataStr = WxMaCryptUtils.decrypt(session_key, encryptedData, iv); |
|
|
|
if (null != weRunDataStr) { |
|
|
|
Object obj = JSON.parse(weRunDataStr); |
|
|
|
return new ResultData(obj); |
|
|
|
} else { |
|
|
|
return new ResultData(ErrorCode.WE_RUN_DATA_DECODE_ERR); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
this.logger.error(e.getMessage(), e); |
|
|
|
return new ResultData(ErrorCode.WE_RUN_DATA_DECODE_ERR); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |