Pārlūkot izejas kodu

应用管理联调和体系管理开发

2643616413 6 dienas atpakaļ
vecāks
revīzija
6c0d19d08a
18 mainītis faili ar 594 papildinājumiem un 239 dzēšanām
  1. 18 13
      server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/controller/AitagAppController.java
  2. 95 0
      server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/controller/AitagTagCategoryController.java
  3. 1 1
      server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/domain/dto/AitagAppCreateDTO.java
  4. 19 0
      server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/domain/dto/AitagTagCategoryCreateDTO.java
  5. 23 0
      server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/domain/dto/AitagTagCategoryUpdateDTO.java
  6. 1 1
      server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/domain/entity/AitagApp.java
  7. 30 66
      server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/domain/entity/AitagTagCategory.java
  8. 23 113
      server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/domain/entity/AitagTagInfo.java
  9. 33 0
      server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/domain/vo/AitagTagCategoryVO.java
  10. 14 7
      server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/mapper/AitagAppMapper.java
  11. 41 0
      server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/mapper/AitagTagCategoryMapper.java
  12. 0 16
      server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/service/AiTagAppService.java
  13. 18 0
      server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/service/AitagAppService.java
  14. 19 0
      server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/service/AitagTagCategoryService.java
  15. 33 15
      server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/service/impl/AitagAppServiceImpl.java
  16. 136 0
      server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/service/impl/AitagTagCategoryServiceImpl.java
  17. 28 7
      server/yusp-tagging-core/src/main/resources/mapper/AitagAppMapper.xml
  18. 62 0
      server/yusp-tagging-core/src/main/resources/mapper/AitagTagCategoryMapper.xml

+ 18 - 13
server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/controller/AiTagAppController.java → server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/controller/AitagAppController.java

@@ -1,9 +1,9 @@
 package cn.com.yusys.yusp.controller;
 
 import cn.com.yusys.yusp.model.Result;
-import cn.com.yusys.yusp.domain.dto.AiTagAppCreateDTO;
-import cn.com.yusys.yusp.domain.entity.AiTagApp;
-import cn.com.yusys.yusp.service.AiTagAppService;
+import cn.com.yusys.yusp.domain.dto.AitagAppCreateDTO;
+import cn.com.yusys.yusp.domain.entity.AitagApp;
+import cn.com.yusys.yusp.service.AitagAppService;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
@@ -13,18 +13,18 @@ import java.util.List;
 
 @RestController
 @RequestMapping("/api/aitag-app")
-public class AiTagAppController {
+public class AitagAppController {
 
     @Autowired
-    private AiTagAppService aiTagAppService;
+    private AitagAppService aiTagAppService;
 
     @GetMapping("/list")
-    public Result<List<AiTagApp>> listApps(
+    public Result<List<AitagApp>> listApps(
             @RequestParam(defaultValue = "1") int page,
             @RequestParam(defaultValue = "10") int size) {
         try {
             // 分页查询
-            Page<AiTagApp> pageResult = aiTagAppService.listApps(page, size);
+            Page<AitagApp> pageResult = aiTagAppService.listApps(page, size);
 
             // 提取 records 并封装为 Result 对象
             return Result.pageSuccess(pageResult.getRecords(), pageResult.getTotal());
@@ -36,9 +36,9 @@ public class AiTagAppController {
 
 
     @PostMapping("/add")
-    public Result<AiTagApp> addApp(@Validated @RequestBody AiTagAppCreateDTO dto) {
+    public Result<AitagApp> addApp(@Validated @RequestBody AitagAppCreateDTO dto) {
         try {
-            AiTagApp app = aiTagAppService.addApp(dto);
+            AitagApp app = aiTagAppService.addApp(dto);
             return Result.success(app); // 成功时返回封装后的数据
         } catch (Exception e) {
             return Result.error("500", "应用新增失败:" + e.getMessage()); // 异常时返回错误信息
@@ -47,16 +47,21 @@ public class AiTagAppController {
 
 
     @GetMapping("/query")
-    public Result<List<AiTagApp>> queryByName(@RequestParam String appName) {
+    public Result<List<AitagApp>> queryByName(
+            @RequestParam String appName,
+            @RequestParam(defaultValue = "1") int page,
+            @RequestParam(defaultValue = "10") int pageSize) {
         try {
-            List<AiTagApp> apps = aiTagAppService.queryByAppNameLike(appName);
-            return Result.success(apps); // 成功时返回封装后的数据
+            Page<AitagApp> pageResult = aiTagAppService.queryByAppNameLikeWithPagination(appName, page, pageSize);
+            return Result.pageSuccess(pageResult.getRecords(), pageResult.getTotal()); // ✅ 返回 Result<List<AitagApp>>
         } catch (Exception e) {
-            return Result.error("500", "应用查询失败:" + e.getMessage()); // 异常时返回错误信息
+            return Result.error("500", "应用查询失败:" + e.getMessage());
         }
     }
 
 
+
+
     @PostMapping("/reset-secret")
     public Result<String> resetSecret(@RequestParam String id) {
         try {

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

@@ -0,0 +1,95 @@
+package cn.com.yusys.yusp.controller;
+
+import cn.com.yusys.yusp.domain.dto.AitagTagCategoryCreateDTO;
+import cn.com.yusys.yusp.domain.dto.AitagTagCategoryUpdateDTO;
+import cn.com.yusys.yusp.domain.entity.AitagTagCategory;
+import cn.com.yusys.yusp.domain.vo.AitagTagCategoryVO;
+import cn.com.yusys.yusp.model.Result;
+import cn.com.yusys.yusp.service.AitagTagCategoryService;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/api/aitag-tagcategory")
+public class AitagTagCategoryController {
+
+    @Autowired
+    private AitagTagCategoryService aiTagCategoryService;
+
+    @GetMapping("/list")
+    public Result<List<AitagTagCategoryVO>> listCategories(
+            @RequestParam(defaultValue = "1") int page,
+            @RequestParam(defaultValue = "5") int size) {
+        try {
+            Page<AitagTagCategoryVO> pageResult = aiTagCategoryService.listCategories(page, size);
+            return Result.pageSuccess(pageResult.getRecords(), pageResult.getTotal());
+        } catch (Exception e) {
+            return Result.error("500", "分页查询失败:" + e.getMessage());
+        }
+    }
+
+
+    @PostMapping("/create")
+    public Result<AitagTagCategory> createCategory(@Validated @RequestBody AitagTagCategoryCreateDTO dto) {
+        try {
+            AitagTagCategory category = aiTagCategoryService.createCategory(dto);
+            return Result.success(category);
+        } catch (Exception e) {
+            return Result.error("500", "新建标签体系失败:" + e.getMessage());
+        }
+    }
+
+    @PostMapping("/update")
+    public Result<AitagTagCategory> updateCategory(@Validated @RequestBody AitagTagCategoryUpdateDTO dto) {
+        try {
+            AitagTagCategory category = aiTagCategoryService.updateCategory(dto);
+            return Result.success(category);
+        } catch (Exception e) {
+            return Result.error("500", "编辑标签体系失败:" + e.getMessage());
+        }
+    }
+
+    @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());
+        }
+    }
+
+    @PostMapping("/enable")
+    public Result<Void> enableCategory(@RequestParam String id) {
+        try {
+            aiTagCategoryService.enableCategory(id);
+            return Result.success();
+        } catch (Exception e) {
+            return Result.error("500", "启用标签体系失败:" + e.getMessage());
+        }
+    }
+
+    @PostMapping("/disable")
+    public Result<Void> disableCategory(@RequestParam String id) {
+        try {
+            aiTagCategoryService.disableCategory(id);
+            return Result.success();
+        } catch (Exception e) {
+            return Result.error("500", "停用标签体系失败:" + e.getMessage());
+        }
+    }
+
+    @PostMapping("/delete")
+    public Result<Void> deleteCategory(@RequestParam String id) {
+        try {
+            aiTagCategoryService.deleteCategory(id);
+            return Result.success();
+        } catch (Exception e) {
+            return Result.error("500", "删除标签体系失败:" + e.getMessage());
+        }
+    }
+}

+ 1 - 1
server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/domain/dto/AiTagAppCreateDTO.java → server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/domain/dto/AitagAppCreateDTO.java

@@ -8,7 +8,7 @@ import javax.validation.constraints.NotBlank;
 
 @Data
 @ApiModel("新增应用请求DTO")
-public class AiTagAppCreateDTO {
+public class AitagAppCreateDTO {
 
     @NotBlank(message = "应用名称不能为空")
     @ApiModelProperty(value = "应用名称", required = true)

+ 19 - 0
server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/domain/dto/AitagTagCategoryCreateDTO.java

@@ -0,0 +1,19 @@
+package cn.com.yusys.yusp.domain.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+
+@Data
+@ApiModel("新建标签体系请求DTO")
+public class AitagTagCategoryCreateDTO {
+
+    @NotBlank(message = "标签体系名称不能为空")
+    @ApiModelProperty(value = "标签体系名称", required = true)
+    private String categoryNm;
+
+    @ApiModelProperty(value = "标签体系描述")
+    private String categoryDesc;
+}

+ 23 - 0
server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/domain/dto/AitagTagCategoryUpdateDTO.java

@@ -0,0 +1,23 @@
+package cn.com.yusys.yusp.domain.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+
+@Data
+@ApiModel("编辑标签体系请求DTO")
+public class AitagTagCategoryUpdateDTO {
+
+    @NotBlank(message = "ID不能为空")
+    @ApiModelProperty(value = "标签体系ID", required = true)
+    private String id;
+
+    @NotBlank(message = "标签体系名称不能为空")
+    @ApiModelProperty(value = "标签体系名称", required = true)
+    private String categoryNm;
+
+    @ApiModelProperty(value = "标签体系描述")
+    private String categoryDesc;
+}

+ 1 - 1
server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/domain/entity/AiTagApp.java → server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/domain/entity/AitagApp.java

@@ -13,7 +13,7 @@ import org.hibernate.validator.constraints.Length;
  * @TableName aitag_app
  */
 @Data
-public class AiTagApp implements Serializable {
+public class AitagApp implements Serializable {
 
     /**
      * 主键ID(UUID生成)

+ 30 - 66
server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/domain/entity/TabTagCategory.java → server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/domain/entity/AitagTagCategory.java

@@ -7,97 +7,61 @@ import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 
 import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
 import org.hibernate.validator.constraints.Length;
 
 /**
-* 
-* @TableName tab_tag_category
-*/
-public class TabTagCategory implements Serializable {
+ *
+ * @TableName aitag_tag_category
+ */
+@Data
+public class AitagTagCategory implements Serializable {
 
     /**
-    * 
-    */
+     *
+     */
     @NotBlank(message="[]不能为空")
     @Size(max= 100,message="编码长度不能超过100")
     @ApiModelProperty("")
     @Length(max= 100,message="编码长度不能超过100")
     private String id;
     /**
-    * 类别代码
-    */
+     * 类别代码
+     */
     @Size(max= 100,message="编码长度不能超过100")
     @ApiModelProperty("类别代码")
     @Length(max= 100,message="编码长度不能超过100")
     private String categoryCode;
     /**
-    * 类别名称
-    */
+     * 类别名称
+     */
     @Size(max= 100,message="编码长度不能超过100")
     @ApiModelProperty("类别名称")
     @Length(max= 100,message="编码长度不能超过100")
     private String categoryNm;
-    /**
-    * 0启用;1停用
-    */
-    @ApiModelProperty("0启用;1停用")
-    private Integer state;
-
-    /**
-    * 
-    */
-    private void setId(String id){
-    this.id = id;
-    }
-
-    /**
-    * 类别代码
-    */
-    private void setCategoryCode(String categoryCode){
-    this.categoryCode = categoryCode;
-    }
-
-    /**
-    * 类别名称
-    */
-    private void setCategoryNm(String categoryNm){
-    this.categoryNm = categoryNm;
-    }
-
-    /**
-    * 0启用;1停用
-    */
-    private void setState(Integer state){
-    this.state = state;
-    }
-
 
     /**
-    * 
-    */
-    private String getId(){
-    return this.id;
-    }
+     * 类别描述
+     */
+    @Size(max = 500, message = "编码长度不能超过500")
+    @ApiModelProperty("类别描述")
+    @Length(max = 500, message = "编码长度不能超过500")
+    private String categoryDesc;
 
     /**
-    * 类别代码
-    */
-    private String getCategoryCode(){
-    return this.categoryCode;
-    }
-
+     * 生效级别
+     */
+    @ApiModelProperty("生效级别")
+    private Integer visibilityLevel;
     /**
-    * 类别名称
-    */
-    private String getCategoryNm(){
-    return this.categoryNm;
-    }
-
+     * 状态:0启用;1停用
+     */
+    @ApiModelProperty("0启用;1停用")
+    private Integer state;
     /**
-    * 0启用;1停用
-    */
-    private Integer getState(){
-    return this.state;
-    }
+     * 删除标记:0未删除;1删除
+     */
+    @ApiModelProperty("0未删除;1删除")
+    private Integer isDelete;
 
 }

+ 23 - 113
server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/domain/entity/TabTagInfo.java → server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/domain/entity/AitagTagInfo.java

@@ -7,13 +7,15 @@ import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 
 import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
 import org.hibernate.validator.constraints.Length;
 
 /**
 * 
-* @TableName tab_tag_info
+* @TableName aitag_tag_info
 */
-public class TabTagInfo implements Serializable {
+@Data
+public class AitagTagInfo implements Serializable {
 
     /**
     * 
@@ -57,7 +59,7 @@ public class TabTagInfo implements Serializable {
     @Size(max= 100,message="编码长度不能超过100")
     @ApiModelProperty("父级ID")
     @Length(max= 100,message="编码长度不能超过100")
-    private String parentId;
+    private String parentCode;
     /**
     * 标签规则
     */
@@ -66,124 +68,32 @@ public class TabTagInfo implements Serializable {
     @Length(max= 100,message="编码长度不能超过100")
     private String reg;
     /**
-    * 标签提示词
-    */
-    @Size(max= 100,message="编码长度不能超过100")
-    @ApiModelProperty("标签提示词")
-    @Length(max= 100,message="编码长度不能超过100")
-    private String prompt;
-
-    /**
-    * 
-    */
-    private void setId(String id){
-    this.id = id;
-    }
-
-    /**
-    * 所属大类
-    */
-    private void setCategoryId(String categoryId){
-    this.categoryId = categoryId;
-    }
-
-    /**
-    * 标签名称
-    */
-    private void setTagNm(String tagNm){
-    this.tagNm = tagNm;
-    }
-
-    /**
-    * 标签代码
-    */
-    private void setTagCode(String tagCode){
-    this.tagCode = tagCode;
-    }
-
-    /**
-    * 标签备注
-    */
-    private void setTagRemark(String tagRemark){
-    this.tagRemark = tagRemark;
-    }
-
-    /**
-    * 父级ID
-    */
-    private void setParentId(String parentId){
-    this.parentId = parentId;
-    }
-
-    /**
-    * 标签规则
+    * 标签等级
     */
-    private void setReg(String reg){
-    this.reg = reg;
-    }
-
-    /**
-    * 标签提示词
-    */
-    private void setPrompt(String prompt){
-    this.prompt = prompt;
-    }
-
-
-    /**
-    * 
-    */
-    private String getId(){
-    return this.id;
-    }
-
-    /**
-    * 所属大类
-    */
-    private String getCategoryId(){
-    return this.categoryId;
-    }
-
-    /**
-    * 标签名称
-    */
-    private String getTagNm(){
-    return this.tagNm;
-    }
-
-    /**
-    * 标签代码
-    */
-    private String getTagCode(){
-    return this.tagCode;
-    }
-
+    @ApiModelProperty("标签等级")
+    private Integer level;
     /**
-    * 标签备注
+    * tag1/tag2/tag3/...
     */
-    private String getTagRemark(){
-    return this.tagRemark;
-    }
-
+    @Size(max= 100,message="编码长度不能超过100")
+    @ApiModelProperty("tag1/tag2/tag3/...")
+    @Length(max= 100,message="编码长度不能超过100")
+    private String tagPath;
     /**
-    * 父级ID
+    * 0未删除;1删除
     */
-    private String getParentId(){
-    return this.parentId;
-    }
-
+    @ApiModelProperty("0未删除;1删除")
+    private Integer isDelete;
     /**
-    * 标签规则
+    * 0 正常;1 停用
     */
-    private String getReg(){
-    return this.reg;
-    }
-
+    @ApiModelProperty("0 正常;1 停用")
+    private Integer state;
     /**
     * 标签提示词
     */
-    private String getPrompt(){
-    return this.prompt;
-    }
-
+    @Size(max= 1000,message="编码长度不能超过1000")
+    @ApiModelProperty("标签提示词")
+    @Length(max= 1000,message="编码长度不能超过1,000")
+    private String tagPrompt;
 }

+ 33 - 0
server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/domain/vo/AitagTagCategoryVO.java

@@ -0,0 +1,33 @@
+package cn.com.yusys.yusp.domain.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+@ApiModel("标签体系视图对象")
+public class AitagTagCategoryVO {
+    @ApiModelProperty("标签体系ID")
+    private String id;
+
+    @ApiModelProperty("类别代码")
+    private String categoryCode;
+
+    @ApiModelProperty("类别名称")
+    private String categoryNm;
+
+    @ApiModelProperty("类别描述")
+    private String categoryDesc;
+
+    @ApiModelProperty("生效级别")
+    private Integer visibilityLevel;
+
+    @ApiModelProperty("状态:0启用;1停用")
+    private Integer state;
+
+    @ApiModelProperty("删除标记:0未删除;1删除")
+    private Integer isDelete;
+
+    @ApiModelProperty("标签数量(临时字段)")
+    private Integer tagNum;
+}

+ 14 - 7
server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/mapper/AiTagAppMapper.java → server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/mapper/AitagAppMapper.java

@@ -1,30 +1,30 @@
 package cn.com.yusys.yusp.mapper;
 
-import cn.com.yusys.yusp.domain.entity.AiTagApp;
+import cn.com.yusys.yusp.domain.entity.AitagApp;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
 @Mapper
-public interface AiTagAppMapper {
+public interface AitagAppMapper {
 
     // 分页查询(偏移量 + 限制)
-    List<AiTagApp> selectPageApps(@Param("offset") int offset, @Param("limit") int limit);
+    List<AitagApp> selectPageApps(@Param("offset") int offset, @Param("limit") int limit);
 
-    List<AiTagApp> selectByAppNameLike(@Param("appName") String appName);
+    List<AitagApp> selectByAppNameLike(@Param("appName") String appName);
 
     // 按应用名称查重
     int selectCountByName(@Param("appName") String appName);
 
     // 新增
-    void insertApp(AiTagApp app);
+    void insertApp(AitagApp app);
 
     // 按 ID 查询
-    AiTagApp selectById(@Param("id") String id);
+    AitagApp selectById(@Param("id") String id);
 
     // 按应用名称查询(仅三字段)
-    List<AiTagApp> selectByName(@Param("appName") String appName);
+    List<AitagApp> selectByName(@Param("appName") String appName);
 
     // 重置密钥
     void updateAppSecret(@Param("id") String id, @Param("appSecret") String appSecret);
@@ -34,4 +34,11 @@ public interface AiTagAppMapper {
 
     // 全表计数(分页总数)
     long selectCountAll();
+
+    // 分页模糊查询
+    List<AitagApp> selectByAppNameLikeWithPagination(@Param("appName") String appName, @Param("offset") int offset, @Param("limit") int limit);
+
+    // 模糊查询总数
+    long selectCountByAppNameLike(@Param("appName") String appName);
+
 }

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

@@ -0,0 +1,41 @@
+package cn.com.yusys.yusp.mapper;
+
+import cn.com.yusys.yusp.domain.entity.AitagTagCategory;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+@Mapper
+public interface AitagTagCategoryMapper {
+
+    // 分页查询(偏移量 + 限制)
+    List<AitagTagCategory> selectPageCategories(@Param("offset") int offset, @Param("limit") int limit);
+
+    // 模糊查询(按名称)
+    List<AitagTagCategory> selectByCategoryNmLike(@Param("categoryNm") String categoryNm);
+
+    // 按名称查重(未删除)
+    int selectCountByNameAndNotDeleted(@Param("categoryNm") String categoryNm);
+
+    // 新增
+    void insertCategory(AitagTagCategory category);
+
+    // 按 ID 查询
+    AitagTagCategory selectById(@Param("id") String id);
+
+    // 更新
+    void updateCategory(AitagTagCategory category);
+
+    // 启用/停用
+    void updateState(@Param("id") String id, @Param("state") Integer state);
+
+    // 删除(逻辑删除)
+    void deleteCategory(@Param("id") String id);
+
+    // 计算标签数量(关联 aitag_tag_info 表)
+    int countTagsByCategoryId(@Param("categoryId") String categoryId);
+
+    // 全表计数(分页总数)
+    long selectCountAll();
+}

+ 0 - 16
server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/service/AiTagAppService.java

@@ -1,16 +0,0 @@
-package cn.com.yusys.yusp.service;
-
-import cn.com.yusys.yusp.domain.entity.AiTagApp;
-import cn.com.yusys.yusp.domain.dto.AiTagAppCreateDTO;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-
-import java.util.List;
-
-public interface AiTagAppService {
-    Page<AiTagApp> listApps(int page, int size);
-    AiTagApp addApp(AiTagAppCreateDTO dto);
-    List<AiTagApp> queryByName(String appName);
-    List<AiTagApp> queryByAppNameLike(String appName);
-    String resetSecret(String id);
-    void disableApp(String id);
-}

+ 18 - 0
server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/service/AitagAppService.java

@@ -0,0 +1,18 @@
+package cn.com.yusys.yusp.service;
+
+import cn.com.yusys.yusp.domain.entity.AitagApp;
+import cn.com.yusys.yusp.domain.dto.AitagAppCreateDTO;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+
+import java.util.List;
+
+public interface AitagAppService {
+    Page<AitagApp> listApps(int page, int size);
+    Page<AitagApp> queryByAppNameLikeWithPagination(String appName, int page, int pageSize);
+
+    AitagApp addApp(AitagAppCreateDTO dto);
+    List<AitagApp> queryByName(String appName);
+    List<AitagApp> queryByAppNameLike(String appName);
+    String resetSecret(String id);
+    void disableApp(String id);
+}

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

@@ -0,0 +1,19 @@
+package cn.com.yusys.yusp.service;
+
+import cn.com.yusys.yusp.domain.dto.AitagTagCategoryCreateDTO;
+import cn.com.yusys.yusp.domain.dto.AitagTagCategoryUpdateDTO;
+import cn.com.yusys.yusp.domain.entity.AitagTagCategory;
+import cn.com.yusys.yusp.domain.vo.AitagTagCategoryVO;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+
+import java.util.List;
+
+public interface AitagTagCategoryService {
+    Page<AitagTagCategoryVO> listCategories(int page, int size); // ← 改为 VO
+    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);
+}

+ 33 - 15
server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/service/impl/AiTagAppServiceImpl.java → server/yusp-tagging-core/src/main/java/cn/com/yusys/yusp/service/impl/AitagAppServiceImpl.java

@@ -1,9 +1,9 @@
 package cn.com.yusys.yusp.service.impl;
 
-import cn.com.yusys.yusp.domain.dto.AiTagAppCreateDTO;
-import cn.com.yusys.yusp.domain.entity.AiTagApp;
-import cn.com.yusys.yusp.mapper.AiTagAppMapper;
-import cn.com.yusys.yusp.service.AiTagAppService;
+import cn.com.yusys.yusp.domain.dto.AitagAppCreateDTO;
+import cn.com.yusys.yusp.domain.entity.AitagApp;
+import cn.com.yusys.yusp.mapper.AitagAppMapper;
+import cn.com.yusys.yusp.service.AitagAppService;
 import cn.com.yusys.yusp.util.DataUtil;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -15,23 +15,23 @@ import java.util.List;
 import java.util.Random;
 
 @Service
-public class AiTagAppServiceImpl implements AiTagAppService {
+public class AitagAppServiceImpl implements AitagAppService {
 
     @Autowired
-    private AiTagAppMapper aiTagAppMapper;
+    private AitagAppMapper aiTagAppMapper;
 
     @Override
-    public Page<AiTagApp> listApps(int page, int size) {
+    public Page<AitagApp> listApps(int page, int size) {
         int offset = (page - 1) * size;
-        List<AiTagApp> records = aiTagAppMapper.selectPageApps(offset, size);
+        List<AitagApp> records = aiTagAppMapper.selectPageApps(offset, size);
         long total = aiTagAppMapper.selectCountAll();
-        Page<AiTagApp> pageObj = new Page<>(page, size, total);
+        Page<AitagApp> pageObj = new Page<>(page, size, total);
         pageObj.setRecords(records);
         return pageObj;
     }
 
     @Override
-    public AiTagApp addApp(AiTagAppCreateDTO dto) {
+    public AitagApp addApp(AitagAppCreateDTO dto) {
         String appName = dto.getAppName();
 
         // 校验唯一性
@@ -46,7 +46,7 @@ public class AiTagAppServiceImpl implements AiTagAppService {
                 String.format("%06d", new Random().nextInt(1000000));
         String appSecret = generateRandomString(25);
 
-        AiTagApp app = new AiTagApp();
+        AitagApp app = new AitagApp();
         app.setId(id);
         app.setAppName(appName);
         app.setAppId(appId);
@@ -60,18 +60,36 @@ public class AiTagAppServiceImpl implements AiTagAppService {
     }
 
     @Override
-    public List<AiTagApp> queryByName(String appName) {
+    public List<AitagApp> queryByName(String appName) {
         return aiTagAppMapper.selectByName(appName);
     }
 
     @Override
-    public List<AiTagApp> queryByAppNameLike(String appName) {
+    public List<AitagApp> queryByAppNameLike(String appName) {
         return aiTagAppMapper.selectByAppNameLike(appName); // 调用 Mapper 层的模糊查询方法
     }
 
     @Override
+    public Page<AitagApp> queryByAppNameLikeWithPagination(String appName, int page, int pageSize) {
+        int offset = (page - 1) * pageSize;
+
+        // 查询符合条件的应用列表
+        List<AitagApp> records = aiTagAppMapper.selectByAppNameLikeWithPagination(appName, offset, pageSize);
+
+        // 查询符合条件的总记录数
+        long total = aiTagAppMapper.selectCountByAppNameLike(appName);
+
+        // 构造分页对象
+        Page<AitagApp> pageObj = new Page<>(page, pageSize, total);
+        pageObj.setRecords(records);
+
+        return pageObj;
+    }
+
+
+    @Override
     public String resetSecret(String id) {
-        AiTagApp app = aiTagAppMapper.selectById(id);
+        AitagApp app = aiTagAppMapper.selectById(id);
         if (app == null) {
             throw new RuntimeException("应用不存在");
         }
@@ -83,7 +101,7 @@ public class AiTagAppServiceImpl implements AiTagAppService {
 
     @Override
     public void disableApp(String id) {
-        AiTagApp app = aiTagAppMapper.selectById(id);
+        AitagApp app = aiTagAppMapper.selectById(id);
         if (app == null) {
             throw new RuntimeException("应用不存在");
         }

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

@@ -0,0 +1,136 @@
+package cn.com.yusys.yusp.service.impl;
+
+import cn.com.yusys.yusp.domain.dto.AitagTagCategoryCreateDTO;
+import cn.com.yusys.yusp.domain.dto.AitagTagCategoryUpdateDTO;
+import cn.com.yusys.yusp.domain.entity.AitagTagCategory;
+import cn.com.yusys.yusp.domain.vo.AitagTagCategoryVO;
+import cn.com.yusys.yusp.mapper.AitagTagCategoryMapper;
+import cn.com.yusys.yusp.service.AitagTagCategoryService;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.UUID;
+import java.util.stream.Collectors;
+
+@Service
+public class AitagTagCategoryServiceImpl implements AitagTagCategoryService {
+
+    @Autowired
+    private AitagTagCategoryMapper aiTagCategoryMapper;
+
+    @Override
+    public Page<AitagTagCategoryVO> listCategories(int page, int size) {
+        int offset = (page - 1) * size;
+        List<AitagTagCategory> records = aiTagCategoryMapper.selectPageCategories(offset, size);
+        long total = aiTagCategoryMapper.selectCountAll();
+
+        // 转换为 VO 并动态计算 tagNum
+        List<AitagTagCategoryVO> voList = records.stream().map(category -> {
+            AitagTagCategoryVO vo = new AitagTagCategoryVO();
+            vo.setId(category.getId());
+            vo.setCategoryCode(category.getCategoryCode());
+            vo.setCategoryNm(category.getCategoryNm());
+            vo.setCategoryDesc(category.getCategoryDesc());
+            vo.setVisibilityLevel(category.getVisibilityLevel());
+            vo.setState(category.getState());
+            vo.setIsDelete(category.getIsDelete());
+
+            // 动态计算 tagNum
+            int tagNum = aiTagCategoryMapper.countTagsByCategoryId(category.getId());
+            vo.setTagNum(tagNum);
+
+            return vo;
+        }).collect(Collectors.toList());
+
+        Page<AitagTagCategoryVO> pageObj = new Page<>(page, size, total);
+        pageObj.setRecords(voList);
+        return pageObj;
+    }
+
+
+    @Override
+    public AitagTagCategory createCategory(AitagTagCategoryCreateDTO dto) {
+        // 校验唯一性
+        if (aiTagCategoryMapper.selectCountByNameAndNotDeleted(dto.getCategoryNm()) > 0) {
+            throw new RuntimeException("标签体系名称已存在");
+        }
+
+        AitagTagCategory category = new AitagTagCategory();
+        category.setId(UUID.randomUUID().toString());
+        category.setCategoryNm(dto.getCategoryNm());
+        category.setCategoryDesc(dto.getCategoryDesc());
+        category.setState(0); // 默认启用
+        category.setIsDelete(0); // 未删除
+
+        aiTagCategoryMapper.insertCategory(category);
+        return category;
+    }
+
+    @Override
+    public AitagTagCategory updateCategory(AitagTagCategoryUpdateDTO dto) {
+        AitagTagCategory existing = aiTagCategoryMapper.selectById(dto.getId());
+        if (existing == null) {
+            throw new RuntimeException("标签体系不存在");
+        }
+
+        // 校验唯一性(排除自己)
+        if (!existing.getCategoryNm().equals(dto.getCategoryNm())) {
+            if (aiTagCategoryMapper.selectCountByNameAndNotDeleted(dto.getCategoryNm()) > 0) {
+                throw new RuntimeException("标签体系名称已存在");
+            }
+        }
+
+        existing.setCategoryNm(dto.getCategoryNm());
+        existing.setCategoryDesc(dto.getCategoryDesc());
+
+        aiTagCategoryMapper.updateCategory(existing);
+        return existing;
+    }
+
+    @Override
+    public List<AitagTagCategory> searchByCategoryNm(String categoryNm) {
+        return aiTagCategoryMapper.selectByCategoryNmLike(categoryNm);
+    }
+
+    @Override
+    public void enableCategory(String id) {
+        AitagTagCategory category = aiTagCategoryMapper.selectById(id);
+        if (category == null) {
+            throw new RuntimeException("标签体系不存在");
+        }
+        if (category.getState() == 0) {
+            throw new RuntimeException("标签体系已经是启用状态");
+        }
+        aiTagCategoryMapper.updateState(id, 0);
+    }
+
+    @Override
+    public void disableCategory(String id) {
+        AitagTagCategory category = aiTagCategoryMapper.selectById(id);
+        if (category == null) {
+            throw new RuntimeException("标签体系不存在");
+        }
+        if (category.getState() == 1) {
+            throw new RuntimeException("标签体系已经是停用状态");
+        }
+        aiTagCategoryMapper.updateState(id, 1);
+    }
+
+    @Override
+    public void deleteCategory(String id) {
+        AitagTagCategory category = aiTagCategoryMapper.selectById(id);
+        if (category == null) {
+            throw new RuntimeException("标签体系不存在");
+        }
+
+        // 判断标签数量是否为0
+        int tagCount = aiTagCategoryMapper.countTagsByCategoryId(id);
+        if (tagCount > 0) {
+            throw new RuntimeException("该标签体系下仍有标签,无法删除");
+        }
+
+        aiTagCategoryMapper.deleteCategory(id);
+    }
+}

+ 28 - 7
server/yusp-tagging-core/src/main/resources/mapper/AiTagAppMapper.xml → server/yusp-tagging-core/src/main/resources/mapper/AitagAppMapper.xml

@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 
-<mapper namespace="cn.com.yusys.yusp.mapper.AiTagAppMapper">
+<mapper namespace="cn.com.yusys.yusp.mapper.AitagAppMapper">
 
     <!-- 1. 分页查询 -->
-    <select id="selectPageApps" parameterType="map" resultType="cn.com.yusys.yusp.domain.entity.AiTagApp">
+    <select id="selectPageApps" parameterType="map" resultType="cn.com.yusys.yusp.domain.entity.AitagApp">
         SELECT
             id,
             app_name,
@@ -27,7 +27,7 @@
     </select>
 
     <!-- 3. 新增应用(插入全部字段) -->
-    <insert id="insertApp" parameterType="cn.com.yusys.yusp.domain.entity.AiTagApp">
+    <insert id="insertApp" parameterType="cn.com.yusys.yusp.domain.entity.AitagApp">
         INSERT INTO aitag_app (
             id,
             app_name,
@@ -50,14 +50,14 @@
     </insert>
 
     <!-- 4. 根据 ID 查询完整对象(用于 reset/disable) -->
-    <select id="selectById" parameterType="string" resultType="cn.com.yusys.yusp.domain.entity.AiTagApp">
+    <select id="selectById" parameterType="string" resultType="cn.com.yusys.yusp.domain.entity.AitagApp">
         SELECT *
         FROM aitag_app
         WHERE id = #{id}
     </select>
 
     <!-- 5. 按应用名称查询(返回 app_name, app_id, app_secret) -->
-    <select id="selectByName" parameterType="string" resultType="cn.com.yusys.yusp.domain.entity.AiTagApp">
+    <select id="selectByName" parameterType="string" resultType="cn.com.yusys.yusp.domain.entity.AitagApp">
         SELECT app_name, app_id, app_secret
         FROM aitag_app
         WHERE app_name = #{appName}
@@ -83,7 +83,7 @@
         FROM aitag_app
     </select>
 <!--    9.模糊查询-->
-    <select id="selectByAppNameLike" parameterType="string" resultType="cn.com.yusys.yusp.domain.entity.AiTagApp">
+    <select id="selectByAppNameLike" parameterType="string" resultType="cn.com.yusys.yusp.domain.entity.AitagApp">
         SELECT
             id,
             app_name,
@@ -96,5 +96,26 @@
         FROM aitag_app
         WHERE app_name LIKE CONCAT('%', #{appName}, '%')
     </select>
-
+    <!--    10.模糊查询计数-->
+    <select id="selectByAppNameLikeWithPagination" parameterType="map" resultType="cn.com.yusys.yusp.domain.entity.AitagApp">
+        SELECT
+            id,
+            app_name,
+            app_id,
+            app_secret,
+            create_time,
+            creater_nm,
+            creater_id,
+            state
+        FROM aitag_app
+        WHERE app_name LIKE CONCAT('%', #{appName}, '%')
+        ORDER BY create_time DESC
+            LIMIT #{limit} OFFSET #{offset}
+    </select>
+    <!--    11.模糊查询总数-->
+    <select id="selectCountByAppNameLike" parameterType="string" resultType="java.lang.Long">
+        SELECT COUNT(*)
+        FROM aitag_app
+        WHERE app_name LIKE CONCAT('%', #{appName}, '%')
+    </select>
 </mapper>

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

@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.yusys.yusp.mapper.AitagTagCategoryMapper">
+
+    <!-- 分页查询 -->
+    <select id="selectPageCategories" resultType="cn.com.yusys.yusp.domain.entity.AitagTagCategory">
+        SELECT * FROM aitag_tag_category
+        WHERE is_delete = 0
+            LIMIT #{offset}, #{limit}
+    </select>
+
+    <!-- 模糊查询 -->
+    <select id="selectByCategoryNmLike" resultType="cn.com.yusys.yusp.domain.entity.AitagTagCategory">
+        SELECT * FROM aitag_tag_category
+        WHERE is_delete = 0 AND category_nm LIKE CONCAT('%', #{categoryNm}, '%')
+            LIMIT 5
+    </select>
+
+    <!-- 按名称查重(未删除) -->
+    <select id="selectCountByNameAndNotDeleted" resultType="int">
+        SELECT COUNT(*) FROM aitag_tag_category
+        WHERE is_delete = 0 AND category_nm = #{categoryNm}
+    </select>
+
+    <!-- 新增 -->
+    <insert id="insertCategory">
+        INSERT INTO aitag_tag_category (id, category_nm, category_desc, state, is_delete)
+        VALUES (#{id}, #{categoryNm}, #{categoryDesc}, 0, 0)
+    </insert>
+
+    <!-- 按 ID 查询 -->
+    <select id="selectById" resultType="cn.com.yusys.yusp.domain.entity.AitagTagCategory">
+        SELECT * FROM aitag_tag_category WHERE id = #{id}
+    </select>
+
+    <!-- 更新 -->
+    <update id="updateCategory">
+        UPDATE aitag_tag_category
+        SET category_nm = #{categoryNm}, category_desc = #{categoryDesc}
+        WHERE id = #{id}
+    </update>
+
+    <!-- 启用/停用 -->
+    <update id="updateState">
+        UPDATE aitag_tag_category SET state = #{state} WHERE id = #{id}
+    </update>
+
+    <!-- 删除(逻辑删除) -->
+    <update id="deleteCategory">
+        UPDATE aitag_tag_category SET is_delete = 1 WHERE id = #{id}
+    </update>
+
+    <!-- 计算标签数量 -->
+    <select id="countTagsByCategoryId" resultType="int">
+        SELECT COUNT(*) FROM aitag_tag_info WHERE category_id = #{categoryId} AND is_delete = 0
+    </select>
+
+    <!-- 全表计数 -->
+    <select id="selectCountAll" resultType="long">
+        SELECT COUNT(*) FROM aitag_tag_category WHERE is_delete = 0
+    </select>
+</mapper>