微信公众号功能开发中...

master
星期八 5 years ago
parent 1b60971272
commit 7b53bce557
  1. 2
      src/main/java/com/lq/cms/dao/AdminBaseDao.java
  2. 44
      src/main/java/com/lq/cms/service/impl/WechatRuleServiceImpl.java
  3. 2
      src/main/java/com/lq/dao/WechatRuleMessageDao.java
  4. 13
      src/main/java/com/lq/entity/SysPermission.java

@ -5,7 +5,7 @@ import com.lq.code.dao.BaseDao;
import java.util.List;
public interface AdminBaseDao<T,V extends AdminBaseVo> extends BaseDao {
public interface AdminBaseDao<T,V extends AdminBaseVo> extends BaseDao<T> {
List<V> findListPage(V vo);

@ -2,6 +2,7 @@ package com.lq.cms.service.impl;
import com.lq.cms.emun.StatusTypeEnum;
import com.lq.cms.emun.WechatKeywordMatchinTypeEnum;
import com.lq.cms.emun.WechatRuleReplyTypeEnum;
import com.lq.cms.service.WechatRuleService;
import com.lq.cms.vo.WechatRuleVo;
import com.lq.code.dao.BaseDao;
@ -22,6 +23,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
/**
* @Author: qi
@ -37,20 +39,58 @@ public class WechatRuleServiceImpl extends BaseServiceImpl<WechatRule> implement
private WechatKeywordDao wechatKeywordDao;
@Autowired
private WechatRuleMessageDao wechatRuleMessageDao;
@Autowired
private WechatMessageDao wechatMessageDao;
@Override
public BaseMessage getByKeyworkdAndWechatInfoId(String keyworkd, WechatInfo wechatInfo) {
List<WechatMessage> wechatMessageList = new ArrayList<>();
//公众号相关回复规则
List<WechatRule> wechatRuleList = wechatRuleDao.findByWechatInfoIdAndStatus(wechatInfo.getId(),StatusTypeEnum.STATUS_ACTIVITY_YES.getValue());
wechatRuleList.forEach((wechatRule)->{
//规则相关关键词
List<WechatKeyword> 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<WechatMessage> wechatMessageList = null;
List<WechatRuleMessage> wechatRuleMessageList = wechatRuleMessageDao.findByWechatRuleId(wechatRule.getId());
if (WechatRuleReplyTypeEnum.REPLY_ALL.getValue().equals(wechatRule.getReplyType())) {
wechatRuleMessageList.forEach((wechatRuleMessage) -> {
WechatMessage wechatMessage = wechatMessageDao.findOne(wechatRuleMessage.getId());
if (wechatMessage != null) {
wechatMessageList.add(wechatMessage);
}
});
}
if (WechatRuleReplyTypeEnum.REPLY_RANDOM.getValue().equals(wechatRule.getReplyType())){
ThreadLocalRandom threadLocalRandom=ThreadLocalRandom.current();
int index = ThreadLocalRandom.current().nextInt(wechatRuleMessageList.size());
WechatRuleMessage wechatRuleMessage = wechatRuleMessageList.get(index);
WechatMessage wechatMessage = wechatMessageDao.findOne(wechatRuleMessage.getId());
wechatMessageList.add(wechatMessage);
}
}
}else {
if (keyworkd.indexOf(wechatKeyword.getKeyword())!=-1){
List<WechatRuleMessage> wechatRuleMessageList = wechatRuleMessageDao.findByWechatRuleId(wechatRule.getId());
if (WechatRuleReplyTypeEnum.REPLY_ALL.getValue().equals(wechatRule.getReplyType())) {
wechatRuleMessageList.forEach((wechatRuleMessage) -> {
WechatMessage wechatMessage = wechatMessageDao.findOne(wechatRuleMessage.getId());
if (wechatMessage != null) {
wechatMessageList.add(wechatMessage);
}
});
}
if (WechatRuleReplyTypeEnum.REPLY_RANDOM.getValue().equals(wechatRule.getReplyType())){
ThreadLocalRandom threadLocalRandom=ThreadLocalRandom.current();
int index = ThreadLocalRandom.current().nextInt(wechatRuleMessageList.size());
WechatRuleMessage wechatRuleMessage = wechatRuleMessageList.get(index);
WechatMessage wechatMessage = wechatMessageDao.findOne(wechatRuleMessage.getId());
wechatMessageList.add(wechatMessage);
}
}
}
});

@ -1,6 +1,7 @@
package com.lq.dao;
import com.lq.code.dao.BaseDao;
import com.lq.entity.WechatMessage;
import com.lq.entity.WechatRuleMessage;
import org.apache.ibatis.annotations.Param;
@ -11,4 +12,5 @@ public interface WechatRuleMessageDao extends BaseDao<WechatRuleMessage> {
WechatRuleMessage getByRuleIdAndMessageId(@Param("ruleId")Long ruleId,@Param("messageId")Long messageId);
List<WechatRuleMessage> findByWechatRuleId(@Param("wechatRuleId")Long wechatRuleId);
}

@ -7,6 +7,10 @@ import com.lq.code.entity.IdEntity;
*/
public class SysPermission extends IdEntity{
/**
* 关联资源ID
*/
private Long sysResourceId;
/**
* 权限名称
*/
@ -15,11 +19,18 @@ public class SysPermission extends IdEntity{
* 权限类型
*/
private Integer permissionType;
/**·
/**
* 权限键值
*/
private String permissionKey;
public Long getSysResourceId() {
return sysResourceId;
}
public void setSysResourceId(Long sysResourceId) {
this.sysResourceId = sysResourceId;
}
public String getName() {
return name;

Loading…
Cancel
Save