jeecms使用方法+微信推送

jeecms的使用方式

通过jeecmsdemo进行系统性的学习与开发。

1.页面数据的展示

由(freemarker)进行数据的展示,freemarker在package com.jeecms.front.controller.directive;包内 。

2.后台输出数据

后台通过 重写 TemplateDirectiveModel的excute方法(继承TemplateDirectiveModel类)的方式,向前端输出数据。
具体方式:首先需要将如UserListDirectiv(继承TemplateDirectiveModel)放入spring.xml中,例子

<bean id="userListDirective" class="com.action.directive.UserListDirective"></bean>

然后 将spring bean 设置到freemarkerConfig全局变量中去。

<bean id="freemarkerConfig2"
        class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
        <property name="templateLoaderPath" value="/" />
        <property name="freemarkerVariables">
            <map >
                <entry key="userListDirective" value="userListTag" />
            </map>
        </property>
        <property name="freemarkerSettings">
            <props>
                <prop key="template_update_delay">0</prop>
                <prop key="defaultEncoding">UTF-8</prop>
                <prop key="url_escaping_charset">UTF-8</prop>
                <prop key="locale">zh_CN</prop>
                <prop key="boolean_format">true,false</prop>
                <prop key="datetime_format">yyyy-MM-dd HH:mm:ss</prop>
                <prop key="date_format">yyyy-MM-dd</prop>
                <prop key="time_format">HH:mm:ss</prop>
                <prop key="number_format">0.######</prop>
                <prop key="whitespace_stripping">true</prop>
            </props>
        </property>
    </bean>

最后在页面使用表达式:userListTag.具体配置文件:context.xml,config.properties,context.directive.xml 。

3.内容有关的数据库表

jc_content(发布内容数据),jc_contet_ext(内容数据扩展表),jc_channel(栏目数据),jc_content_channel(栏目和内容关联表)。

4.模板使用

生成模板会自动产生html文件,模板使用freemarker模式。

5.首页推送发布功能

首推功能(首页推送):jc_content_type(内容操作表,jc_tr_content_type(内容操作关联表),
进行操作时,往jc_tr_content_type添加数据,然后在各个功能在页面上渲染时 content通过指定参数typeId,是否含有类型,进行展示,例如头条中,设置typeId=’149’,若循环出来的列表中含有这列,就认为是头条内容。(热门、头条、首推、猜你喜欢、首推-中、首页要闻功能类似)

6.微信群发消息

1,通过appid获取所有用户的openid列表。

	WxMpService wxMpService = WxMpConfiguration.getMpServices().get(appid);
	WxMpUserList wxUserList = wxMpService.getUserService().userList(null);
	List<String> opindList = wxUserList.getOpenids();

2.使用WxMpService上传图片素材至微信服务器。

	WxMediaUploadResult uploadMediaRes = wxMpService.getMaterialService().mediaUpload(WxConsts.MassMsgType.IMAGE, destFile);

3.将 要传送的信息封装成article类、

	WxMpMassNews.WxMpMassNewsArticle article1 = new WxMpMassNews.WxMpMassNewsArticle();
	article1.setTitle("标题1");
	article1.setContent("内容1");
	article1.setThumbMediaId(uploadMediaRes.getMediaId());
	news.addArticle(article1);

	WxMpMassNews.WxMpMassNewsArticle article2 = new WxMpMassNews.WxMpMassNewsArticle();
	article2.setTitle("标题2");
	article2.setContent("内容2");
	article2.setThumbMediaId(uploadMediaRes.getMediaId());
	article2.setShowCoverPic(true);
	article2.setAuthor("作者2");
	article2.setContentSourceUrl("www.baidu.com");
	article2.setDigest("摘要2");
	news.addArticle(article2);

	WxMpMassUploadResult massUploadResult = wxMpService.
	getMassMessageService().massNewsUpload(news);

4.对所有用户发送消息。(风险:微信官方文档说明中订阅号不支持以openid方式群发消息,但是实际测试却能够成功推送。)

	WxMpMassOpenIdsMessage massMessage = new WxMpMassOpenIdsMessage();
	massMessage.setMsgType(WxConsts.MassMsgType.MPNEWS);
	massMessage.setMediaId(massUploadResult.getMediaId());
	massMessage.setToUsers(openids);
	WxMpMassSendResult massResult = wxMpService.getMassMessageService().
	massOpenIdsMessageSend(massMessage);

7.上传图片库

上传到图片库:可以做成类似商城中的图片库进行管理
1.调用sys-file/upload上传文件
2.上传成功后在进行后续操作,比如保存进入图库
3.后续进行发送图文消息操作。

8.模板消息和群发消息

模板消息:类似于通知与图文消息不一致
模板消息:只服务于服务号。(微信支付后的支付信息)模板功能
图文消息:服务号和订阅号中的信息。(群发功能)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值