From 53dea0ef5fc8b035397b73b10f7a819ebf381b1c Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期二, 09 七月 2024 09:39:11 +0800
Subject: [PATCH] 分页优化

---
 src/main/java/com/mindskip/xzs/domain/vo/TagVO.java                |    2 ++
 src/main/java/com/mindskip/xzs/controller/admin/TagController.java |    4 ++++
 src/main/resources/mapper/TagMapper.xml                            |   14 +++++++++++++-
 3 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/src/main/java/com/mindskip/xzs/controller/admin/TagController.java b/src/main/java/com/mindskip/xzs/controller/admin/TagController.java
index f241fa3..b739e97 100644
--- a/src/main/java/com/mindskip/xzs/controller/admin/TagController.java
+++ b/src/main/java/com/mindskip/xzs/controller/admin/TagController.java
@@ -9,6 +9,7 @@
 import com.mindskip.xzs.service.TagService;
 import lombok.Data;
 import org.apache.commons.lang3.ObjectUtils;
+import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
@@ -35,6 +36,9 @@
 
     @RequestMapping(value = "/page/list", method = RequestMethod.POST)
     public RestResponse<PageInfo<Tag>> pageList(@RequestBody TagVO tag) {
+        if (! CollectionUtils.isEmpty(webContext.getAdminDeptIds())) {
+            tag.setDeptId(webContext.getAdminDeptIds().get(0));
+        }
         PageInfo<Tag> page = tagService.tagPage(tag);
         return RestResponse.ok(page);
     }
diff --git a/src/main/java/com/mindskip/xzs/domain/vo/TagVO.java b/src/main/java/com/mindskip/xzs/domain/vo/TagVO.java
index e47e579..87c0f8d 100644
--- a/src/main/java/com/mindskip/xzs/domain/vo/TagVO.java
+++ b/src/main/java/com/mindskip/xzs/domain/vo/TagVO.java
@@ -16,6 +16,8 @@
 
     private String name;
 
+    private Integer deptId;
+
     private String deptName;
 
     private Boolean deleted;
diff --git a/src/main/resources/mapper/TagMapper.xml b/src/main/resources/mapper/TagMapper.xml
index b164ec9..693b3bb 100644
--- a/src/main/resources/mapper/TagMapper.xml
+++ b/src/main/resources/mapper/TagMapper.xml
@@ -37,13 +37,25 @@
                tt.id, tt.name, td.name as deptName
         FROM
              t_tag tt
-                 INNER JOIN t_department td ON tt.dept_id = td.id
+                 INNER JOIN t_department td ON tt.dept_id = td.id <if test="tag.deptId != null">AND tt.dept_id = #{tag.deptId}</if>
         <where>
             AND tt.deleted = 0
             <if test="tag.name != null and tag.name != ''">
                 AND tt.name like concat('%', #{tag.name}, '%')
             </if>
         </where>
+        UNION ALL
+        SELECT
+            tt.id, tt.name, '鎵�鏈夐儴闂�' as deptName
+        FROM
+            t_tag tt
+        <where>
+            tt.dept_id is null
+            AND tt.deleted = 0
+            <if test="tag.name != null and tag.name != ''">
+                AND tt.name like concat('%', #{tag.name}, '%')
+            </if>
+        </where>
     </select>
 
 </mapper>

--
Gitblit v1.8.0