浏览代码

调整素材字段{file_url}

tsurumure 1 月之前
父节点
当前提交
df910dafa7

+ 14 - 15
db/ai_material.sql

@@ -14,8 +14,7 @@ CREATE TABLE `ai_material` (
     `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文件',
+    `file_url` VARCHAR(1000) COMMENT '文件地址',
     `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 '更新时间',
@@ -25,18 +24,18 @@ CREATE TABLE `ai_material` (
     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, create_time) 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, '2025-07-28 08:30:01'),
-    (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, '2025-07-28 08:30:02'),
-    (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, '2025-07-28 08:30:03'),
-    (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, '2025-07-28 08:30:04'),
-    (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, '2025-07-28 08:30:05'),
-    (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, '2025-07-28 08:30:06'),
-    (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, '2025-07-28 08:30:07'),
-    (1, 1, '4,5', '御姐魔女-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, '2025-07-28 08:30:08'),
-    (1, 1, '3,4,5', '御姐魔女-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, '2025-07-28 08:30:09'),
-    (1, 1, '3', '御姐魔女-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, '2025-07-28 08:30:10'),
-    (1, 2, '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, '2025-07-28 08:30:11'),
-    (1, 1, '1,2', '竹屋内', 'https://cos.daogu.ai/temp/d2361395-6e39-4a01-8c3b-1c79095f4391.png?imageMogr2/thumbnail/315x180/pad/1/color/I2Y4ZjhmOA==', 'https://cos.daogu.ai/temp/d2361395-6e39-4a01-8c3b-1c79095f4391.png', 'https://cos.daogu.ai/temp/2d0e951d-d894-4f88-8904-bf9f1d4797f5.fla', 'https://cos.daogu.ai/temp/aba04bf3-fa42-48d7-923f-b223b7aee22c.psd', 1, '2025-07-30 08:30:00')
+INSERT INTO ai_material(user_id, category_id, tag_ids, material_name, image_thumb_url, image_url, file_url, is_copyright, create_time) VALUES
+    (1, 1, '1,2', '御姐魔女-1', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.fla', 1, '2025-07-28 08:30:01'),
+    (1, 1, '1,2', '御姐魔女-2', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.fla', 1, '2025-07-28 08:30:02'),
+    (1, 1, '1,2', '御姐魔女-3', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.fla', 1, '2025-07-28 08:30:03'),
+    (1, 1, '1,2', '御姐魔女-4', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.fla', 1, '2025-07-28 08:30:04'),
+    (1, 1, '1,2', '御姐魔女-5', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.fla', 1, '2025-07-28 08:30:05'),
+    (1, 1, '1,2', '御姐魔女-6', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.fla', 1, '2025-07-28 08:30:06'),
+    (1, 1, '1,2', '御姐魔女-7', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.fla', 1, '2025-07-28 08:30:07'),
+    (1, 1, '4,5', '御姐魔女-8', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.fla', 1, '2025-07-28 08:30:08'),
+    (1, 1, '3,4,5', '御姐魔女-9', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.fla', 1, '2025-07-28 08:30:09'),
+    (1, 1, '3', '御姐魔女-10', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.fla', 1, '2025-07-28 08:30:10'),
+    (1, 2, '1,2', '御姐魔女-11', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.png', 'https://www.xxx.com/xx.fla', 1, '2025-07-28 08:30:11'),
+    (1, 1, '1,2', '竹屋内', 'https://cos.daogu.ai/temp/d2361395-6e39-4a01-8c3b-1c79095f4391.png?imageMogr2/thumbnail/315x180/pad/1/color/I2Y4ZjhmOA==', 'https://cos.daogu.ai/temp/d2361395-6e39-4a01-8c3b-1c79095f4391.png', 'https://cos.daogu.ai/temp/2d0e951d-d894-4f88-8904-bf9f1d4797f5.fla', 1, '2025-07-30 08:30:00')
 ;
 

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

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

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

@@ -56,9 +56,7 @@ public class Material {
     @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;
+    private String file_url;
 
     @RangeArray(message="是否有版权,范围应是(-1否, 1是)", value = {"-1", "1"}, groups = { Create.class, Update.class })
     private Integer is_copyright;

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

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

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

@@ -165,12 +165,10 @@ public class MaterialServiceImpl implements MaterialService {
 
         // 删除的时候,同时删除对象存储中的素材图片 (异步)
         ObjectKeyEntity image_url_object = objectKeyUtil.urlToObjectKey(detail.getImage_url());
-        ObjectKeyEntity fla_url_object = objectKeyUtil.urlToObjectKey(detail.getFla_url());
-        ObjectKeyEntity psd_url_object = objectKeyUtil.urlToObjectKey(detail.getPsd_url());
+        ObjectKeyEntity file_url_object = objectKeyUtil.urlToObjectKey(detail.getFile_url());
         CompletableFuture.runAsync(() -> {
             sysFileService.deleteObject(image_url_object.getObject_key(), image_url_object.getTarget());
-            sysFileService.deleteObject(fla_url_object.getObject_key(), fla_url_object.getTarget());
-            sysFileService.deleteObject(psd_url_object.getObject_key(), psd_url_object.getTarget());
+            sysFileService.deleteObject(file_url_object.getObject_key(), file_url_object.getTarget());
         });
 
         materialDao.deleteMaterial(material);

+ 12 - 9
src/main/resources/mapper/ai/material/MaterialCategoryDao.xml

@@ -3,17 +3,19 @@
 <mapper namespace="com.backendsys.modules.material.dao.MaterialCategoryDao">
 
     <sql id="includeMaterialCategory">
-        id,
-        id category_id,
-        lora_id,
-        category_name,
-        sort
+        mc.id,
+        mc.id category_id,
+        mc.lora_id,
+        mcl.lora_name,
+        mc.category_name,
+        mc.sort
     </sql>
     <!-- COALESCE(content_type, '') content_type, -->
     <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="lora_name" column="lora_name" />
         <result property="category_name" column="category_name" />
         <result property="sort" column="sort" javaType="java.lang.Integer" />
     </resultMap>
@@ -21,16 +23,17 @@
     <select id="selectMaterialCategoryList" resultMap="resultMapMaterialCategory">
         SELECT
             <include refid="includeMaterialCategory" />
-        FROM ai_material_category
+        FROM ai_material_category mc
+        LEFT JOIN ai_material_lora mcl ON mc.lora_id = mcl.id
         <where>
             <if test="lora_id != null and lora_id != ''">
-                AND lora_id = #{lora_id}
+                AND mc.lora_id = #{lora_id}
             </if>
             <if test="category_name != null and category_name != ''">
-                AND category_name like concat('%', #{category_name}, '%')
+                AND mc.category_name like concat('%', #{category_name}, '%')
             </if>
         </where>
-        ORDER BY sort DESC
+        ORDER BY mc.sort DESC
     </select>
 
 

+ 5 - 10
src/main/resources/mapper/ai/material/MaterialDao.xml

@@ -26,8 +26,7 @@
         m.material_name,
         COALESCE(m.image_thumb_url, '') image_thumb_url,
         COALESCE(m.image_url, '') image_url,
-        COALESCE(m.fla_url, '') fla_url,
-        COALESCE(m.psd_url, '') psd_url,
+        COALESCE(m.file_url, '') file_url,
         m.is_copyright,
         m.create_time,
         m.update_time
@@ -61,8 +60,7 @@
         <result property="material_name" column="material_name" />
         <result property="image_thumb_url" column="image_thumb_url" />
         <result property="image_url" column="image_url" />
-        <result property="fla_url" column="fla_url" />
-        <result property="psd_url" column="psd_url" />
+        <result property="file_url" column="file_url" />
         <result property="is_copyright" column="is_copyright" javaType="java.lang.Integer" />
         <result property="create_time" column="create_time"
                 typeHandler="com.backendsys.config.Mybatis.handler.timezone.LocalDateTimeHandler" />
@@ -110,8 +108,7 @@
             <if test="tag_ids != null and tag_ids != ''">, tag_ids</if>
             <if test="image_thumb_url != null and image_thumb_url != ''">, image_thumb_url</if>
             <if test="image_url != null and image_url != ''">, image_url</if>
-            <if test="fla_url != null and fla_url != ''">, fla_url</if>
-            <if test="psd_url != null and psd_url != ''">, psd_url</if>
+            <if test="file_url != null and file_url != ''">, file_url</if>
             <if test="is_copyright != null and is_copyright != ''">, is_copyright</if>
         )
         VALUES (
@@ -119,8 +116,7 @@
             <if test="tag_ids != null and tag_ids != ''">, #{tag_ids}</if>
             <if test="image_thumb_url != null and image_thumb_url != ''">, #{image_thumb_url}</if>
             <if test="image_url != null and image_url != ''">, #{image_url}</if>
-            <if test="fla_url != null and fla_url != ''">, #{fla_url}</if>
-            <if test="psd_url != null and psd_url != ''">, #{psd_url}</if>
+            <if test="file_url != null and file_url != ''">, #{file_url}</if>
             <if test="is_copyright != null and is_copyright != ''">, #{is_copyright}</if>
        )
     </insert>
@@ -135,8 +131,7 @@
         <if test="tag_ids != null and tag_ids != ''">, tag_ids = #{tag_ids}</if>
         <if test="image_thumb_url != null and image_thumb_url != ''">, image_thumb_url = #{image_thumb_url}</if>
         <if test="image_url != null and image_url != ''">, image_url = #{image_url}</if>
-        <if test="fla_url != null and fla_url != ''">, fla_url = #{fla_url}</if>
-        <if test="psd_url != null and psd_url != ''">, psd_url = #{psd_url}</if>
+        <if test="file_url != null and file_url != ''">, file_url = #{file_url}</if>
         <if test="is_copyright != null and is_copyright != ''">, is_copyright = #{is_copyright}</if>
         WHERE id = #{material_id}
     </update>