JFinal Weixin 1.2 主要添加了对多公众号账户的支持,并对原有代码进行小幅重构,具体变化如下:
改进内容:
1.添加 ApiConfigKit,便于将 ApiConfig 对象与当前线程进行绑定,方便在各处通过 ApiConfigKit.getApiConfig() 进行获取
2.原有 ApiCofig 对象中的所有属性与方法去掉 static 关键字
3.WeixinController 更名为 MsgController,WeixinInterceptor 更名为 MsgInterceptor
4.添加 ApiController、ApiInterceptor
5.所有对 ApiConfig 静态方法有依赖的地方改为:ApiConfigKit.getApiConfig() 获取对象后再获取属性值,以便支持多公众号账户
6.demo重构:DemoController 更名为 WeixinMsgController,ApiController更名为WeixinApiController
7.WeixinConfig 中的路由配置 "/weixin" 改为 "/msg"
升级步骤:
1.引入新版本 jar 包 jfinal-weixin-1.1-bin-with-src.jar
2.原来继承自 WeixinController 的类改为继承 MsgController
3.需要使用 ApiConfig 的自定义 controller 需要继承自 ApiController
4.去掉YourJFinalConfig 中原来对 ApiConfig 的配置,改而实现控制中的 getApiConfig() 方法
5.原来对 ApiConfig 静态方法的依赖改为通过 ApiConfigKit.getApiConfig() 获取对象后再获取相关属性
6.使用 ApiConfigKit.setDevMode(true) 输出消息交互时的xml与json
多公众号支持的建议方案:
1.创建数据库表 api_config(weixinId, token, appId, appSecret, encodingAesKey, messageEncrypt)
2.多公众号的微信服务器 url 格式设置为:http://域名/msg?weixinId=123,其中 weixinId 对应 api_config 数据库表中的 weixinId
3.在 MsgController 继承类中的 getApiConfig() 中动态获取并返回相应的 ApiConfig 对象
软件详情:http://www.jfinal.com/
下载地址:http://www.jfinal.com/download?file=jfinal-weixin-1.2-bin-with-src.jar
来自:开源中国社区

