2643616413 пре 14 часа
родитељ
комит
5f6f30131e

+ 2 - 12
server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/controller/AitagTagCategoryController.java

@@ -24,10 +24,11 @@ public class AitagTagCategoryController {
     @ApiOperationType("标签体系列表")
     @GetMapping("/list")
     public Result<List<AitagTagCategoryVo>> listCategories(
+            @RequestParam(required = false) String categoryNm,
             @RequestParam(defaultValue = "1") int page,
             @RequestParam(defaultValue = "5") int size) {
         try {
-            Page<AitagTagCategoryVo> pageResult = aiTagCategoryService.listCategories(page, size);
+            Page<AitagTagCategoryVo> pageResult = aiTagCategoryService.listCategories(categoryNm, page, size);
             return Result.pageSuccess(pageResult.getRecords(), pageResult.getTotal());
         } catch (Exception e) {
             return Result.error("500", "分页查询失败:" + e.getMessage());
@@ -56,17 +57,6 @@ public class AitagTagCategoryController {
         }
     }
 
-    @ApiOperationType("查询标签体系")
-    @GetMapping("/query")
-    public Result<List<AitagTagCategory>> searchByCategoryNm(@RequestParam String categoryNm) {
-        try {
-            List<AitagTagCategory> categories = aiTagCategoryService.searchByCategoryNm(categoryNm);
-            return Result.success(categories);
-        } catch (Exception e) {
-            return Result.error("500", "模糊查询失败:" + e.getMessage());
-        }
-    }
-
     @ApiOperationType("启用标签体系")
     @PostMapping("/enable")
     public Result<Void> enableCategory(@RequestParam String id) {

+ 9 - 0
server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/mapper/AitagTagCategoryMapper.java

@@ -12,6 +12,15 @@ public interface AitagTagCategoryMapper {
     // 分页查询(偏移量 + 限制)
     List<AitagTagCategory> selectPageCategories(@Param("offset") int offset, @Param("limit") int limit);
 
+    // 带模糊筛选的分页查询
+    List<AitagTagCategory> selectPageCategoriesWithFilter(
+            @Param("categoryNm") String categoryNm,
+            @Param("offset") int offset,
+            @Param("limit") int limit);
+
+    // 带模糊筛选的总数
+    long selectCountWithFilter(@Param("categoryNm") String categoryNm);
+
     // 模糊查询(按名称)
     List<AitagTagCategory> selectByCategoryNmLike(@Param("categoryNm") String categoryNm);
 

+ 1 - 2
server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/service/AitagTagCategoryService.java

@@ -9,10 +9,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import java.util.List;
 
 public interface AitagTagCategoryService {
-    Page<AitagTagCategoryVo> listCategories(int page, int size); // ← 改为 VO
+    Page<AitagTagCategoryVo> listCategories(String categoryNm, int page, int size);
     AitagTagCategory createCategory(AitagTagCategoryCreateDto dto);
     AitagTagCategory updateCategory(AitagTagCategoryUpdateDto dto);
-    List<AitagTagCategory> searchByCategoryNm(String categoryNm);
     void enableCategory(String id);
     void disableCategory(String id);
     void deleteCategory(String id);

+ 4 - 7
server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/service/impl/AitagTagCategoryServiceImpl.java

@@ -21,10 +21,10 @@ public class AitagTagCategoryServiceImpl implements AitagTagCategoryService {
     private AitagTagCategoryMapper aiTagCategoryMapper;
 
     @Override
-    public Page<AitagTagCategoryVo> listCategories(int page, int size) {
+    public Page<AitagTagCategoryVo> listCategories(String categoryNm, int page, int size) {
         int offset = (page - 1) * size;
-        List<AitagTagCategory> records = aiTagCategoryMapper.selectPageCategories(offset, size);
-        long total = aiTagCategoryMapper.selectCountAll();
+        List<AitagTagCategory> records = aiTagCategoryMapper.selectPageCategoriesWithFilter(categoryNm, offset, size);
+        long total = aiTagCategoryMapper.selectCountWithFilter(categoryNm);
 
         // 转换为 VO 并动态计算 tagNum
         List<AitagTagCategoryVo> voList = records.stream().map(category -> {
@@ -89,10 +89,7 @@ public class AitagTagCategoryServiceImpl implements AitagTagCategoryService {
         return existing;
     }
 
-    @Override
-    public List<AitagTagCategory> searchByCategoryNm(String categoryNm) {
-        return aiTagCategoryMapper.selectByCategoryNmLike(categoryNm);
-    }
+
 
     @Override
     public void enableCategory(String id) {

+ 19 - 0
server/yusp-tagging-core/src/main/resources/mapper/AitagTagCategoryMapper.xml

@@ -9,6 +9,25 @@
             LIMIT #{offset}, #{limit}
     </select>
 
+    <!-- 带模糊筛选的分页查询 -->
+    <select id="selectPageCategoriesWithFilter" resultType="cn.com.yusys.yusp.domain.entity.AitagTagCategory">
+        SELECT * FROM aitag_tag_category
+        WHERE is_delete = 0
+        <if test="categoryNm != null and categoryNm != ''">
+            AND category_nm LIKE CONCAT('%', #{categoryNm}, '%')
+        </if>
+        LIMIT #{offset}, #{limit}
+    </select>
+
+    <!-- 带模糊筛选的总数 -->
+    <select id="selectCountWithFilter" resultType="long">
+        SELECT COUNT(*) FROM aitag_tag_category
+        WHERE is_delete = 0
+        <if test="categoryNm != null and categoryNm != ''">
+            AND category_nm LIKE CONCAT('%', #{categoryNm}, '%')
+        </if>
+    </select>
+
     <!-- 模糊查询 -->
     <select id="selectByCategoryNmLike" resultType="cn.com.yusys.yusp.domain.entity.AitagTagCategory">
         SELECT * FROM aitag_tag_category