| @@ -9,9 +9,9 @@ public interface WxAuthorizerInfoMapper extends CommonMapper<WxAuthorizerInfo, L | |||
| List<WxAuthorizerInfo> findList(WxAuthorizerInfo wxAuthorizerInfo); | |||
| List<WxAuthorizerInfo> findWeappList(); | |||
| List<WxWeappInfo> findWeappList(); | |||
| List<WxAuthorizerInfo> findWxMpList(); | |||
| List<WxWeappInfo> findWxMpList(); | |||
| List<WxWeappInfo> findVoList(WxWeappInfo wxWeappInfo); | |||
| @@ -119,16 +119,6 @@ | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| <select id="findWeappList" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> from wx_authorizer_info | |||
| where type = 1 or type = 2 | |||
| </select> | |||
| <select id="findWxMpList" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> from wx_authorizer_info | |||
| where type = 3 or type = 4 | |||
| </select> | |||
| <update id="updateReleaseInfo" parameterType="com.iformall.domain.po.WxAuthorizerInfo" > | |||
| update wx_authorizer_info | |||
| set `current_version` = #{currentVersion}, `current_desc` = #{currentDesc}, `release_time` = #{releaseTime}, `update_time` = #{updateTime} | |||
| @@ -170,6 +160,7 @@ | |||
| <result column="release_time" jdbcType="TIMESTAMP" property="releaseTime" /> | |||
| <result column="open_appid" jdbcType="VARCHAR" property="openAppid" /> | |||
| <result column="bind_open_time" jdbcType="TIMESTAMP" property="bindOpenTime" /> | |||
| <result column="tenant_id" jdbcType="INTEGER" property="tenantId" /> | |||
| <result column="type" jdbcType="INTEGER" property="type" /> | |||
| <result column="name" jdbcType="TIMESTAMP" property="name" /> | |||
| </resultMap> | |||
| @@ -183,7 +174,7 @@ | |||
| ai.`template_status`,ai.`template_time`, | |||
| ai.`current_version`,ai.`current_desc`,ai.`release_time`, | |||
| ai.`open_appid`,ai.`bind_open_time`, | |||
| a.`type`,a.`name` | |||
| a.`tenant_id`,a.`type`,a.`name` | |||
| </sql> | |||
| <sql id="dynamicVWhereConditions"> | |||
| @@ -251,10 +242,20 @@ | |||
| left join wx_appinfo a on ai.`authorizer_appid` = a.app_id | |||
| <include refid="dynamicVWhereConditions" /> | |||
| </select> | |||
| <select id="findWeappList" resultMap="BaseResultMap"> | |||
| select <include refid="allVColumns" /> | |||
| from wx_authorizer_info ai | |||
| left join wx_appinfo a on ai.`authorizer_appid` = a.app_id | |||
| where a.type = 1 or a.type = 2 | |||
| </select> | |||
| <select id="findWxMpList" resultMap="BaseResultMap"> | |||
| select <include refid="allVColumns" /> | |||
| from wx_authorizer_info ai | |||
| left join wx_appinfo a on ai.`authorizer_appid` = a.app_id | |||
| where a.type = 3 or a.type = 4 | |||
| </select> | |||
| </mapper> | |||
| @@ -1,6 +1,6 @@ | |||
| package com.iformall.schedule; | |||
| import com.iformall.domain.po.WxAuthorizerInfo; | |||
| import com.iformall.domain.vo.WxWeappInfo; | |||
| import com.iformall.mapper.WxAuthorizerInfoMapper; | |||
| import com.iformall.service.wechat.WxOpenService; | |||
| import me.chanjar.weixin.common.error.WxErrorException; | |||
| @@ -22,15 +22,15 @@ public class AppAccessTokenSchedule { | |||
| @Autowired | |||
| private WxOpenService openService; | |||
| @Scheduled(cron = "0 0 */1 * * *?") // 每小时更新一次 | |||
| @Scheduled(cron = "0 10 * * * *?") // 每小时更新一次 | |||
| //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 | |||
| public void updateAppAccessToken() { | |||
| // 微信小程序 | |||
| /* | |||
| List<WxAuthorizerInfo> weappList = authorizerInfoMapper.findWeappList(); | |||
| weappList.stream().forEach(wxAuthorizerInfo -> { | |||
| List<WxWeappInfo> weappList = authorizerInfoMapper.findWeappList(); | |||
| weappList.stream().forEach(weappInfo -> { | |||
| try { | |||
| openService.getWxOpenComponentService().getAuthorizerAccessToken(wxAuthorizerInfo.getAuthorizerAppid(), true); | |||
| openService.getWxOpenComponentService().getAuthorizerAccessToken(weappInfo.getAuthorizerAppid(), true); | |||
| } catch (WxErrorException e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| @@ -38,10 +38,10 @@ public class AppAccessTokenSchedule { | |||
| */ | |||
| // 微信公众号 | |||
| List<WxAuthorizerInfo> wxmpList = authorizerInfoMapper.findWxMpList(); | |||
| wxmpList.stream().forEach(wxAuthorizerInfo -> { | |||
| List<WxWeappInfo> wxmpList = authorizerInfoMapper.findWxMpList(); | |||
| wxmpList.stream().forEach(weappInfo -> { | |||
| try { | |||
| openService.getWxOpenComponentService().getAuthorizerAccessToken(wxAuthorizerInfo.getAuthorizerAppid(), true); | |||
| openService.getWxOpenComponentService().getAuthorizerAccessToken(weappInfo.getAuthorizerAppid(), true); | |||
| } catch (WxErrorException e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||