20173 月23
NutzWk: 微信AccessToken没有持久化造成超出调用限制的问题解决
1、wx_config 实体类添加三个字段,对应的表结构也要手动修改: @Column @Comment("access_token") @ColDefine(type = ColType.VARCHAR, width = 255) private String access_token; @Column @Comment("access_token_expires") @ColDefine(type = ColType.INT) private Integer access_token_expires; @Column @Comment("access_token_lastat") @ColDefine(type = ColType.VARCHAR, width = 50) private String access_token_lastat; get set ...方法生成出来 2、nutzwx版本升级为1.r.61-SNAPSHOT <dependency> <groupId>org.nutz</groupId> <artifactId>nutzwx</artifactId> <version>1.r.61-SNAPSHOT</version> </dependency> 3、nutz版本升级为1.r.60 <dependency> <groupId>org.nutz</groupId> <artifactId>nutz</artifactId> <version>1.r.60</version> </dependency> 4、WxConfigService 类getWxApi2替换为如下代码(主要是DaoAccessTokenStore从数据库取access_token) public WxApi2 getWxApi2(String wxid) { Wx_config appInfo = this.fetch(Cnd.where("id", "=", wxid)); DaoAccessTokenStore myDaoAccessTokenStore = new DaoAccessTokenStore(dao()); Map<String, Object> params = new HashMap<>(); params.put("id", appInfo.getId()); myDaoAccessTokenStore.setTableAccessToken("access_token"); myDaoAccessTokenStore.setTableAccessTokenExpires("access_token_expires"); myDaoAccessTokenStore.setTableAccessTokenLastat("access_token_lastat"); myDaoAccessTokenStore.setFetch("select access_token,access_token_expires,access_token_lastat from wx_config where id=@id"); myDaoAccessTokenStore.setUpdate("update wx_config set access_token=@access_token, access_token_expires=@access_token_expires, access_token_lastat=@access_token_lastat where id=@id"); myDaoAccessTokenStore.setParams(params); WxApi2Impl wxApi2 = new WxApi2Impl(); wxApi2.setAppid(appInfo.getAppid()); wxApi2.setAppsecret(appInfo.getAppsecret()); wxApi2.setEncodingAesKey(appInfo.getEncodingAESKey()); wxApi2.setToken(appInfo.getToken()); wxApi2.setAccessTokenStore(myDaoAccessTokenStore); return wxApi2; }
本文地址:https://wizzer.cn/archives/3345 , 转载请保留.