tsurumure před 1 měsícem
rodič
revize
54f5aabaa7

+ 18 - 1
src/main/java/com/backendsys/modules/ai/material/controller/MaterialCategoryController.java

@@ -1,9 +1,14 @@
 package com.backendsys.modules.ai.material.controller;
 
+import com.backendsys.modules.ai.material.entity.MaterialCategory;
 import com.backendsys.modules.ai.material.service.MaterialCategoryService;
+import com.backendsys.modules.common.utils.Result;
+import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 @Validated
@@ -14,6 +19,18 @@ public class MaterialCategoryController {
     @Autowired
     private MaterialCategoryService materialCategoryService;
 
-    
+    @Operation(summary = "获取素材分类列表")
+//    @PreAuthorize("@sr.hasPermission('31')")
+    @GetMapping("/api/ai/material/getMaterialCategoryList")
+    public Result getMaterialCategoryList(MaterialCategory materialCategory) {
+        return Result.success().put("data", materialCategoryService.selectMaterialCategoryList(materialCategory));
+    }
+
+    @Operation(summary = "获取素材分类列表(下拉)")
+//    @PreAuthorize("@sr.hasPermission('31')")
+    @GetMapping("/api/ai/material/getMaterialCategoryPopover")
+    public Result getMaterialCategoryPopover() {
+        return Result.success().put("data", materialCategoryService.selectMaterialCategoryPopover());
+    }
 
 }

+ 6 - 0
src/main/java/com/backendsys/modules/ai/material/dao/MaterialCategoryDao.java

@@ -4,6 +4,12 @@ import com.backendsys.modules.ai.material.entity.MaterialCategory;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Mapper;
 
+import java.util.List;
+
 @Mapper
 public interface MaterialCategoryDao extends BaseMapper<MaterialCategory> {
+
+    // 获取素材分类列表
+    List<MaterialCategory> selectMaterialCategoryList(MaterialCategory materialCategory);
+
 }

+ 1 - 1
src/main/java/com/backendsys/modules/ai/material/entity/Material.java

@@ -27,7 +27,7 @@ public class Material {
     @TableId(type = IdType.AUTO)
     private Long id;
 
-    @TableField(exist = false)
+    @TableField("id")
     @NotEmpty(message="素材ID不能为空", groups = { Detail.class, Update.class, Delete.class })
     private Long material_id;
 

+ 1 - 1
src/main/java/com/backendsys/modules/ai/material/entity/MaterialCategory.java

@@ -22,7 +22,7 @@ public class MaterialCategory {
     @TableId(type = IdType.AUTO)
     private Long id;
 
-    @TableField(exist = false)
+    @TableField("id")
     @NotEmpty(message="分类ID不能为空", groups = { Detail.class, Update.class, Delete.class })
     private Long category_id;
 

+ 1 - 1
src/main/java/com/backendsys/modules/ai/material/entity/MaterialTag.java

@@ -22,7 +22,7 @@ public class MaterialTag {
     @TableId(type = IdType.AUTO)
     private Long id;
 
-    @TableField(exist = false)
+    @TableField("id")
     @NotEmpty(message="标签ID不能为空", groups = { Detail.class, Update.class, Delete.class })
     private Long tag_id;
 

+ 12 - 0
src/main/java/com/backendsys/modules/ai/material/service/MaterialCategoryService.java

@@ -1,4 +1,16 @@
 package com.backendsys.modules.ai.material.service;
 
+import com.backendsys.modules.ai.material.entity.MaterialCategory;
+import com.backendsys.utils.response.PageEntity;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.List;
+
 public interface MaterialCategoryService {
+
+    // 获取素材分类列表
+    PageEntity selectMaterialCategoryList(MaterialCategory materialCategory);
+    // 获取素材分类列表 (下拉)
+    List<MaterialCategory> selectMaterialCategoryPopover();
+
 }

+ 5 - 0
src/main/java/com/backendsys/modules/ai/material/service/MaterialService.java

@@ -1,4 +1,9 @@
 package com.backendsys.modules.ai.material.service;
 
+import com.backendsys.utils.response.PageEntity;
+
 public interface MaterialService {
+
+    PageEntity getMaterialList();
+
 }

+ 34 - 0
src/main/java/com/backendsys/modules/ai/material/service/impl/MaterialCategoryImpl.java

@@ -1,8 +1,42 @@
 package com.backendsys.modules.ai.material.service.impl;
 
+import com.backendsys.modules.ai.material.dao.MaterialCategoryDao;
+import com.backendsys.modules.ai.material.entity.MaterialCategory;
 import com.backendsys.modules.ai.material.service.MaterialCategoryService;
+import com.backendsys.modules.system.dao.SysUserRolePermissionDao;
+import com.backendsys.modules.system.entity.SysUserRolePermission;
+import com.backendsys.utils.response.PageEntity;
+import com.backendsys.utils.response.PageInfoResult;
+import com.backendsys.utils.v2.PageUtils;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 @Service
 public class MaterialCategoryImpl implements MaterialCategoryService {
+
+    @Autowired
+    private MaterialCategoryDao materialCategoryDao;
+
+    /**
+     * 获取素材分类列表
+     */
+    @Override
+    public PageEntity selectMaterialCategoryList(MaterialCategory materialCategory) {
+        PageUtils.startPage();  // 分页
+        List<MaterialCategory> list = materialCategoryDao.selectMaterialCategoryList(materialCategory);
+        return new PageInfoResult(list).toEntity();
+    }
+
+    /**
+     * 获取素材分类列表 (下拉)
+     */
+    @Override
+    public List<MaterialCategory> selectMaterialCategoryPopover() {
+        return materialCategoryDao.selectMaterialCategoryList(new MaterialCategory());
+    }
+
 }

+ 9 - 0
src/main/java/com/backendsys/modules/ai/material/service/impl/MaterialServiceImpl.java

@@ -1,8 +1,17 @@
 package com.backendsys.modules.ai.material.service.impl;
 
 import com.backendsys.modules.ai.material.service.MaterialService;
+import com.backendsys.utils.response.PageEntity;
+import com.backendsys.utils.v2.PageUtils;
 import org.springframework.stereotype.Service;
 
 @Service
 public class MaterialServiceImpl implements MaterialService {
+
+    @Override
+    public PageEntity getMaterialList() {
+        PageUtils.startPage();  // 分页
+        return null;
+    }
+
 }

+ 32 - 0
src/main/resources/mapper/ai/material/MaterialCategoryDao.xml

@@ -0,0 +1,32 @@
+<?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="com.backendsys.modules.ai.material.dao.MaterialCategoryDao">
+
+    <sql id="includeMaterialCategory">
+        id,
+        id category_id,
+        category_name,
+        sort
+    </sql>
+    <!-- COALESCE(content_type, '') content_type, -->
+    <resultMap id="resultMapMaterialCategory" type="com.backendsys.modules.ai.material.entity.MaterialCategory">
+        <id property="id" column="id" jdbcType="BIGINT" />
+        <result property="category_id" column="id" javaType="java.lang.Long" />
+        <result property="category_name" column="category_name" />
+        <result property="sort" column="sort" javaType="java.lang.Integer" />
+    </resultMap>
+
+    <select id="selectMaterialCategoryList" resultMap="resultMapMaterialCategory">
+        SELECT
+            <include refid="includeMaterialCategory" />
+        FROM ai_material_category
+        <where>
+            <if test="category_name != null and category_name != ''">
+                AND category_name like concat('%', #{category_name}, '%')
+            </if>
+        </where>
+        ORDER BY sort DESC
+    </select>
+
+
+</mapper>