From d815de513dbb27e74445e352e6c250099542d71b Mon Sep 17 00:00:00 2001
From: sterben <1473352497@qq.com>
Date: Wed, 11 Oct 2023 16:27:16 +0800
Subject: [PATCH] =?UTF-8?q?[Feature#]=E8=A1=A5=E5=85=85=E4=BA=86=E6=9F=A5?=
 =?UTF-8?q?=E7=9C=8B=E8=A7=84=E5=88=99=E7=9A=84=E8=BF=94=E5=9B=9E=E6=95=B0?=
 =?UTF-8?q?=E6=8D=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../saber/biz/INotificationRuleBiz.java       |  3 ++-
 .../saber/biz/impl/NotificationRuleBiz.java   |  5 +++--
 .../NotificationRuleController.java           |  5 +++--
 .../saber/mapper/NotificationRuleMapper.java  |  3 +++
 .../pojo/domain/dto/NotificationRuleDto.java  | 20 +++++++++++++++++++
 .../saber/service/NotificationService.java    |  3 ++-
 .../service/impl/NotificationServiceImpl.java |  7 ++++---
 .../mapper/NotificationRuleMapper.xml         | 18 +++++++++++++++++
 8 files changed, 55 insertions(+), 9 deletions(-)
 create mode 100644 src/main/java/com/steadon/saber/pojo/domain/dto/NotificationRuleDto.java

diff --git a/src/main/java/com/steadon/saber/biz/INotificationRuleBiz.java b/src/main/java/com/steadon/saber/biz/INotificationRuleBiz.java
index 9716b62..dd24308 100644
--- a/src/main/java/com/steadon/saber/biz/INotificationRuleBiz.java
+++ b/src/main/java/com/steadon/saber/biz/INotificationRuleBiz.java
@@ -2,6 +2,7 @@ package com.steadon.saber.biz;
 
 import com.steadon.saber.pojo.SaberResponse;
 import com.steadon.saber.pojo.domain.NotificationRule;
+import com.steadon.saber.pojo.domain.dto.NotificationRuleDto;
 import com.steadon.saber.pojo.model.NotificationRuleRequest;
 import com.steadon.saber.pojo.model.pageData.PageData;
 
@@ -12,5 +13,5 @@ public interface INotificationRuleBiz {
 
     SaberResponse<String> deleteNotificationRule(Integer ruleId);
 
-    SaberResponse<PageData<NotificationRule>> getNotificationRuleBatch(Integer pageNo, Integer pageSize);
+    SaberResponse<PageData<NotificationRuleDto>> getNotificationRuleBatch(Integer pageNo, Integer pageSize);
 }
diff --git a/src/main/java/com/steadon/saber/biz/impl/NotificationRuleBiz.java b/src/main/java/com/steadon/saber/biz/impl/NotificationRuleBiz.java
index 0ca749b..66b32a9 100644
--- a/src/main/java/com/steadon/saber/biz/impl/NotificationRuleBiz.java
+++ b/src/main/java/com/steadon/saber/biz/impl/NotificationRuleBiz.java
@@ -3,6 +3,7 @@ package com.steadon.saber.biz.impl;
 import com.steadon.saber.biz.INotificationRuleBiz;
 import com.steadon.saber.pojo.SaberResponse;
 import com.steadon.saber.pojo.domain.NotificationRule;
+import com.steadon.saber.pojo.domain.dto.NotificationRuleDto;
 import com.steadon.saber.pojo.model.NotificationRuleRequest;
 import com.steadon.saber.pojo.model.pageData.PageData;
 import com.steadon.saber.service.NotificationService;
@@ -43,8 +44,8 @@ public class NotificationRuleBiz implements INotificationRuleBiz {
     }
 
     @Override
-    public SaberResponse<PageData<NotificationRule>> getNotificationRuleBatch(Integer pageNo, Integer pageSize) {
-        PageData<NotificationRule> notificationRuleBatch = notificationService.getNotificationRuleBatch(pageNo, pageSize);
+    public SaberResponse<PageData<NotificationRuleDto>> getNotificationRuleBatch(Integer pageNo, Integer pageSize) {
+        PageData<NotificationRuleDto> notificationRuleBatch = notificationService.getNotificationRuleBatch(pageNo, pageSize);
         return SaberResponse.success(notificationRuleBatch);
     }
 }
diff --git a/src/main/java/com/steadon/saber/controller/NotificationRuleController.java b/src/main/java/com/steadon/saber/controller/NotificationRuleController.java
index c727d65..22cf59a 100644
--- a/src/main/java/com/steadon/saber/controller/NotificationRuleController.java
+++ b/src/main/java/com/steadon/saber/controller/NotificationRuleController.java
@@ -3,6 +3,7 @@ package com.steadon.saber.controller;
 import com.steadon.saber.biz.INotificationRuleBiz;
 import com.steadon.saber.pojo.SaberResponse;
 import com.steadon.saber.pojo.domain.NotificationRule;
+import com.steadon.saber.pojo.domain.dto.NotificationRuleDto;
 import com.steadon.saber.pojo.model.NotificationRuleRequest;
 import com.steadon.saber.pojo.model.pageData.PageData;
 import lombok.AllArgsConstructor;
@@ -33,8 +34,8 @@ public class NotificationRuleController {
     }
 
     @GetMapping("/notification/rule/list")
-    public SaberResponse<PageData<NotificationRule>> getNotificationRuleBatch(@RequestParam(value = "page_no", required = false, defaultValue = "1") Integer pageNo,
-                                                                              @RequestParam(value = "page_size", required = false, defaultValue = "10") Integer pageSize) {
+    public SaberResponse<PageData<NotificationRuleDto>> getNotificationRuleBatch(@RequestParam(value = "page_no", required = false, defaultValue = "1") Integer pageNo,
+                                                                                 @RequestParam(value = "page_size", required = false, defaultValue = "10") Integer pageSize) {
         return iNotificationRuleBiz.getNotificationRuleBatch(pageNo, pageSize);
     }
 }
diff --git a/src/main/java/com/steadon/saber/mapper/NotificationRuleMapper.java b/src/main/java/com/steadon/saber/mapper/NotificationRuleMapper.java
index c24cf3c..4958c66 100644
--- a/src/main/java/com/steadon/saber/mapper/NotificationRuleMapper.java
+++ b/src/main/java/com/steadon/saber/mapper/NotificationRuleMapper.java
@@ -1,7 +1,9 @@
 package com.steadon.saber.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.steadon.saber.pojo.domain.NotificationRule;
+import com.steadon.saber.pojo.domain.dto.NotificationRuleDto;
 import org.apache.ibatis.annotations.Mapper;
 
 /**
@@ -15,4 +17,5 @@ import org.apache.ibatis.annotations.Mapper;
 @Mapper
 public interface NotificationRuleMapper extends BaseMapper<NotificationRule> {
 
+    IPage<NotificationRuleDto> selectDtoPage(IPage<NotificationRule> page);
 }
diff --git a/src/main/java/com/steadon/saber/pojo/domain/dto/NotificationRuleDto.java b/src/main/java/com/steadon/saber/pojo/domain/dto/NotificationRuleDto.java
new file mode 100644
index 0000000..f9b9031
--- /dev/null
+++ b/src/main/java/com/steadon/saber/pojo/domain/dto/NotificationRuleDto.java
@@ -0,0 +1,20 @@
+package com.steadon.saber.pojo.domain.dto;
+
+import lombok.Data;
+
+@Data
+public class NotificationRuleDto {
+    private Integer id;
+    private String code;
+    private Integer templateId;
+    private String templateName;
+    private Integer groupId;
+    private String groupName;
+    private Boolean feishuStatus;
+    private Boolean smsStatus;
+    private Boolean emailStatus;
+    private String createBy;
+    private String createTime;
+    private String updateBy;
+    private String updateTime;
+}
\ No newline at end of file
diff --git a/src/main/java/com/steadon/saber/service/NotificationService.java b/src/main/java/com/steadon/saber/service/NotificationService.java
index a397823..de88e1b 100644
--- a/src/main/java/com/steadon/saber/service/NotificationService.java
+++ b/src/main/java/com/steadon/saber/service/NotificationService.java
@@ -2,6 +2,7 @@ package com.steadon.saber.service;
 
 import com.steadon.saber.handler.chain.model.MessageInfo;
 import com.steadon.saber.pojo.domain.NotificationRule;
+import com.steadon.saber.pojo.domain.dto.NotificationRuleDto;
 import com.steadon.saber.pojo.model.pageData.PageData;
 
 public interface NotificationService {
@@ -16,5 +17,5 @@ public interface NotificationService {
 
     void deleteNotificationRule(Integer ruleId);
 
-    PageData<NotificationRule> getNotificationRuleBatch(Integer pageNo, Integer pageSize);
+    PageData<NotificationRuleDto> getNotificationRuleBatch(Integer pageNo, Integer pageSize);
 }
\ No newline at end of file
diff --git a/src/main/java/com/steadon/saber/service/impl/NotificationServiceImpl.java b/src/main/java/com/steadon/saber/service/impl/NotificationServiceImpl.java
index 59e1f9d..77a6d7f 100644
--- a/src/main/java/com/steadon/saber/service/impl/NotificationServiceImpl.java
+++ b/src/main/java/com/steadon/saber/service/impl/NotificationServiceImpl.java
@@ -11,6 +11,7 @@ import com.steadon.saber.pojo.domain.Notification;
 import com.steadon.saber.pojo.domain.NotificationRule;
 import com.steadon.saber.pojo.domain.NotificationUserMerge;
 import com.steadon.saber.pojo.domain.UserInfo;
+import com.steadon.saber.pojo.domain.dto.NotificationRuleDto;
 import com.steadon.saber.pojo.model.exception.SaberBaseException;
 import com.steadon.saber.pojo.model.pageData.PageData;
 import com.steadon.saber.service.NotificationService;
@@ -99,11 +100,11 @@ public class NotificationServiceImpl implements NotificationService {
     }
 
     @Override
-    public PageData<NotificationRule> getNotificationRuleBatch(Integer pageNo, Integer pageSize) {
+    public PageData<NotificationRuleDto> getNotificationRuleBatch(Integer pageNo, Integer pageSize) {
         Page<NotificationRule> page = new Page<>(pageNo, pageSize);
-        IPage<NotificationRule> notificationRulePage = notificationRuleMapper.selectPage(page, null);
+        IPage<NotificationRuleDto> notificationRulePage = notificationRuleMapper.selectDtoPage(page);
 
-        PageData<NotificationRule> notificationRulePageData = new PageData<>();
+        PageData<NotificationRuleDto> notificationRulePageData = new PageData<>();
         notificationRulePageData.praiseIPage(notificationRulePage);
         return notificationRulePageData;
     }
diff --git a/src/main/resources/mapper/NotificationRuleMapper.xml b/src/main/resources/mapper/NotificationRuleMapper.xml
index 26d55e8..5f0f1ff 100644
--- a/src/main/resources/mapper/NotificationRuleMapper.xml
+++ b/src/main/resources/mapper/NotificationRuleMapper.xml
@@ -2,4 +2,22 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.steadon.saber.mapper.NotificationRuleMapper">
 
+    <select id="selectDtoPage" resultType="com.steadon.saber.pojo.domain.dto.NotificationRuleDto">
+        select nr.id            as id,
+               nr.code          as code,
+               t.id             as templateId,
+               t.name           as templateName,
+               g.id             as groupId,
+               g.name           as groupName,
+               nr.feishu_status as feishuStatus,
+               nr.sms_status    as smsStatus,
+               nr.email_status  as emailStatus,
+               nr.create_by     as createBy,
+               nr.create_time   as createtime,
+               nr.update_by     as updateBy,
+               nr.update_time   as updateTime
+        from notification_rule nr
+                 left join saber.`group` g on g.id = nr.group_id
+                 left join saber.template t on t.id = nr.template_id
+    </select>
 </mapper>
-- 
GitLab