From 457890d43a4d42eb6d3ab5112bb5266e9909d1e2 Mon Sep 17 00:00:00 2001 From: chenjiahe <763432473@qq.com> Date: 星期五, 05 十一月 2021 17:52:21 +0800 Subject: [PATCH] 新增优化 --- phi_platform_user/src/main/java/com/hx/phip/controller/AccountTokenController.java | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 46 insertions(+), 0 deletions(-) diff --git a/phi_platform_user/src/main/java/com/hx/phip/controller/AccountTokenController.java b/phi_platform_user/src/main/java/com/hx/phip/controller/AccountTokenController.java index cbf8c84..dc74876 100644 --- a/phi_platform_user/src/main/java/com/hx/phip/controller/AccountTokenController.java +++ b/phi_platform_user/src/main/java/com/hx/phip/controller/AccountTokenController.java @@ -13,6 +13,7 @@ import com.hx.util.HttpServletRequestUtil; import com.hx.util.StringUtils; import com.hx.util.corp.entity.WeiXinInfo; +import com.hx.util.rsa.RSAUtil; import com.platform.exception.PlatTipsException; import com.platform.resultTool.PlatformCode; import com.platform.resultTool.PlatformResult; @@ -105,6 +106,50 @@ if (StringUtils.isEmpty(accountToken.getCorpId())) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"corpId is required"); } + + //鑾峰彇搴旂敤鏁版嵁 + ApplyParameter applyParameter = ApplyParameterTool.getContact(accountToken.getCorpId(),commonService); + if(applyParameter == null){ + throw new PlatTipsException(PlatformCode.ERROR_TIPS,"corpId is error"); + } + + SysParameter sysParameter = WeiXinCorpMpUtil.getApplicationAccessToken(commonService,applyParameter.getCorpId(),AesUtil.aesDecryp(applyParameter.getContactSecretKey())); + if(sysParameter == null){ + throw new PlatTipsException(PlatformCode.ERROR_SYSTEM,"鏈嶅姟閿欒"+ SystemCode.ERROR_GET_CORP_TOKEN); + } + Map<String,Object> data = new HashMap<>(); + data.put("access_token",sysParameter.getParamValue()); + data.put("create_time",DateUtil.formatDate(sysParameter.getCreateTime(),"yyyy-MM-dd HH:mm:ss")); + data.put("expires_in",Integer.parseInt(sysParameter.getParamValue1())); + data.put("expires_surplus",secondNum(sysParameter.getCreateTime(),Integer.parseInt(sysParameter.getParamValue1()))); + + return PlatformResult.success(data); + } + + + /**鑾峰彇浼佷笟搴旂敤token*/ + @RequestMapping(value = "/apply/get_token",method = RequestMethod.POST) + public PlatformResult applyToken(HttpServletRequest request) { + + //鑾峰彇杩斿洖鍙傛暟 + String bodydata = HttpServletRequestUtil.getBody(request); + if(StringUtils.isEmpty(bodydata)){ + throw new PlatTipsException(PlatformCode.ERROR_BODY_DATA,"鏁版嵁鏍煎紡閿欒"); + } + AccountToken accountToken = null; + try{ + accountToken = JSONObject.parseObject(bodydata,AccountToken.class); + }catch (Exception e){ + throw new PlatTipsException(PlatformCode.ERROR_BODY_DATA,"鏁版嵁鏍煎紡閿欒"); + } + + if(accountToken == null){ + throw new PlatTipsException(PlatformCode.ERROR_BODY_DATA,"鏁版嵁鏍煎紡閿欒"); + } + + if (StringUtils.isEmpty(accountToken.getCorpId())) { + throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"corpId is required"); + } if (StringUtils.isEmpty(accountToken.getMpId())) { throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"mpId is required"); } @@ -129,6 +174,7 @@ } + /** * token鍓╀綑鏃堕棿 * @param createTime 鑾峰彇鏃堕棿 -- Gitblit v1.8.0