| @@ -21,6 +21,8 @@ public interface WxAuthorizerInfoMapper extends CommonMapper<WxAuthorizerInfo, L | |||
| int updateAccessToken(WxAuthorizerInfo wxAuthorizerInfo); | |||
| int removeOpenAppId(WxAuthorizerInfo wxAuthorizerInfo); | |||
| List<WxWeappInfo> findWeappList(); | |||
| List<WxWeappInfo> findWxMpList(); | |||
| @@ -66,18 +66,20 @@ public interface WxAuthorizerInfoService { | |||
| void deleteById(Long id); | |||
| void updateReleaseVersion(WxAuthorizerInfo record); | |||
| int updateReleaseVersion(WxAuthorizerInfo record); | |||
| void updateBaseVersion(WxAuthorizerInfo record); | |||
| int updateBaseVersion(WxAuthorizerInfo record); | |||
| void updateDomainUrl(WxAuthorizerInfo record); | |||
| int updateDomainUrl(WxAuthorizerInfo record); | |||
| void updateWebDomainUrl(WxAuthorizerInfo record); | |||
| int updateWebDomainUrl(WxAuthorizerInfo record); | |||
| void updateTemplate(WxAuthorizerInfo record); | |||
| int updateTemplate(WxAuthorizerInfo record); | |||
| void updateOpenAppid(WxAuthorizerInfo record); | |||
| int updateOpenAppid(WxAuthorizerInfo record); | |||
| void updateAuthAppidInfo(WxAuthorizerInfo record); | |||
| int removeOpenAppid(WxAuthorizerInfo record); | |||
| int updateAuthAppidInfo(WxAuthorizerInfo record); | |||
| } | |||
| @@ -128,73 +128,79 @@ public class WxAuthorizerInfoServiceImpl implements WxAuthorizerInfoService { | |||
| } | |||
| @Override | |||
| public void updateReleaseVersion(WxAuthorizerInfo record) { | |||
| authorizerInfoMapper.updateReleaseInfo(record); | |||
| public int updateReleaseVersion(WxAuthorizerInfo record) { | |||
| return authorizerInfoMapper.updateReleaseInfo(record); | |||
| } | |||
| @Override | |||
| public void updateBaseVersion(WxAuthorizerInfo record) { | |||
| public int updateBaseVersion(WxAuthorizerInfo record) { | |||
| Date curDate = new Date(); | |||
| WxAuthorizerInfo info = new WxAuthorizerInfo(); | |||
| info.setId(record.getId()); | |||
| info.setBaseStatus(record.getBaseStatus()); | |||
| info.setBaseTime(curDate); | |||
| info.setUpdateTime(curDate); | |||
| authorizerInfoMapper.updateByPrimaryKeySelective(record); | |||
| return authorizerInfoMapper.updateByPrimaryKeySelective(record); | |||
| } | |||
| @Override | |||
| public void updateDomainUrl(WxAuthorizerInfo record) { | |||
| public int updateDomainUrl(WxAuthorizerInfo record) { | |||
| Date curDate = new Date(); | |||
| WxAuthorizerInfo info = new WxAuthorizerInfo(); | |||
| info.setId(record.getId()); | |||
| info.setDomainStatus(record.getDomainStatus()); | |||
| info.setDomainTime(curDate); | |||
| info.setUpdateTime(curDate); | |||
| authorizerInfoMapper.updateByPrimaryKeySelective(record); | |||
| return authorizerInfoMapper.updateByPrimaryKeySelective(record); | |||
| } | |||
| @Override | |||
| public void updateWebDomainUrl(WxAuthorizerInfo record) { | |||
| public int updateWebDomainUrl(WxAuthorizerInfo record) { | |||
| Date curDate = new Date(); | |||
| WxAuthorizerInfo info = new WxAuthorizerInfo(); | |||
| info.setId(record.getId()); | |||
| info.setWebdomainStatus(record.getWebdomainStatus()); | |||
| info.setWebdomainTime(curDate); | |||
| info.setUpdateTime(curDate); | |||
| authorizerInfoMapper.updateByPrimaryKeySelective(record); | |||
| return authorizerInfoMapper.updateByPrimaryKeySelective(record); | |||
| } | |||
| @Override | |||
| public void updateTemplate(WxAuthorizerInfo record) { | |||
| public int updateTemplate(WxAuthorizerInfo record) { | |||
| Date curDate = new Date(); | |||
| WxAuthorizerInfo info = new WxAuthorizerInfo(); | |||
| info.setId(record.getId()); | |||
| info.setTemplateStatus(record.getTemplateStatus()); | |||
| info.setTemplateTime(curDate); | |||
| info.setUpdateTime(curDate); | |||
| authorizerInfoMapper.updateByPrimaryKeySelective(record); | |||
| return authorizerInfoMapper.updateByPrimaryKeySelective(record); | |||
| } | |||
| @Override | |||
| public void updateOpenAppid(WxAuthorizerInfo record) { | |||
| public int updateOpenAppid(WxAuthorizerInfo record) { | |||
| Date curDate = new Date(); | |||
| WxAuthorizerInfo info = new WxAuthorizerInfo(); | |||
| info.setId(record.getId()); | |||
| info.setOpenAppid(record.getOpenAppid()); | |||
| info.setBindOpenTime(curDate); | |||
| authorizerInfoMapper.updateByPrimaryKeySelective(record); | |||
| return authorizerInfoMapper.updateByPrimaryKeySelective(record); | |||
| } | |||
| @Override | |||
| public void updateAuthAppidInfo(WxAuthorizerInfo record) { | |||
| public int removeOpenAppid(WxAuthorizerInfo record) { | |||
| return authorizerInfoMapper.removeOpenAppId(record); | |||
| } | |||
| @Override | |||
| public int updateAuthAppidInfo(WxAuthorizerInfo record) { | |||
| WxAuthorizerInfo authorizerInfo = authorizerInfoMapper.findByAppid(record.getAuthorizerAppid()); | |||
| if(authorizerInfo != null) { | |||
| record.setId(authorizerInfo.getId()); | |||
| authorizerInfoMapper.updateByPrimaryKeySelective(record); | |||
| return authorizerInfoMapper.updateByPrimaryKeySelective(record); | |||
| } else { | |||
| /// TODO | |||
| } | |||
| return 0; | |||
| } | |||
| @@ -147,6 +147,12 @@ | |||
| where `authorizer_appid` = #{authorizerAppid} | |||
| </update> | |||
| <update id="removeOpenAppId" parameterType="com.iformall.domain.po.WxAuthorizerInfo"> | |||
| update wx_authorizer_info | |||
| set `open_appid` = null, `bind_open_time` = null | |||
| where `authorizer_appid` = #{authorizerAppid} | |||
| </update> | |||
| <select id="findMp" parameterType="com.iformall.domain.po.WxAuthorizerInfo" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| @@ -308,6 +308,12 @@ public class WechatCalllbackController extends BaseController { | |||
| logger.info(responseStr); | |||
| WxOpenResult openResult = gson.fromJson(responseStr, WxOpenResult.class); | |||
| if (openResult.isSuccess()) { | |||
| WxAuthorizerInfo authorizerInfo = authorizerInfoService.getByAppId(appId); | |||
| if (authorizerInfo != null) { | |||
| authorizerInfo.setId(authorizerInfo.getId()); | |||
| authorizerInfo.setOpenAppid(openAppId); | |||
| authorizerInfoService.updateOpenAppid(authorizerInfo); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| return new ResultData(Result.ERROR, responseStr); | |||
| @@ -326,6 +332,9 @@ public class WechatCalllbackController extends BaseController { | |||
| logger.info(responseStr); | |||
| WxOpenResult openResult = gson.fromJson(responseStr, WxOpenResult.class); | |||
| if (openResult.isSuccess()) { | |||
| WxAuthorizerInfo authorizerInfo = new WxAuthorizerInfo(); | |||
| authorizerInfo.setAuthorizerAppid(appId); | |||
| authorizerInfoService.removeOpenAppid(authorizerInfo); | |||
| return new ResultData(); | |||
| } | |||
| return new ResultData(Result.ERROR, responseStr); | |||
| @@ -344,6 +353,14 @@ public class WechatCalllbackController extends BaseController { | |||
| logger.info(responseStr); | |||
| WxOpenPlatformResult openPlatformResult = gson.fromJson(responseStr, WxOpenPlatformResult.class); | |||
| if (openPlatformResult.isSuccess()) { | |||
| WxAuthorizerInfo authorizerInfo = authorizerInfoService.getByAppId(appId); | |||
| if (authorizerInfo != null) { | |||
| if(StringUtils.isBlank(authorizerInfo.getOpenAppid()) && StringUtils.isNotBlank(openPlatformResult.getOpenAppid())) { | |||
| authorizerInfo.setId(authorizerInfo.getId()); | |||
| authorizerInfo.setOpenAppid(openPlatformResult.getOpenAppid()); | |||
| authorizerInfoService.updateOpenAppid(authorizerInfo); | |||
| } | |||
| } | |||
| return new ResultData(openPlatformResult.getOpenAppid()); | |||
| } | |||
| return new ResultData(Result.ERROR, responseStr); | |||