diff --git a/README.md b/README.md index 05a421a..74ee09e 100644 --- a/README.md +++ b/README.md @@ -21,5 +21,11 @@ ssm 使用说明 3. 自定义实体同步数据库表结构插件(com.lq.code.executor.processor.InstantiationTracingBeanPostProcessor) 4. AdminBaseDao,AdminBaseServer,AdminBaseController.三层类结构的继承。可以实现简单模块基本管理功能。 +三层架构理念: +1.数据库表与mapping.xml一一对应。 +2.dao层代码密度低,dao层代码尽量通用,以工具类形式使用。便于代码重用 +3.service层代码密度高 通过组合复用dao层工具类,实现业务逻辑 +4.controller层代码密度低 只负责简单的数据接受和转发。以及页面跳转的控制 + 1. 项目案例:http://106.12.122.216/ssm/cms/ 2. 默认账号/密码:admin/123 diff --git a/src/main/java/com/lq/cms/service/impl/WechatRuleServiceImpl.java b/src/main/java/com/lq/cms/service/impl/WechatRuleServiceImpl.java index ee5a299..11f568a 100644 --- a/src/main/java/com/lq/cms/service/impl/WechatRuleServiceImpl.java +++ b/src/main/java/com/lq/cms/service/impl/WechatRuleServiceImpl.java @@ -1,17 +1,17 @@ package com.lq.cms.service.impl; import com.lq.cms.emun.StatusTypeEnum; +import com.lq.cms.emun.WechatKeywordMatchinTypeEnum; import com.lq.cms.service.WechatRuleService; import com.lq.cms.vo.WechatRuleVo; import com.lq.code.dao.BaseDao; import com.lq.code.service.impl.BaseServiceImpl; import com.lq.code.util.BeanUtil; import com.lq.dao.WechatKeywordDao; +import com.lq.dao.WechatMessageDao; import com.lq.dao.WechatRuleDao; -import com.lq.entity.SysUser; -import com.lq.entity.WechatInfo; -import com.lq.entity.WechatKeyword; -import com.lq.entity.WechatRule; +import com.lq.dao.WechatRuleMessageDao; +import com.lq.entity.*; import com.lq.wechat.mode.message.BaseMessage; import org.apache.shiro.SecurityUtils; import org.apache.shiro.subject.Subject; @@ -35,10 +35,26 @@ public class WechatRuleServiceImpl extends BaseServiceImpl implement private WechatRuleDao wechatRuleDao; @Autowired private WechatKeywordDao wechatKeywordDao; + @Autowired + private WechatRuleMessageDao wechatRuleMessageDao; @Override public BaseMessage getByKeyworkdAndWechatInfoId(String keyworkd, WechatInfo wechatInfo) { + List wechatRuleList = wechatRuleDao.findByWechatInfoIdAndStatus(wechatInfo.getId(),StatusTypeEnum.STATUS_ACTIVITY_YES.getValue()); + wechatRuleList.forEach((wechatRule)->{ + List wechatKeywordList = wechatKeywordDao.findByWechatRuleIdAndStatus(wechatRule.getId(),StatusTypeEnum.STATUS_ACTIVITY_YES.getValue()); + wechatKeywordList.forEach((wechatKeyword)->{ + if (WechatKeywordMatchinTypeEnum.KEYWORD_ALL.getValue().equals(wechatKeyword.getMatchinType())){ + if (keyworkd.equals(wechatKeyword.getKeyword())){ + List wechatMessageList = null; + } + }else { + + } + + }); + }); BaseMessage baseMessage = null; return baseMessage; diff --git a/src/main/java/com/lq/cms/web/wechat/WechatRuleController.java b/src/main/java/com/lq/cms/web/wechat/WechatRuleController.java index 4d54c02..c7949fc 100755 --- a/src/main/java/com/lq/cms/web/wechat/WechatRuleController.java +++ b/src/main/java/com/lq/cms/web/wechat/WechatRuleController.java @@ -10,6 +10,7 @@ import com.lq.code.entity.AjaxResult; import com.lq.code.util.StringUtil; import com.lq.entity.WechatInfo; import com.lq.entity.WechatKeyword; +import com.lq.entity.WechatMessage; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @@ -64,6 +65,10 @@ public class WechatRuleController { List wechatKeywordList = JSON.parseArray(keywordListStr, WechatKeyword.class); vo.setWechatKeywordList(wechatKeywordList); } + if (StringUtil.isNotNull(messageListStr)){ + List messageIds = JSON.parseArray(messageListStr, Long.class); + vo.setMessageIds(messageIds); + } wechatRuleService.saveRule(vo); return ajaxResult; diff --git a/src/main/java/com/lq/code/util/mybatisPlus/CreateMapperFileUtil.java b/src/main/java/com/lq/code/util/mybatisPlus/CreateMapperFileUtil.java index fe606fb..73ff982 100755 --- a/src/main/java/com/lq/code/util/mybatisPlus/CreateMapperFileUtil.java +++ b/src/main/java/com/lq/code/util/mybatisPlus/CreateMapperFileUtil.java @@ -5,7 +5,9 @@ import com.lq.code.util.sql.AbstractDbBuiler; import com.lq.code.util.sql.MysqlBuilder; import com.lq.code.util.sql.SqlUtil; import com.lq.dao.WechatKeywordDao; +import com.lq.dao.WechatRuleMessageDao; import com.lq.entity.WechatKeyword; +import com.lq.entity.WechatRuleMessage; import java.io.File; import java.io.IOException; @@ -60,7 +62,8 @@ public class CreateMapperFileUtil { } public static void main(String[] args) throws IOException { - createXml(WechatKeywordDao.class,WechatKeyword.class,new MysqlBuilder()); + AbstractDbBuiler abstractDbBuiler = new MysqlBuilder(); + createXml(WechatRuleMessageDao.class, WechatRuleMessage.class,abstractDbBuiler); } diff --git a/src/main/java/com/lq/dao/WechatRuleMessageDao.java b/src/main/java/com/lq/dao/WechatRuleMessageDao.java new file mode 100644 index 0000000..c39c5ed --- /dev/null +++ b/src/main/java/com/lq/dao/WechatRuleMessageDao.java @@ -0,0 +1,7 @@ +package com.lq.dao; + +import com.lq.code.dao.BaseDao; +import com.lq.entity.WechatRuleMessage; + +public interface WechatRuleMessageDao extends BaseDao { +} diff --git a/src/main/resources/dev/jdbc.properties b/src/main/resources/dev/jdbc.properties index 8741005..2087517 100644 --- a/src/main/resources/dev/jdbc.properties +++ b/src/main/resources/dev/jdbc.properties @@ -1,6 +1,6 @@ #--------- jdbc 配置--------- jdbc.driver=com.mysql.jdbc.Driver -jdbc.url=jdbc:mysql://192.168.31.19:3306/ssm?useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8 +jdbc.url=jdbc:mysql://192.168.31.110:3306/ssm?useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8 jdbc.user=root jdbc.password=mysql #--------数据库连接池配置 ------- diff --git a/src/main/resources/dev/redis.properties b/src/main/resources/dev/redis.properties index 80be888..b61b6af 100644 --- a/src/main/resources/dev/redis.properties +++ b/src/main/resources/dev/redis.properties @@ -1,4 +1,4 @@ -redis.host=127.0.0.1 +redis.host=192.168.31.19 redis.port=6379 redis.pass= redis.timeout=-1 diff --git a/src/main/resources/mybatis/mapping/WechatRuleMessageDao.xml b/src/main/resources/mybatis/mapping/WechatRuleMessageDao.xml new file mode 100644 index 0000000..ea47bb5 --- /dev/null +++ b/src/main/resources/mybatis/mapping/WechatRuleMessageDao.xml @@ -0,0 +1,67 @@ + + + + + + + + wechat_rule_id,id,wechat_message_id,status + + + + + + + + + + + + SELECT LAST_INSERT_ID() + + INSERT INTO + wechat_rule_message(wechat_rule_id,id,wechat_message_id,status) + VALUES + ( + #{wechatRuleId},#{id},#{wechatMessageId},#{status} + ) + + + + + UPDATE + wechat_rule_message + + + wechat_rule_id=#{wechatRuleId}, + id=#{id}, + wechat_message_id=#{wechatMessageId}, + status=#{status}, + + WHERE + id=#{id} + + + + UPDATE + wechat_rule_message + SET + status = 0 + WHERE + id=#{id} + + + \ No newline at end of file diff --git a/src/main/resources/pro/jdbc.properties b/src/main/resources/pro/jdbc.properties index 537c374..0f28bcc 100644 --- a/src/main/resources/pro/jdbc.properties +++ b/src/main/resources/pro/jdbc.properties @@ -1,6 +1,6 @@ #--------- jdbc ����--------- jdbc.driver=com.mysql.jdbc.Driver -jdbc.url=jdbc:mysql://192.168.31.19:3306/ssm?useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8 +jdbc.url=jdbc:mysql://192.168.31.110:3306/ssm?useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8 jdbc.user=root jdbc.password=mysql #--------���ݿ����ӳ����� ------- diff --git a/src/main/resources/pro/redis.properties b/src/main/resources/pro/redis.properties index d8a745a..f3e3342 100644 --- a/src/main/resources/pro/redis.properties +++ b/src/main/resources/pro/redis.properties @@ -1,4 +1,4 @@ -redis.host=192.168.31.19 +redis.host=192.168.31.110 redis.port=6379 redis.pass= redis.timeout=-1 diff --git a/src/main/resources/spring/spring-shiro.xml b/src/main/resources/spring/spring-shiro.xml index 4885acc..39fb94d 100644 --- a/src/main/resources/spring/spring-shiro.xml +++ b/src/main/resources/spring/spring-shiro.xml @@ -26,11 +26,13 @@ - + + + diff --git a/src/main/resources/test/jdbc.properties b/src/main/resources/test/jdbc.properties index dd9d45e..93886b7 100644 --- a/src/main/resources/test/jdbc.properties +++ b/src/main/resources/test/jdbc.properties @@ -1,16 +1,25 @@ +#--------- jdbc --------- jdbc.driver=com.mysql.jdbc.Driver -jdbc.url=jdbc:mysql://192.168.31.110:3306/ssm?useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8 +jdbc.url=jdbc:mysql://127.0.0.1:3306/ssm?useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8 jdbc.user=root jdbc.password=mysql -#\u5B9A\u4E49\u521D\u59CB\u8FDE\u63A5\u6570 -initialSize=0 -#\u5B9A\u4E49\u6700\u5927\u8FDE\u63A5\u6570 -maxActive=5 -#\u5B9A\u4E49\u6700\u5927\u7A7A\u95F2 -maxIdle=5 -#\u5B9A\u4E49\u6700\u5C0F\u7A7A\u95F2 -minIdle=1 -#\u5B9A\u4E49\u6700\u957F\u7B49\u5F85\u65F6\u95F4 -maxWait=6000 -email.port=Create property +#--------ݿӳ ------- +durid.pool.initialSize=5 +durid.pool.maxActive=5 +durid.pool.minIdle=1 +durid.pool.maxWait=60000 +durid.pool.timeBetweenEvictionRunsMillis=60000 +durid.pool.filters=stat +durid.pool.poolPreparedStatements=false +durid.pool.maxPoolPreparedStatementPerConnectionSize=100 +durid.pool.minEvictableIdleTimeMillis=300000 +durid.pool.validationQuery=SELECT 'X' +durid.pool.testWhileIdle=true +durid.pool.testOnBorrow=false +durid.pool.testOnReturn=false +durid.pool.removeAbandonedTimeout=1800 +durid.pool.logAbandoned=true + + +durid.pool.email.port=Create property diff --git a/src/main/resources/test/redis.properties b/src/main/resources/test/redis.properties index 3cd757e..80be888 100644 --- a/src/main/resources/test/redis.properties +++ b/src/main/resources/test/redis.properties @@ -3,7 +3,7 @@ redis.port=6379 redis.pass= redis.timeout=-1 -redis.maxTotal=30 +redis.maxTotal=15 redis.maxIdle=10 redis.numTestsPerEvictionRun=1024 redis.timeBetweenEvictionRunsMillis=30000 @@ -12,5 +12,5 @@ redis.softMinEvictableIdleTimeMillis=10000 redis.maxWaitMillis=1500 redis.testWhileIdle=true redis.blockWhenExhausted=false -redis.minIdle=8 +redis.minIdle=5 redis.testOnBorrow=true \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/jsp/cms/sys/user/edit.jsp b/src/main/webapp/WEB-INF/views/jsp/cms/sys/user/edit.jsp index ba861f1..d39ba67 100755 --- a/src/main/webapp/WEB-INF/views/jsp/cms/sys/user/edit.jsp +++ b/src/main/webapp/WEB-INF/views/jsp/cms/sys/user/edit.jsp @@ -35,7 +35,6 @@ return url ; } -
@@ -53,8 +52,6 @@ - - 电子邮箱: diff --git a/src/main/webapp/WEB-INF/views/jsp/cms/wechat/rule/index.jsp b/src/main/webapp/WEB-INF/views/jsp/cms/wechat/rule/index.jsp index 602e9bf..3a0470a 100755 --- a/src/main/webapp/WEB-INF/views/jsp/cms/wechat/rule/index.jsp +++ b/src/main/webapp/WEB-INF/views/jsp/cms/wechat/rule/index.jsp @@ -344,7 +344,6 @@ }); $("#subscribe-save").click(function(){ - var data = new Object(); var messageContent = $("#subscribe-arce").html(); data.content = messageContent; @@ -356,7 +355,6 @@ if(messageContent.length==0){ layer.msg('回复内容不能为空'); return ; - } if(messageContent.length>maxInputNum){ layer.msg('字数超出限制,不能提交'); @@ -398,7 +396,6 @@ dataType:"json", success:function(result){ if(result.success==true){ - index = layer.open({ type: 1, btn:['确定','取消'], @@ -665,7 +662,6 @@ } function showeditText(){ - var html = '
'; return html; }