From 29e330e467be8ca41598d6bb07314f54fd27b320 Mon Sep 17 00:00:00 2001 From: jinqiming <45981669@qq.com> Date: Wed, 3 Mar 2021 17:55:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E6=81=AF=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/SysNewsTriggersController.java | 37 +++++--- .../src/main/resources/application-druid.yml | 6 +- .../templates/system/triggers/add.html | 14 ++- .../templates/system/triggers/triggers.html | 89 +++++++------------ .../com/snow/common/constant/Constants.java | 11 +++ .../web/service/NewsTriggerService.java | 71 +++++++++++++++ .../com/snow/system/domain/SysNewsNode.java | 55 +----------- .../snow/system/domain/SysNewsTriggers.java | 82 ++--------------- .../snow/system/mapper/SysNewsNodeMapper.java | 7 ++ .../system/service/ISysNewsNodeService.java | 7 ++ .../service/impl/SysNewsNodeServiceImpl.java | 5 ++ .../impl/SysNewsTriggersServiceImpl.java | 17 +++- .../mapper/system/SysNewsNodeMapper.xml | 6 +- .../mapper/system/SysNewsTriggersMapper.xml | 2 +- 14 files changed, 207 insertions(+), 202 deletions(-) create mode 100644 snow-framework/src/main/java/com/snow/framework/web/service/NewsTriggerService.java diff --git a/snow-admin/src/main/java/com/snow/web/controller/system/SysNewsTriggersController.java b/snow-admin/src/main/java/com/snow/web/controller/system/SysNewsTriggersController.java index 65b3789..cdbbe61 100644 --- a/snow-admin/src/main/java/com/snow/web/controller/system/SysNewsTriggersController.java +++ b/snow-admin/src/main/java/com/snow/web/controller/system/SysNewsTriggersController.java @@ -4,6 +4,7 @@ import java.util.List; import com.snow.framework.util.ShiroUtils; import com.snow.system.domain.SysUser; +import org.apache.commons.collections.CollectionUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.ui.ModelMap; @@ -53,6 +54,8 @@ public class SysNewsTriggersController extends BaseController public TableDataInfo list(SysNewsTriggers sysNewsTriggers) { startPage(); + SysUser sysUser = ShiroUtils.getSysUser(); + sysNewsTriggers.setUserId(String.valueOf(sysUser.getUserId())); List list = sysNewsTriggersService.selectSysNewsTriggersList(sysNewsTriggers); return getDataTable(list); } @@ -68,6 +71,7 @@ public class SysNewsTriggersController extends BaseController { SysUser sysUser = ShiroUtils.getSysUser(); sysNewsTriggers.setUserId(String.valueOf(sysUser.getUserId())); + List list = sysNewsTriggersService.selectSysNewsTriggersList(sysNewsTriggers); ExcelUtil util = new ExcelUtil(SysNewsTriggers.class); return util.exportExcel(list, "triggers"); @@ -93,6 +97,13 @@ public class SysNewsTriggersController extends BaseController { SysUser sysUser = ShiroUtils.getSysUser(); sysNewsTriggers.setUserId(String.valueOf(sysUser.getUserId())); + sysNewsTriggers.setNewsOnOff(null); + List sysNewsTriggersList = sysNewsTriggersService.selectSysNewsTriggersList(sysNewsTriggers); + if(CollectionUtils.isNotEmpty(sysNewsTriggersList)){ + return AjaxResult.error("该配置已存在,请勿重复添加"); + } + sysNewsTriggers.setNewsOnOff(sysNewsTriggers.getNewsOnOff()); + sysNewsTriggers.setCreateBy(String.valueOf(sysUser.getUserId())); return toAjax(sysNewsTriggersService.insertSysNewsTriggers(sysNewsTriggers)); } @@ -107,17 +118,6 @@ public class SysNewsTriggersController extends BaseController return prefix + "/edit"; } - /** - * 修改保存消息通知配置 - */ - @RequiresPermissions("system:triggers:edit") - @Log(title = "消息通知配置", businessType = BusinessType.UPDATE) - @PostMapping("/edit") - @ResponseBody - public AjaxResult editSave(SysNewsTriggers sysNewsTriggers) - { - return toAjax(sysNewsTriggersService.updateSysNewsTriggers(sysNewsTriggers)); - } /** * 删除消息通知配置 @@ -130,4 +130,19 @@ public class SysNewsTriggersController extends BaseController { return toAjax(sysNewsTriggersService.deleteSysNewsTriggersByIds(ids)); } + + + /** + * 开启关闭通知 + */ + @RequiresPermissions("system:triggers:changeStatus") + @Log(title = "开启关闭通知", businessType = BusinessType.UPDATE) + @PostMapping("/changeStatus") + @ResponseBody + public AjaxResult changeStatus(SysNewsTriggers sysNewsTriggers) + { + SysUser sysUser = ShiroUtils.getSysUser(); + sysNewsTriggers.setUpdateBy(String.valueOf(sysUser.getUserId())); + return toAjax(sysNewsTriggersService.updateSysNewsTriggers(sysNewsTriggers)); + } } diff --git a/snow-admin/src/main/resources/application-druid.yml b/snow-admin/src/main/resources/application-druid.yml index f59d864..91f1014 100644 --- a/snow-admin/src/main/resources/application-druid.yml +++ b/snow-admin/src/main/resources/application-druid.yml @@ -6,9 +6,9 @@ spring: druid: # 主库数据源 master: - url: jdbc:mysql://rm-bp1j1554xv1qs04295o.mysql.rds.aliyuncs.com:3306/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 - username: cloud_root - password: Jin!152377 + url: jdbc:mysql://localhost:3306/snow?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: root + password: root # 从库数据源 slave: # 从数据源开关/默认关闭 diff --git a/snow-admin/src/main/resources/templates/system/triggers/add.html b/snow-admin/src/main/resources/templates/system/triggers/add.html index ca50388..fc8c669 100644 --- a/snow-admin/src/main/resources/templates/system/triggers/add.html +++ b/snow-admin/src/main/resources/templates/system/triggers/add.html @@ -6,16 +6,25 @@
- +
- +
+
+ +
+
+ + +
+
+
@@ -55,6 +64,7 @@ function doSubmit(index, layero){ var body = layer.getChildFrame('body', index); $("#treeId").val(body.find('#treeId').val()); + $("#newsNodeId").val(body.find('#treeId').val()); $("#treeName").val(body.find('#treeName').val()); layer.close(index); } diff --git a/snow-admin/src/main/resources/templates/system/triggers/triggers.html b/snow-admin/src/main/resources/templates/system/triggers/triggers.html index 9714080..6ab087f 100644 --- a/snow-admin/src/main/resources/templates/system/triggers/triggers.html +++ b/snow-admin/src/main/resources/templates/system/triggers/triggers.html @@ -30,17 +30,17 @@
- +
  • - +
  • - 消息类型: @@ -56,19 +56,16 @@
@@ -86,6 +83,7 @@ - - \ No newline at end of file diff --git a/snow-common/src/main/java/com/snow/common/constant/Constants.java b/snow-common/src/main/java/com/snow/common/constant/Constants.java index d4925ae..e920c43 100644 --- a/snow-common/src/main/java/com/snow/common/constant/Constants.java +++ b/snow-common/src/main/java/com/snow/common/constant/Constants.java @@ -125,4 +125,15 @@ public class Constants * 钉钉回调失败返回 */ public static final String CALL_BACK_FAIL_RETURN="fail"; + + + /** + * dingding消息类型 + */ + public static final Integer NEWS_DINGDING_TYPE=1; + + /** + * 邮件消息类型 + */ + public static final Integer NEWS_EMAIL_TYPE=2; } diff --git a/snow-framework/src/main/java/com/snow/framework/web/service/NewsTriggerService.java b/snow-framework/src/main/java/com/snow/framework/web/service/NewsTriggerService.java new file mode 100644 index 0000000..b9c3cd3 --- /dev/null +++ b/snow-framework/src/main/java/com/snow/framework/web/service/NewsTriggerService.java @@ -0,0 +1,71 @@ +package com.snow.framework.web.service; + +import com.snow.common.constant.Constants; +import com.snow.framework.util.ShiroUtils; +import com.snow.system.domain.SysNewsNode; +import com.snow.system.domain.SysNewsTriggers; +import com.snow.system.domain.SysUser; +import com.snow.system.service.impl.SysNewsNodeServiceImpl; +import com.snow.system.service.impl.SysNewsTriggersServiceImpl; +import org.apache.commons.collections.CollectionUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @author qimingjin + * @Title: + * @Description: + * @date 2021/3/3 17:03 + */ +@Service("newsTrigger") +public class NewsTriggerService { + + @Autowired + private SysNewsNodeServiceImpl sysNewsNodeService; + + @Autowired + private SysNewsTriggersServiceImpl sysNewsTriggersService; + + + /** + * 获取Email消息通知开关 + * @param nodeKey + * @return + */ + public boolean getEmailOnOff(String nodeKey) + { + return getNewsOnOff(nodeKey,Constants.NEWS_EMAIL_TYPE); + } + + + /** + * 获取钉钉开关 + * @param nodeKey + * @return + */ + public boolean getDingTalkOnOff(String nodeKey) + { + return getNewsOnOff(nodeKey,Constants.NEWS_DINGDING_TYPE); + } + + + private boolean getNewsOnOff(String nodeKey,Integer newsType){ + SysNewsNode sysNewsNode = sysNewsNodeService.selectSysNewsNodeByKey(nodeKey); + if(null == sysNewsNode){ + return false; + } + SysNewsTriggers sysNewsTriggers=new SysNewsTriggers(); + sysNewsTriggers.setNewsNodeId(sysNewsNode.getId()); + sysNewsTriggers.setNewsType(newsType); + SysUser sysUser = ShiroUtils.getSysUser(); + sysNewsTriggers.setUserId(String.valueOf(sysUser.getUserId())); + List sysNewsTriggersList = sysNewsTriggersService.selectSysNewsTriggersList(sysNewsTriggers); + if(CollectionUtils.isNotEmpty(sysNewsTriggersList)){ + Integer newsOnOff = sysNewsTriggersList.get(0).getNewsOnOff(); + return newsOnOff==1; + } + return false; + } +} diff --git a/snow-system/src/main/java/com/snow/system/domain/SysNewsNode.java b/snow-system/src/main/java/com/snow/system/domain/SysNewsNode.java index a80858a..caa5cc3 100644 --- a/snow-system/src/main/java/com/snow/system/domain/SysNewsNode.java +++ b/snow-system/src/main/java/com/snow/system/domain/SysNewsNode.java @@ -4,6 +4,7 @@ import com.snow.common.annotation.Excel; import com.fasterxml.jackson.annotation.JsonFormat; import com.snow.common.core.domain.BaseEntity; import com.snow.common.core.domain.TreeEntity; +import lombok.Data; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; @@ -13,6 +14,7 @@ import org.apache.commons.lang3.builder.ToStringStyle; * @author qimingjin * @date 2021-03-02 */ +@Data public class SysNewsNode extends TreeEntity { private static final long serialVersionUID = 1L; @@ -32,57 +34,4 @@ public class SysNewsNode extends TreeEntity @Excel(name = "是否删除", readConverterExp = "0=--否,1--是") private Long isDelete; - public void setId(Integer id) - { - this.id = id; - } - - public Integer getId() - { - return id; - } - public void setNewsNodeName(String newsNodeName) - { - this.newsNodeName = newsNodeName; - } - - public String getNewsNodeName() - { - return newsNodeName; - } - public void setNewsNodeKey(String newsNodeKey) - { - this.newsNodeKey = newsNodeKey; - } - - public String getNewsNodeKey() - { - return newsNodeKey; - } - public void setIsDelete(Long isDelete) - { - this.isDelete = isDelete; - } - - public Long getIsDelete() - { - return isDelete; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("id", getId()) - .append("newsNodeName", getNewsNodeName()) - .append("newsNodeKey", getNewsNodeKey()) - .append("parentId", getParentId()) - .append("ancestors", getAncestors()) - .append("orderNum", getOrderNum()) - .append("isDelete", getIsDelete()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .toString(); - } } diff --git a/snow-system/src/main/java/com/snow/system/domain/SysNewsTriggers.java b/snow-system/src/main/java/com/snow/system/domain/SysNewsTriggers.java index 760943d..975cf23 100644 --- a/snow-system/src/main/java/com/snow/system/domain/SysNewsTriggers.java +++ b/snow-system/src/main/java/com/snow/system/domain/SysNewsTriggers.java @@ -3,6 +3,7 @@ package com.snow.system.domain; import com.snow.common.annotation.Excel; import com.fasterxml.jackson.annotation.JsonFormat; import com.snow.common.core.domain.BaseEntity; +import lombok.Data; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; @@ -12,6 +13,7 @@ import org.apache.commons.lang3.builder.ToStringStyle; * @author qimingjin * @date 2021-03-02 */ +@Data public class SysNewsTriggers extends BaseEntity { private static final long serialVersionUID = 1L; @@ -21,15 +23,15 @@ public class SysNewsTriggers extends BaseEntity /** 流程消息节点key */ @Excel(name = "流程消息节点key") - private Long newsNodeId; + private Integer newsNodeId; /** 消息类型(1-钉钉,2-邮件,3-短信,4-站内消息) */ @Excel(name = "消息类型", readConverterExp = "1=-钉钉,2-邮件,3-短信,4-站内消息") - private Long newsType; + private Integer newsType; /** 消息开关(0--关,1--开) */ @Excel(name = "消息开关", readConverterExp = "0=--关,1--开") - private Long newsOnOff; + private Integer newsOnOff; /** 用户id */ @Excel(name = "用户id") @@ -39,74 +41,8 @@ public class SysNewsTriggers extends BaseEntity @Excel(name = "是否删除", readConverterExp = "0=--否,1--是") private Long isDelete; - public void setId(Integer id) - { - this.id = id; - } - - public Integer getId() - { - return id; - } - public void setNewsNodeId(Long newsNodeId) - { - this.newsNodeId = newsNodeId; - } - - public Long getNewsNodeId() - { - return newsNodeId; - } - public void setNewsType(Long newsType) - { - this.newsType = newsType; - } - - public Long getNewsType() - { - return newsType; - } - public void setNewsOnOff(Long newsOnOff) - { - this.newsOnOff = newsOnOff; - } - - public Long getNewsOnOff() - { - return newsOnOff; - } - public void setUserId(String userId) - { - this.userId = userId; - } - - public String getUserId() - { - return userId; - } - public void setIsDelete(Long isDelete) - { - this.isDelete = isDelete; - } - - public Long getIsDelete() - { - return isDelete; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("id", getId()) - .append("newsNodeId", getNewsNodeId()) - .append("newsType", getNewsType()) - .append("newsOnOff", getNewsOnOff()) - .append("userId", getUserId()) - .append("isDelete", getIsDelete()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .toString(); - } + /** + * 节点信息 + */ + private SysNewsNode sysNewsNode; } diff --git a/snow-system/src/main/java/com/snow/system/mapper/SysNewsNodeMapper.java b/snow-system/src/main/java/com/snow/system/mapper/SysNewsNodeMapper.java index 824e689..4a71a70 100644 --- a/snow-system/src/main/java/com/snow/system/mapper/SysNewsNodeMapper.java +++ b/snow-system/src/main/java/com/snow/system/mapper/SysNewsNodeMapper.java @@ -19,6 +19,13 @@ public interface SysNewsNodeMapper */ public SysNewsNode selectSysNewsNodeById(Integer id); + /** + * 查询消息配置节点 + * @param newsNodeKey 配置节点key + * @return + */ + public SysNewsNode selectSysNewsNodeByKey(String newsNodeKey); + /** * 查询消息配置节点列表 * diff --git a/snow-system/src/main/java/com/snow/system/service/ISysNewsNodeService.java b/snow-system/src/main/java/com/snow/system/service/ISysNewsNodeService.java index bb13837..04e58e6 100644 --- a/snow-system/src/main/java/com/snow/system/service/ISysNewsNodeService.java +++ b/snow-system/src/main/java/com/snow/system/service/ISysNewsNodeService.java @@ -20,6 +20,13 @@ public interface ISysNewsNodeService */ public SysNewsNode selectSysNewsNodeById(Integer id); + /** + * 查询消息配置节点 + * @param newsNodeKey 配置节点key + * @return + */ + public SysNewsNode selectSysNewsNodeByKey(String newsNodeKey); + /** * 查询消息配置节点列表 * diff --git a/snow-system/src/main/java/com/snow/system/service/impl/SysNewsNodeServiceImpl.java b/snow-system/src/main/java/com/snow/system/service/impl/SysNewsNodeServiceImpl.java index c14a10a..ad67d8d 100644 --- a/snow-system/src/main/java/com/snow/system/service/impl/SysNewsNodeServiceImpl.java +++ b/snow-system/src/main/java/com/snow/system/service/impl/SysNewsNodeServiceImpl.java @@ -35,6 +35,11 @@ public class SysNewsNodeServiceImpl implements ISysNewsNodeService return sysNewsNodeMapper.selectSysNewsNodeById(id); } + @Override + public SysNewsNode selectSysNewsNodeByKey(String newsNodeKey) { + return sysNewsNodeMapper.selectSysNewsNodeByKey(newsNodeKey); + } + /** * 查询消息配置节点列表 * diff --git a/snow-system/src/main/java/com/snow/system/service/impl/SysNewsTriggersServiceImpl.java b/snow-system/src/main/java/com/snow/system/service/impl/SysNewsTriggersServiceImpl.java index bacfebd..bd82dd6 100644 --- a/snow-system/src/main/java/com/snow/system/service/impl/SysNewsTriggersServiceImpl.java +++ b/snow-system/src/main/java/com/snow/system/service/impl/SysNewsTriggersServiceImpl.java @@ -1,7 +1,10 @@ package com.snow.system.service.impl; +import java.util.ArrayList; import java.util.List; import com.snow.common.utils.DateUtils; +import com.snow.common.utils.StringUtils; +import com.snow.system.domain.SysNewsNode; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.snow.system.mapper.SysNewsTriggersMapper; @@ -21,6 +24,9 @@ public class SysNewsTriggersServiceImpl implements ISysNewsTriggersService @Autowired private SysNewsTriggersMapper sysNewsTriggersMapper; + @Autowired + private SysNewsNodeServiceImpl sysNewsNodeService; + /** * 查询消息通知配置 * @@ -42,7 +48,16 @@ public class SysNewsTriggersServiceImpl implements ISysNewsTriggersService @Override public List selectSysNewsTriggersList(SysNewsTriggers sysNewsTriggers) { - return sysNewsTriggersMapper.selectSysNewsTriggersList(sysNewsTriggers); + List sysNewsTriggersList=new ArrayList<>(); + if(StringUtils.isNotNull(sysNewsTriggers.getNewsNodeId())){ + SysNewsNode sysNewsNode = sysNewsNodeService.selectSysNewsNodeById(sysNewsTriggers.getNewsNodeId().intValue()); + sysNewsTriggersList = sysNewsTriggersMapper.selectSysNewsTriggersList(sysNewsTriggers); + sysNewsTriggersList.parallelStream().forEach(t->{ + t.setSysNewsNode(sysNewsNode); + }); + } + + return sysNewsTriggersList; } /** diff --git a/snow-system/src/main/resources/mapper/system/SysNewsNodeMapper.xml b/snow-system/src/main/resources/mapper/system/SysNewsNodeMapper.xml index 37b85b9..23d5a72 100644 --- a/snow-system/src/main/resources/mapper/system/SysNewsNodeMapper.xml +++ b/snow-system/src/main/resources/mapper/system/SysNewsNodeMapper.xml @@ -42,7 +42,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" left join sys_news_node p on p.id = t.parent_id where t.id = #{id} - + + insert into sys_news_node diff --git a/snow-system/src/main/resources/mapper/system/SysNewsTriggersMapper.xml b/snow-system/src/main/resources/mapper/system/SysNewsTriggersMapper.xml index 873b7e0..ed5bfe6 100644 --- a/snow-system/src/main/resources/mapper/system/SysNewsTriggersMapper.xml +++ b/snow-system/src/main/resources/mapper/system/SysNewsTriggersMapper.xml @@ -36,7 +36,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} - + insert into sys_news_triggers