Sfoglia il codice sorgente

Merge branch 'dev-yhq'

tsurumure 1 mese fa
parent
commit
257852fcbe

+ 13 - 8
db/ai_material_category.sql

@@ -8,18 +8,23 @@ DROP TABLE IF EXISTS `ai_material_category`;
 CREATE TABLE `ai_material_category` (
     PRIMARY KEY (`id`),
     `id` BIGINT AUTO_INCREMENT COMMENT 'ID',
+    `lora_id` BIGINT NOT NULL COMMENT '素材风格ID',
     `category_name` VARCHAR(255) NOT NULL COMMENT '素材分类名称',
     `sort` INT DEFAULT '1' COMMENT '排序',
     INDEX `idx_category_name` (`category_name`)
 ) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='素材分类表';
 
-INSERT INTO ai_material_category(category_name, sort) VALUES
-    ('人物素材', 7),
-    ('场景素材', 6),
-    ('表情素材', 5),
-    ('兽类素材', 4),
-    ('道具素材', 3),
-    ('特效素材', 2),
-    ('AI素材', 1)
+INSERT INTO ai_material_category(lora_id, category_name, sort) VALUES
+    (1, '人物素材', 7),
+    (1, '场景素材', 6),
+    (1, '异兽素材', 5),
+    (1, '道具素材', 3),
+    (1, '特效素材', 2),
+
+    (2, '人物素材', 7),
+    (2, '场景素材', 6),
+    (2, '异兽素材', 5),
+    (2, '道具素材', 4),
+    (2, '特效素材', 3)
 ;
 

+ 20 - 0
db/ai_material_lora.sql

@@ -0,0 +1,20 @@
+/**
+Source Server Version: 8.0.31
+Source Database: backendsys
+Date: 2025/07/28 15:57:12
+*/
+
+DROP TABLE IF EXISTS `ai_material_lora`;
+CREATE TABLE `ai_material_lora` (
+    PRIMARY KEY (`id`),
+    `id` BIGINT AUTO_INCREMENT COMMENT 'ID',
+    `lora_name` VARCHAR(255) NOT NULL COMMENT '素材风格名称',
+    `sort` INT DEFAULT '1' COMMENT '排序',
+    INDEX `idx_lora_name` (`lora_name`)
+) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='素材风格表';
+
+INSERT INTO ai_material_lora(lora_name, sort) VALUES
+    ('沙雕素材', 2),
+    ('简笔画素材', 1)
+;
+

+ 48 - 33
db/ai_material_tag.sql

@@ -16,38 +16,53 @@ CREATE TABLE `ai_material_tag` (
 ) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='素材标签表';
 
 INSERT INTO ai_material_tag(category_id, tag_name, sort) VALUES
-    # 1.人物素材
-    (1, '都市人物', 10),
-    (1, '历史人物', 9),
-    (1, '修仙人物', 8),
-    (1, '灵异人物', 7),
-    (1, '主题人物', 6),
-    (1, '火影人物', 5),
-    (1, '海贼人物', 4),
-    (1, '兽世人物', 3),
-    (1, '精选人物', 2),
-    (1, 'Q版人物', 1),
-    # 2.场景素材
-    (2, '都市场景', 7),
-    (2, '修仙古风', 6),
-    (2, '主题场景', 5),
-    (2, '通用场景', 4),
-    (2, '末日悬疑', 3),
-    (2, '兽世古代', 2),
-    (2, '星际宇宙', 1),
-    # 3.表情素材
-    (3, '身体部件', 2),
-    (3, '人物表情', 1),
-    # 4.兽类素材
-    (4, '异兽素材', 2),
-    (4, '动物素材', 1),
-    # 5.道具素材
-    (5, '通用道具', 3),
-    (5, '交通工具', 2),
-    (5, '武器装备', 1),
-    # 6.特效素材
-    (6, '特效素材', 1),
-    # 7.AI素材
-    (7, 'AI素材', 1)
+    # 1-沙雕素材-人物素材
+    (1, '精品人物', 10),
+    (1, '修仙人物', 9),
+    (1, '都市人物', 8),
+    (1, '历史人物', 7),
+    # 2-沙雕素材-场景素材
+    (2, '修仙场景', 10),
+    (2, '都市场景', 9),
+    (2, '历史场景', 8),
+    # 3-沙雕素材-异兽素材
+    (3, '异兽', 10),
+    (3, '动物', 9),
+    # 4-沙雕素材-道具素材
+    (4, '修仙道具', 10),
+    (4, '都市道具', 9),
+    (4, '历史道具', 8),
+    # 5-沙雕素材-特效参考
+    (5, '常用特效', 10),
+    (5, '普通特效', 9),
+    (5, '战斗特效', 8),
+    (5, '阵法特效', 7),
+    (5, '全屏特效', 6),
+
+    # 6-简笔画素材-人物素材
+    (6, '精品人物', 10),
+    (6, '修仙人物', 9),
+    (6, '都市人物', 8),
+    (6, '历史人物', 7),
+    (6, '末日悬疑人物', 6),
+    # 7-简笔画素材-场景素材
+    (7, '修仙场景', 10),
+    (7, '都市场景', 9),
+    (7, '历史场景', 8),
+    (7, '8090场景', 7),
+    (7, '末日悬疑场景', 6),
+    # 8-简笔画素材-异兽素材
+    (8, '异兽', 10),
+    (8, '动物', 9),
+    # 9-简笔画素材-道具素材
+    (9, '修仙道具', 10),
+    (9, '都市道具', 9),
+    (9, '历史道具', 8),
+    # 10-简笔画素材-特效参考
+    (10, '常用特效', 10),
+    (10, '普通特效', 9),
+    (10, '战斗特效', 8),
+    (10, '阵法特效', 7),
+    (10, '全屏特效', 6)
 ;
 

+ 3 - 3
db/sys_user_role.sql

@@ -23,7 +23,7 @@ INSERT INTO sys_user_role(role_name, role_description, login_default_page, sort)
     ('开发者', '全部权限', '/', 1),
     ('管理员', '全部功能权限', '/', 2),
     ('普通用户', '基础权限', '/', 3),
-    ('运营-素材-管理员', '素材管理全权限 (允许查看/下载/上传/删除)', '/material/materialList', 4),
-    ('运营-素材-普通用户', '允许查看/下载', '/material/materialList', 5),
-    ('运营-素材-游客', '允许查看', '/material/materialList', 6)
+    ('运营-素材-管理员', '素材管理全权限 (允许查看/下载/上传/删除)', '/material/materialList?lora_id=1', 4),
+    ('运营-素材-普通用户', '允许查看/下载', '/material/materialList?lora_id=1', 5),
+    ('运营-素材-游客', '允许查看', '/material/materialList?lora_id=1', 6)
 ;

+ 6 - 3
db/sys_user_role_menu.sql

@@ -43,9 +43,12 @@ INSERT INTO sys_user_role_menu(id, parent_id, menu_name, menu_name_en, type, pat
     (11, -1, 'AI成片', 'AI Video', 1, '/ai/generate/video/broadcast/my/broadcast', '', '{}', 'VideoCamera', '34', 909),
 
 
-    (20, -1, '素材管理', 'Material', 1, '/material', '', '{}', 'MessageBox', '20', 13),
-    (21, 20, '素材列表', 'Material List', 1, '/material/materialList', '/src/views/material/materialList.vue', '{}', null, '20.1', 13),
-#
+    (20, -1, '素材中心', 'Material', 1, '/material/materialList', '/src/views/material/materialList.vue', '{}', 'MessageBox', '20', 13),
+#     (20, -1, '素材管理', 'Material', 1, '/material', '', '{}', 'MessageBox', '20', 13),
+#     (21, 20, '素材列表', 'Material List', 1, '/material/materialList', '/src/views/material/materialList.vue', '{}', null, '20.1', 13),
+#     (21, 20, '沙雕素材', 'Material Sa Diao', 1, '/material/materialList?lora_id=1', '/src/views/material/materialList.vue', '{}', null, '20.1', 13),
+#     (22, 20, '简笔画素材', 'Material Simple', 1, '/material/materialList?lora_id=2', '/src/views/material/materialList.vue', '{}', null, '20.1', 13),
+
 #     (-1, '我的', 'Account', 1, '/account', '', '{}', 'User', '21', 11),
 #     (8, '我的素材', 'My MaterialService', 1, '/account/myMaterial', '', '{}', null, '21.1', 11),
 #     (8, '我的作品', 'My Work', 1, '/account/myWork', '', '{}', null, '21.2', 11),

+ 2 - 2
src/main/java/com/backendsys/modules/material/controller/MaterialCategoryController.java

@@ -28,8 +28,8 @@ public class MaterialCategoryController {
     @Operation(summary = "获取素材分类列表(下拉)")
 //    @PreAuthorize("@sr.hasPermission('20.2')")
     @GetMapping("/api/material/getMaterialCategoryPopover")
-    public Result getMaterialCategoryPopover() {
-        return Result.success().put("data", materialCategoryService.selectMaterialCategoryPopover());
+    public Result getMaterialCategoryPopover(@Validated(MaterialCategory.CategoryList.class) MaterialCategory materialCategory) {
+        return Result.success().put("data", materialCategoryService.selectMaterialCategoryPopover(materialCategory));
     }
 
 }

+ 36 - 0
src/main/java/com/backendsys/modules/material/controller/MaterialLoraController.java

@@ -0,0 +1,36 @@
+package com.backendsys.modules.material.controller;
+
+import com.backendsys.modules.common.utils.Result;
+import com.backendsys.modules.material.entity.MaterialLora;
+import com.backendsys.modules.material.service.MaterialLoraService;
+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
+@RestController
+@Tag(name = "素材风格管理")
+public class MaterialLoraController {
+
+    @Autowired
+    private MaterialLoraService materialLoraService;
+
+    @Operation(summary = "获取素材风格列表")
+//    @PreAuthorize("@sr.hasPermission('20.3')")
+    @GetMapping("/api/material/getMaterialLoraList")
+    public Result getMaterialLoraList(@Validated(MaterialLora.LoraList.class) MaterialLora materialLora) {
+        return Result.success().put("data", materialLoraService.selectMaterialLoraList(materialLora));
+    }
+
+    @Operation(summary = "获取素材风格列表(下拉)")
+//    @PreAuthorize("@sr.hasPermission('20.3')")
+    @GetMapping("/api/material/getMaterialLoraPopover")
+    public Result getMaterialLoraPopover(@Validated(MaterialLora.LoraList.class) MaterialLora materialLora) {
+        return Result.success().put("data", materialLoraService.selectMaterialLoraPopover(materialLora));
+    }
+
+}

+ 14 - 0
src/main/java/com/backendsys/modules/material/dao/MaterialLoraDao.java

@@ -0,0 +1,14 @@
+package com.backendsys.modules.material.dao;
+
+import com.backendsys.modules.material.entity.MaterialLora;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+@Mapper
+public interface MaterialLoraDao extends BaseMapper<MaterialLora> {
+
+    List<MaterialLora> selectMaterialLoraList(MaterialLora materialLora);
+    
+}

+ 0 - 2
src/main/java/com/backendsys/modules/material/dao/MaterialTagDao.java

@@ -11,6 +11,4 @@ public interface MaterialTagDao extends BaseMapper<MaterialTag> {
 
     List<MaterialTag> selectMaterialTagList(MaterialTag materialTag);
 
-
-
 }

+ 3 - 0
src/main/java/com/backendsys/modules/material/entity/MaterialCategory.java

@@ -27,6 +27,9 @@ public class MaterialCategory {
     @NotNull(message="分类ID不能为空", groups = { Detail.class, Update.class, Delete.class })
     private Long category_id;
 
+    @NotNull(message="风格ID不能为空", groups = { CategoryList.class, Detail.class, Create.class, Update.class })
+    private Long lora_id;
+
     @Size(max = 100, message = "分类名称长度不超过 {max} 个字符", groups = { Create.class, Update.class })
     @NotEmpty(message="分类名称不能为空", groups = { Create.class, Update.class })
     private String category_name;

+ 37 - 0
src/main/java/com/backendsys/modules/material/entity/MaterialLora.java

@@ -0,0 +1,37 @@
+package com.backendsys.modules.material.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import jakarta.validation.constraints.NotEmpty;
+import jakarta.validation.constraints.NotNull;
+import jakarta.validation.constraints.Size;
+import lombok.Data;
+import org.hibernate.validator.constraints.Range;
+
+@Data
+@TableName("ai_material_lora")
+public class MaterialLora {
+
+    public static interface LoraList{}
+    public static interface Detail{}
+    public static interface Create{}
+    public static interface Update{}
+    public static interface Delete{}
+
+    @TableId(type = IdType.AUTO)
+    private Long id;
+
+    @TableField("id")
+    @NotNull(message="分类ID不能为空", groups = { Detail.class, Update.class, Delete.class })
+    private Long lora_id;
+
+    @Size(max = 100, message = "分类名称长度不超过 {max} 个字符", groups = { Create.class, Update.class })
+    @NotEmpty(message="分类名称不能为空", groups = { Create.class, Update.class })
+    private String lora_name;
+
+    @Range(min = 1, max = 9999, message = "排序必须在 {min} 到 {max} 之间")
+    private Integer sort;
+
+}

+ 1 - 1
src/main/java/com/backendsys/modules/material/service/MaterialCategoryService.java

@@ -10,6 +10,6 @@ public interface MaterialCategoryService {
     // 获取素材分类列表
     PageEntity selectMaterialCategoryList(MaterialCategory materialCategory);
     // 获取素材分类列表 (下拉)
-    List<MaterialCategory> selectMaterialCategoryPopover();
+    List<MaterialCategory> selectMaterialCategoryPopover(MaterialCategory materialCategory);
 
 }

+ 15 - 0
src/main/java/com/backendsys/modules/material/service/MaterialLoraService.java

@@ -0,0 +1,15 @@
+package com.backendsys.modules.material.service;
+
+import com.backendsys.modules.material.entity.MaterialLora;
+import com.backendsys.utils.response.PageEntity;
+
+import java.util.List;
+
+public interface MaterialLoraService {
+
+    // 获取素材风格列表
+    PageEntity selectMaterialLoraList(MaterialLora materialLora);
+
+    // 获取素材风格列表 (下拉)
+    List<MaterialLora> selectMaterialLoraPopover(MaterialLora materialLora);
+}

+ 2 - 2
src/main/java/com/backendsys/modules/material/service/impl/MaterialCategoryImpl.java

@@ -31,8 +31,8 @@ public class MaterialCategoryImpl implements MaterialCategoryService {
      * 获取素材分类列表 (下拉)
      */
     @Override
-    public List<MaterialCategory> selectMaterialCategoryPopover() {
-        return materialCategoryDao.selectMaterialCategoryList(new MaterialCategory());
+    public List<MaterialCategory> selectMaterialCategoryPopover(MaterialCategory materialCategory) {
+        return materialCategoryDao.selectMaterialCategoryList(materialCategory);
     }
 
 }

+ 38 - 0
src/main/java/com/backendsys/modules/material/service/impl/MaterialLoraServiceImpl.java

@@ -0,0 +1,38 @@
+package com.backendsys.modules.material.service.impl;
+
+import com.backendsys.modules.material.dao.MaterialLoraDao;
+import com.backendsys.modules.material.entity.MaterialLora;
+import com.backendsys.modules.material.service.MaterialLoraService;
+import com.backendsys.utils.response.PageEntity;
+import com.backendsys.utils.response.PageInfoResult;
+import com.backendsys.utils.v2.PageUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class MaterialLoraServiceImpl implements MaterialLoraService {
+
+    @Autowired
+    private MaterialLoraDao materialLoraDao;
+
+    /**
+     * 获取素材风格列表
+     */
+    @Override
+    public PageEntity selectMaterialLoraList(MaterialLora materialLora) {
+        PageUtils.startPage();  // 分页
+        List<MaterialLora> list = materialLoraDao.selectMaterialLoraList(materialLora);
+        return new PageInfoResult(list).toEntity();
+    }
+
+    /**
+     * 获取素材风格列表 (下拉)
+     */
+    @Override
+    public List<MaterialLora> selectMaterialLoraPopover(MaterialLora materialLora) {
+        List<MaterialLora> list = materialLoraDao.selectMaterialLoraList(materialLora);
+        return list;
+    }
+}

+ 2 - 2
src/main/java/com/backendsys/modules/material/service/impl/MaterialServiceImpl.java

@@ -116,7 +116,7 @@ public class MaterialServiceImpl implements MaterialService {
 
         // 生成缩略图,并填充缩略图地址
         if (StrUtil.isNotEmpty(material.getImage_url())) {
-            String image_thumb_url = UploadUtil.getImageThumbUrl(material.getImage_url(), objectKeyEntity.getTarget(), 315, 180);
+            String image_thumb_url = UploadUtil.getImageThumbUrl(material.getImage_url(), objectKeyEntity.getTarget(), 276, 155);
             material.setImage_thumb_url(image_thumb_url);
         }
 
@@ -145,7 +145,7 @@ public class MaterialServiceImpl implements MaterialService {
         // 生成缩略图,并填充缩略图地址
         if (StrUtil.isNotEmpty(material.getImage_url())) {
             ObjectKeyEntity objectKeyEntity = objectKeyUtil.urlToObjectKey(material.getImage_url());
-            String image_thumb_url = UploadUtil.getImageThumbUrl(material.getImage_url(), objectKeyEntity.getTarget(), 315, 180);
+            String image_thumb_url = UploadUtil.getImageThumbUrl(material.getImage_url(), objectKeyEntity.getTarget(), 276, 155);
             material.setImage_thumb_url(image_thumb_url);
         }
 

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

@@ -5,6 +5,7 @@
     <sql id="includeMaterialCategory">
         id,
         id category_id,
+        lora_id,
         category_name,
         sort
     </sql>
@@ -12,6 +13,7 @@
     <resultMap id="resultMapMaterialCategory" type="com.backendsys.modules.material.entity.MaterialCategory">
         <id property="id" column="id" jdbcType="BIGINT" />
         <result property="category_id" column="id" javaType="java.lang.Long" />
+        <result property="lora_id" column="lora_id" javaType="java.lang.Long" />
         <result property="category_name" column="category_name" />
         <result property="sort" column="sort" javaType="java.lang.Integer" />
     </resultMap>
@@ -21,6 +23,9 @@
             <include refid="includeMaterialCategory" />
         FROM ai_material_category
         <where>
+            <if test="lora_id != null and lora_id != ''">
+                AND lora_id = #{lora_id}
+            </if>
             <if test="category_name != null and category_name != ''">
                 AND category_name like concat('%', #{category_name}, '%')
             </if>

+ 32 - 0
src/main/resources/mapper/ai/material/MaterialLoraDao.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.material.dao.MaterialLoraDao">
+
+    <sql id="includeMaterialLora">
+        id,
+        id lora_id,
+        lora_name,
+        sort
+    </sql>
+    <!-- COALESCE(content_type, '') content_type, -->
+    <resultMap id="resultMapMaterialLora" type="com.backendsys.modules.material.entity.MaterialLora">
+        <id property="id" column="id" jdbcType="BIGINT" />
+        <result property="lora_id" column="id" javaType="java.lang.Long" />
+        <result property="lora_name" column="lora_name" />
+        <result property="sort" column="sort" javaType="java.lang.Integer" />
+    </resultMap>
+
+    <select id="selectMaterialLoraList" resultMap="resultMapMaterialLora">
+        SELECT
+            <include refid="includeMaterialLora" />
+        FROM ai_material_lora
+        <where>
+            <if test="lora_name != null and lora_name != ''">
+                AND lora_name = #{lora_name}
+            </if>
+        </where>
+        ORDER BY sort DESC
+    </select>
+
+
+</mapper>