设为首页收藏本站

LUPA开源社区

 找回密码
 注册
文章 帖子 博客
LUPA开源社区 首页 业界资讯 软件追踪 查看内容

JFinal Weixin 1.2发布,微信极速SDK

2014-12-12 16:30| 发布者: joejoe0332| 查看: 1048| 评论: 0|原作者: oschina|来自: oschina

摘要: JFinal Weixin 1.2 主要添加了对多公众号账户的支持,并对原有代码进行小幅重构,具体变化如下:……

  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.2-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 对象

    1
    2
    3
    4
    5
    6
    7
    public ApiConfig getApiConfig() { 
        Record r = Db.findFrist("select * from api_config where weixinId=? limit 1"
            getPara("weixinId")); 
        return new ApiConfig(r.get("token"), r.get("appId"), 
            r.get("appSecret"), r.get("encodingAesKey"), 
            r.get("messageEncrypt")); 
    }


  One More Thing,JFinal 官方微信又一大波美女来袭,扫描下方二维码可立即查看,我们只看美女 ^_^


酷毙

雷人

鲜花

鸡蛋

漂亮
  • 快毕业了,没工作经验,
    找份工作好难啊?
    赶紧去人才芯片公司磨练吧!!

最新评论

关于LUPA|人才芯片工程|人才招聘|LUPA认证|LUPA教育|LUPA开源社区 ( 浙B2-20090187 浙公网安备 33010602006705号   

返回顶部