Bläddra i källkod

Add 素材管理

tsurumure 1 månad sedan
förälder
incheckning
01b00a9e7d
19 ändrade filer med 384 tillägg och 5 borttagningar
  1. 42 0
      db/ai_material.sql
  2. 25 0
      db/ai_material_category.sql
  3. 53 0
      db/ai_material_tag.sql
  4. 5 5
      db/sys_user_role_menu.sql
  5. 19 0
      src/main/java/com/backendsys/modules/ai/material/controller/MaterialCategoryController.java
  6. 19 0
      src/main/java/com/backendsys/modules/ai/material/controller/MaterialController.java
  7. 19 0
      src/main/java/com/backendsys/modules/ai/material/controller/MaterialTagController.java
  8. 9 0
      src/main/java/com/backendsys/modules/ai/material/dao/MaterialCategoryDao.java
  9. 9 0
      src/main/java/com/backendsys/modules/ai/material/dao/MaterialDao.java
  10. 9 0
      src/main/java/com/backendsys/modules/ai/material/dao/MaterialTagDao.java
  11. 64 0
      src/main/java/com/backendsys/modules/ai/material/entity/Material.java
  12. 36 0
      src/main/java/com/backendsys/modules/ai/material/entity/MaterialCategory.java
  13. 39 0
      src/main/java/com/backendsys/modules/ai/material/entity/MaterialTag.java
  14. 4 0
      src/main/java/com/backendsys/modules/ai/material/service/MaterialCategoryService.java
  15. 4 0
      src/main/java/com/backendsys/modules/ai/material/service/MaterialService.java
  16. 4 0
      src/main/java/com/backendsys/modules/ai/material/service/MaterialTagService.java
  17. 8 0
      src/main/java/com/backendsys/modules/ai/material/service/impl/MaterialCategoryImpl.java
  18. 8 0
      src/main/java/com/backendsys/modules/ai/material/service/impl/MaterialServiceImpl.java
  19. 8 0
      src/main/java/com/backendsys/modules/ai/material/service/impl/MaterialTagImpl.java

+ 42 - 0
db/ai_material.sql

@@ -0,0 +1,42 @@
+/**
+Source Server Version: 8.0.31
+Source Database: backendsys
+Date: 2025/07/28 15:57:12
+*/
+
+DROP TABLE IF EXISTS `ai_material`;
+CREATE TABLE `ai_material` (
+    PRIMARY KEY (`id`),
+    `id` BIGINT AUTO_INCREMENT COMMENT 'ID',
+    `user_id` BIGINT NOT NULL COMMENT '上传用户ID',
+    `category_id` BIGINT NOT NULL COMMENT '素材分类ID',
+    `tag_ids` VARCHAR(255) COMMENT '素材标签ID(多个以逗号间隔)',
+    `material_name` VARCHAR(100) NOT NULL COMMENT '素材名称',
+    `image_thumb_url` VARCHAR(1000) COMMENT '缩略图',
+    `image_url` VARCHAR(1000) COMMENT '高清图',
+    `fla_url` VARCHAR(1000) COMMENT 'FLA文件',
+    `psd_url` VARCHAR(1000) COMMENT 'PSD文件',
+    `is_copyright` TINYINT DEFAULT '-1' COMMENT '是否有版权 (-1否, 1是)',
+    `create_time` DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+    `update_time` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+    INDEX `idx_user_id` (`user_id`),
+    INDEX `idx_category_id` (`category_id`),
+    INDEX `idx_tag_ids` (`tag_ids`),
+    INDEX `idx_material_name` (`material_name`)
+) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='素材表';
+
+INSERT INTO ai_material(user_id, category_id, tag_ids, material_name, image_thumb_url, image_url, fla_url, psd_url, is_copyright) VALUES
+    (1, 1, '1,2', '御姐魔女-1', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.fla', 'https://www.xxx.com/xx.psd', 1),
+    (1, 1, '1,2', '御姐魔女-2', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.fla', 'https://www.xxx.com/xx.psd', 1),
+    (1, 1, '1,2', '御姐魔女-3', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.fla', 'https://www.xxx.com/xx.psd', 1),
+    (1, 1, '1,2', '御姐魔女-4', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.fla', 'https://www.xxx.com/xx.psd', 1),
+    (1, 1, '1,2', '御姐魔女-5', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.fla', 'https://www.xxx.com/xx.psd', 1),
+    (1, 1, '1,2', '御姐魔女-6', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.fla', 'https://www.xxx.com/xx.psd', 1),
+    (1, 1, '1,2', '御姐魔女-7', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.fla', 'https://www.xxx.com/xx.psd', 1),
+    (1, 1, '1,2', '御姐魔女-8', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.fla', 'https://www.xxx.com/xx.psd', 1),
+    (1, 1, '1,2', '御姐魔女-9', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.fla', 'https://www.xxx.com/xx.psd', 1),
+    (1, 1, '1,2', '御姐魔女-10', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.fla', 'https://www.xxx.com/xx.psd', 1),
+    (1, 1, '1,2', '御姐魔女-11', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.fla', 'https://www.xxx.com/xx.psd', 1),
+    (1, 1, '1,2', '御姐魔女-12', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.fla', 'https://www.xxx.com/xx.psd', 1)
+;
+

+ 25 - 0
db/ai_material_category.sql

@@ -0,0 +1,25 @@
+/**
+Source Server Version: 8.0.31
+Source Database: backendsys
+Date: 2025/07/28 15:57:12
+*/
+
+DROP TABLE IF EXISTS `ai_material_category`;
+CREATE TABLE `ai_material_category` (
+    PRIMARY KEY (`id`),
+    `id` BIGINT AUTO_INCREMENT 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)
+;
+

+ 53 - 0
db/ai_material_tag.sql

@@ -0,0 +1,53 @@
+/**
+Source Server Version: 8.0.31
+Source Database: backendsys
+Date: 2025/07/28 15:57:12
+*/
+
+DROP TABLE IF EXISTS `ai_material_tag`;
+CREATE TABLE `ai_material_tag` (
+    PRIMARY KEY (`id`),
+    `id` BIGINT AUTO_INCREMENT COMMENT 'ID',
+    `category_id` BIGINT NOT NULL COMMENT '素材分类ID',
+    `tag_name` VARCHAR(255) NOT NULL COMMENT '素材标签名称',
+    `sort` INT DEFAULT '1' COMMENT '排序',
+    INDEX `idx_tag_name` (`tag_name`),
+    INDEX `idx_category_id` (`category_id`)
+) 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)
+;
+

+ 5 - 5
db/sys_user_role_menu.sql

@@ -43,13 +43,13 @@ 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),
 
 
-#     (-1, '素材管理', 'Material', 1, '/material', '', '{}', 'MessageBox', '20', 10),
-#     (4, '素材中心', 'Material', 1, '/material/center', '/src/views/material/materialCenter.vue', '{}', null, '20.3', 10),
-#     (4, '素材列表', 'Material List', 1, '/material/list', '/src/views/material/materialList.vue', '{}', null, '20.1', 10),
-#     (4, '素材分类', 'Material Category', 1, '/material/category', '/src/views/material/materialCategory.vue', '{}', null, '20.2', 10),
+#     (-1, '素材管理', 'MaterialService', 1, '/material', '', '{}', 'MessageBox', '20', 10),
+#     (4, '素材中心', 'MaterialService', 1, '/material/center', '/src/views/material/materialCenter.vue', '{}', null, '20.3', 10),
+#     (4, '素材列表', 'MaterialService List', 1, '/material/list', '/src/views/material/materialList.vue', '{}', null, '20.1', 10),
+#     (4, '素材分类', 'MaterialService Category', 1, '/material/category', '/src/views/material/materialCategory.vue', '{}', null, '20.2', 10),
 #
 #     (-1, '我的', 'Account', 1, '/account', '', '{}', 'User', '21', 11),
-#     (8, '我的素材', 'My Material', 1, '/account/myMaterial', '', '{}', null, '21.1', 11),
+#     (8, '我的素材', 'My MaterialService', 1, '/account/myMaterial', '', '{}', null, '21.1', 11),
 #     (8, '我的作品', 'My Work', 1, '/account/myWork', '', '{}', null, '21.2', 11),
 #     (8, '我的草稿', 'My Draft', 1, '/account/myDraft', '', '{}', null, '21.3', 11),
 

+ 19 - 0
src/main/java/com/backendsys/modules/ai/material/controller/MaterialCategoryController.java

@@ -0,0 +1,19 @@
+package com.backendsys.modules.ai.material.controller;
+
+import com.backendsys.modules.ai.material.service.MaterialCategoryService;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.RestController;
+
+@Validated
+@RestController
+@Tag(name = "素材分类管理")
+public class MaterialCategoryController {
+
+    @Autowired
+    private MaterialCategoryService materialCategoryService;
+
+    
+
+}

+ 19 - 0
src/main/java/com/backendsys/modules/ai/material/controller/MaterialController.java

@@ -0,0 +1,19 @@
+package com.backendsys.modules.ai.material.controller;
+
+import com.backendsys.modules.ai.material.service.MaterialService;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.RestController;
+
+@Validated
+@RestController
+@Tag(name = "素材管理")
+public class MaterialController {
+
+    @Autowired
+    private MaterialService materialService;
+
+
+
+}

+ 19 - 0
src/main/java/com/backendsys/modules/ai/material/controller/MaterialTagController.java

@@ -0,0 +1,19 @@
+package com.backendsys.modules.ai.material.controller;
+
+import com.backendsys.modules.ai.material.service.MaterialTagService;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.RestController;
+
+@Validated
+@RestController
+@Tag(name = "素材标签管理")
+public class MaterialTagController {
+
+    @Autowired
+    private MaterialTagService materialTagService;
+
+    
+
+}

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

@@ -0,0 +1,9 @@
+package com.backendsys.modules.ai.material.dao;
+
+import com.backendsys.modules.ai.material.entity.MaterialCategory;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface MaterialCategoryDao extends BaseMapper<MaterialCategory> {
+}

+ 9 - 0
src/main/java/com/backendsys/modules/ai/material/dao/MaterialDao.java

@@ -0,0 +1,9 @@
+package com.backendsys.modules.ai.material.dao;
+
+import com.backendsys.modules.ai.material.entity.Material;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface MaterialDao extends BaseMapper<Material> {
+}

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

@@ -0,0 +1,9 @@
+package com.backendsys.modules.ai.material.dao;
+
+import com.backendsys.modules.ai.material.entity.MaterialTag;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface MaterialTagDao extends BaseMapper<MaterialTag> {
+}

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

@@ -0,0 +1,64 @@
+package com.backendsys.modules.ai.material.entity;
+
+import com.backendsys.config.Mybatis.handler.timezone.LocalDateTimeAdapter;
+import com.backendsys.entity.validator.RangeArray;
+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 com.google.gson.annotations.JsonAdapter;
+import jakarta.validation.constraints.NotEmpty;
+import jakarta.validation.constraints.Size;
+import lombok.Data;
+import org.hibernate.validator.constraints.Range;
+
+import java.time.LocalDateTime;
+import java.util.List;
+
+@Data
+@TableName("ai_material")
+public class Material {
+
+    public static interface Detail{}
+    public static interface Create{}
+    public static interface Update{}
+    public static interface Delete{}
+
+    @TableId(type = IdType.AUTO)
+    private Long id;
+
+    @TableField(exist = false)
+    @NotEmpty(message="素材ID不能为空", groups = { Detail.class, Update.class, Delete.class })
+    private Long material_id;
+
+    private Long user_id;
+
+    @NotEmpty(message="素材分类ID不能为空", groups = { Create.class, Update.class })
+    private Long category_id;
+    private String tag_ids;
+
+    @TableField(exist = false)
+    private List<MaterialTag> tag_list;
+
+    @Size(max = 100, message = "素材名称长度不超过 {max} 个字符", groups = { Create.class, Update.class })
+    @NotEmpty(message="素材名称不能为空", groups = { Create.class, Update.class })
+    private String material_name;
+
+    @Size(max = 1000, message = "缩略图路径长度不超过 {max} 个字符", groups = { Create.class, Update.class })
+    private String image_thumb_url;
+    @Size(max = 1000, message = "高清图路径长度不超过 {max} 个字符", groups = { Create.class, Update.class })
+    private String image_url;
+    @Size(max = 1000, message = "FLA路径长度不超过 {max} 个字符", groups = { Create.class, Update.class })
+    private String fla_url;
+    @Size(max = 1000, message = "PSD路径长度不超过 {max} 个字符", groups = { Create.class, Update.class })
+    private String psd_url;
+
+    @RangeArray(message="是否有版权,范围应是(-1否, 1是)", value = {"-1", "1"})
+    private Integer is_copyright;
+
+    @JsonAdapter(LocalDateTimeAdapter.class)
+    private LocalDateTime create_time;
+    @JsonAdapter(LocalDateTimeAdapter.class)
+    private LocalDateTime update_time;
+
+}

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

@@ -0,0 +1,36 @@
+package com.backendsys.modules.ai.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.Size;
+import lombok.Data;
+import org.hibernate.validator.constraints.Range;
+
+@Data
+@TableName("ai_material_category")
+public class MaterialCategory {
+
+    public static interface CategoryList{}
+    public static interface Detail{}
+    public static interface Create{}
+    public static interface Update{}
+    public static interface Delete{}
+
+    @TableId(type = IdType.AUTO)
+    private Long id;
+
+    @TableField(exist = false)
+    @NotEmpty(message="分类ID不能为空", groups = { Detail.class, Update.class, Delete.class })
+    private Long category_id;
+
+    @Size(max = 100, message = "分类名称长度不超过 {max} 个字符", groups = { Create.class, Update.class })
+    @NotEmpty(message="分类名称不能为空", groups = { Create.class, Update.class })
+    private String category_name;
+
+    @Range(min = 1, max = 9999, message = "排序必须在 {min} 到 {max} 之间")
+    private Integer sort;
+
+}

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

@@ -0,0 +1,39 @@
+package com.backendsys.modules.ai.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.Size;
+import lombok.Data;
+import org.hibernate.validator.constraints.Range;
+
+@Data
+@TableName("ai_material_tag")
+public class MaterialTag {
+
+    public static interface TagList{}
+    public static interface Detail{}
+    public static interface Create{}
+    public static interface Update{}
+    public static interface Delete{}
+
+    @TableId(type = IdType.AUTO)
+    private Long id;
+
+    @TableField(exist = false)
+    @NotEmpty(message="标签ID不能为空", groups = { Detail.class, Update.class, Delete.class })
+    private Long tag_id;
+
+    @NotEmpty(message="分类ID不能为空", groups = { TagList.class, Detail.class })
+    private Long category_id;
+
+    @Size(max = 100, message = "标签名称长度不超过 {max} 个字符", groups = { Create.class, Update.class })
+    @NotEmpty(message="标签名称不能为空", groups = { Create.class, Update.class })
+    private String tag_name;
+
+    @Range(min = 1, max = 9999, message = "排序必须在 {min} 到 {max} 之间")
+    private Integer sort;
+
+}

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

@@ -0,0 +1,4 @@
+package com.backendsys.modules.ai.material.service;
+
+public interface MaterialCategoryService {
+}

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

@@ -0,0 +1,4 @@
+package com.backendsys.modules.ai.material.service;
+
+public interface MaterialService {
+}

+ 4 - 0
src/main/java/com/backendsys/modules/ai/material/service/MaterialTagService.java

@@ -0,0 +1,4 @@
+package com.backendsys.modules.ai.material.service;
+
+public interface MaterialTagService {
+}

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

@@ -0,0 +1,8 @@
+package com.backendsys.modules.ai.material.service.impl;
+
+import com.backendsys.modules.ai.material.service.MaterialCategoryService;
+import org.springframework.stereotype.Service;
+
+@Service
+public class MaterialCategoryImpl implements MaterialCategoryService {
+}

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

@@ -0,0 +1,8 @@
+package com.backendsys.modules.ai.material.service.impl;
+
+import com.backendsys.modules.ai.material.service.MaterialService;
+import org.springframework.stereotype.Service;
+
+@Service
+public class MaterialServiceImpl implements MaterialService {
+}

+ 8 - 0
src/main/java/com/backendsys/modules/ai/material/service/impl/MaterialTagImpl.java

@@ -0,0 +1,8 @@
+package com.backendsys.modules.ai.material.service.impl;
+
+import com.backendsys.modules.ai.material.service.MaterialTagService;
+import org.springframework.stereotype.Service;
+
+@Service
+public class MaterialTagImpl implements MaterialTagService {
+}