瀏覽代碼

完成 编辑分镜 接口

tsurumure 2 月之前
父節點
當前提交
ff40daaf74

+ 0 - 1
src/main/java/com/backendsys/modules/crt/controller/CrtDramaProjectStoryboardController.java

@@ -41,7 +41,6 @@ public class CrtDramaProjectStoryboardController {
     @Operation(summary = "编辑分镜")
     @PutMapping("/api/crt/drama/updateStoryboard")
     public Result updateStoryboard(@Validated(CrtDramaProjectStoryboard.Update.class) @RequestBody CrtDramaProjectStoryboard crtDramaProjectStoryboard) {
-        crtDramaProjectStoryboard.setUser_id(SecurityUtil.getUserId());
         return Result.success().put("data", crtDramaProjectStoryboardService.updateStoryboard(crtDramaProjectStoryboard));
     }
 

+ 1 - 0
src/main/java/com/backendsys/modules/crt/dao/CrtDramaProjectStoryboardDao.java

@@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Mapper;
 @Mapper
 public interface CrtDramaProjectStoryboardDao extends BaseMapper<CrtDramaProjectStoryboard> {
 
+    // 编辑分镜
     int updateStoryboard(CrtDramaProjectStoryboard crtDramaProjectStoryboard);
 
 }

+ 58 - 17
src/main/java/com/backendsys/modules/crt/entity/CrtDramaProjectStoryboard.java

@@ -1,15 +1,21 @@
 package com.backendsys.modules.crt.entity;
 
+import com.backendsys.config.Mybatis.handler.timezone.LocalDateTimeAdapter;
+import com.backendsys.entity.validator.RangeArray;
+import com.backendsys.entity.validator.RangeStringArray;
 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.Max;
 import jakarta.validation.constraints.NotNull;
 import jakarta.validation.constraints.Size;
 import lombok.Data;
 import org.hibernate.validator.constraints.Range;
 
+import java.time.LocalDateTime;
+
 @Data
 @TableName("crt_drama_project_storyboard")
 public class CrtDramaProjectStoryboard {
@@ -29,12 +35,13 @@ public class CrtDramaProjectStoryboard {
 
     private Long user_id;
 
-    @NotNull(message = "项目ID不能为空", groups = { StoryboardDetail.class })
+    @NotNull(message = "项目ID不能为空", groups = { Create.class, StoryboardDetail.class })
     private Long drama_project_id;
-    @NotNull(message = "集数不能为空", groups = { StoryboardDetail.class })
+    @NotNull(message = "集数不能为空", groups = { Create.class, StoryboardDetail.class })
     @Max(value = 999, message = "集数不超过 {value}")
     private Integer episode_num;
 
+    @NotNull(message = "序号不能为空", groups = { Create.class })
     @Range(min = 1, max = 9999, message = "排序必须在 {min} 到 {max} 之间")
     private Integer sort;
 
@@ -46,27 +53,61 @@ public class CrtDramaProjectStoryboard {
     private String story_scene;
     @Size(max = 1000, message = "天气/时间长度不超过 {max} 个字符", groups = { Update.class })
     private String story_weather_time;
-    private String lora_figure_ids;                 // 人物LoRA ID (创建时,跟随项目的人物LoRAID)(多个人物ID以逗号分隔)
 
-    private Integer param_image_count;              // 每次生成图片数量 (默认值:1,整数范围:1~4)
-    private Float param_prompt_weight;              // 提示词引导系数 (默认值:3.5,小数点后一位,范围:1~30)
-    private String param_sampling_method;           // 采样方法 (枚举: SamplingMethodEnums)(Euler: euler, DPM++2M: dpmpp_2m)
-    private Integer param_step_count;               // 步数 (默认值:20,整数范围:1~30)
-    private Integer param_random_seed;              // 随机种子 (默认值:1,范围:(1:随机, 2:自定义))
-    private String param_random_seed_custom;        // 随机种子自定义值 (长度: 0~64位整数)
+    // 人物LoRA ID (创建时,跟随项目的人物LoRAID)(多个人物ID以逗号分隔)
+    @Size(max = 255, message = "人物LoRA ID长度不超过 {max} 个字符", groups = { Update.class })
+    private String lora_figure_ids;
+
+    // 每次生成图片数量 (默认值:1,整数范围:1~4)
+    @RangeArray(message="生成图片数量取值有误,范围应是(1, 2, 3, 4)", value = { "1", "2", "3", "4" }, groups = { Update.class })
+    private Integer param_image_count;
+
+    // 提示词引导系数 (默认值:3.5,小数点后一位,范围:1~30)
+    @Range(min = 1, max = 30, message = "提示词引导系数必须在 {min} 到 {max} 之间", groups = { Update.class })
+    private Float param_prompt_weight;
+
+    // 采样方法 (枚举: SamplingMethodEnums)(Euler: euler, DPM++2M: dpmpp_2m)
+    @RangeStringArray(message="采样方法取值有误,范围应是(Euler, DPM++2M)", value = { "Euler", "DPM++2M" }, groups = { Update.class })
+    private String param_sampling_method;
+
+    // 步数 (默认值:20,整数范围:1~30)
+    @Range(min = 1, max = 30, message = "步数必须在 {min} 到 {max} 之间", groups = { Update.class })
+    private Integer param_step_count;
 
+    // 随机种子 (默认值:1,范围:(1:随机, 2:自定义))
+    @RangeArray(message="随机种子取值有误,范围应是(1, 2)", value = { "1", "2" }, groups = { Update.class })
+    private Integer param_random_seed;
+
+    // 随机种子自定义值 (长度: 0~64位整数)
+    @Size(max = 64, message = "随机种子自定义值长度不超过 {max} 个字符", groups = { Update.class })
+    private String param_random_seed_custom;
+
+    // 文生图提示词 (生图时必填)
     @Size(max = 2000, message = "文生图提示词 长度不超过 {max} 个字符", groups = { Update.class })
-    private String text_to_image_prompt;            // 文生图提示词 (生图时必填)
+    private String text_to_image_prompt;
+
+    // 生视频模式 (1:首尾帧模式, 2:多图参考模式)
+    @RangeArray(message="随机种子取值有误,范围应是(1, 2)", value = { "1", "2" }, groups = { Update.class })
+    private Integer param_video_reference_type;
+
+    // 参考图 (1~4张)(多图以逗号分隔)
+    private String param_video_reference_images;
+
+    // 图生视频提示词 (生视频时必填)
+    private String image_to_video_prompt;
 
-    private Integer param_video_reference_type;     // 生视频模式 (1:首尾帧模式, 2:多图参考模式)
-    private String param_video_reference_images;    // 参考图 (1~4张)(多图以逗号分隔)
-    private String image_to_video_prompt;           // 图生视频提示词 (生视频时必填)
+    // 生图状态 (-1:未生图, 1:生成中, 2:已生图)
+    private Integer generate_image_status;
 
-    private Integer generate_image_status;          // 生图状态 (-1:未生图, 1:生成中, 2:已生图)
-    private Integer generate_video_status;          // 生视频状态 (-1:未生视频, 1:生成中, 2:已生视频)
+    // 生视频状态 (-1:未生视频, 1:生成中, 2:已生视频)
+    private Integer generate_video_status;
 
-    private String create_time;
-    private String update_time;
+//    private String create_time;
+//    private String update_time;
 
+    @JsonAdapter(LocalDateTimeAdapter.class)
+    private LocalDateTime create_time;
+    @JsonAdapter(LocalDateTimeAdapter.class)
+    private LocalDateTime update_time;
 
 }

+ 1 - 8
src/main/java/com/backendsys/modules/crt/service/impl/CrtDramaProjectStoryboardServiceImpl.java

@@ -50,9 +50,6 @@ public class CrtDramaProjectStoryboardServiceImpl implements CrtDramaProjectStor
         wrapperStoryboard.eq(CrtDramaProjectStoryboard::getEpisode_num, episode_num);
         List<CrtDramaProjectStoryboard> storyboardList = crtDramaProjectStoryboardDao.selectList(wrapperStoryboard);
         if (storyboardList.isEmpty()) throw new CustException("分镜不存在");
-        System.out.println("project_id = " + project_id);
-        System.out.println("episode_num = " + episode_num);
-        System.out.println("storyboardList = " + storyboardList);
 
         // 查询项目设置
         LambdaQueryWrapper<CrtDramaProjectSettings> wrapperSettings = new LambdaQueryWrapper<>();
@@ -119,7 +116,6 @@ public class CrtDramaProjectStoryboardServiceImpl implements CrtDramaProjectStor
 
     /**
      * 编辑分镜
-     *
      */
     @Override
     public Map<String, Object> updateStoryboard(CrtDramaProjectStoryboard crtDramaProjectStoryboard) {
@@ -141,10 +137,7 @@ public class CrtDramaProjectStoryboardServiceImpl implements CrtDramaProjectStor
         // ---------------------------------------------------------------------------
 
         // [DB] 更新分镜
-        // crtDramaProjectStoryboardDao.updateStoryboard(crtDramaProjectStoryboard);
-
-
-
+        crtDramaProjectStoryboardDao.updateStoryboard(crtDramaProjectStoryboard);
 
         return Map.of("drama_project_storyboard_id", crtDramaProjectStoryboard.getDrama_project_storyboard_id());
     }

+ 14 - 53
src/main/resources/mapper/crt/drama/CrtDramaProjectStoryboardDao.xml

@@ -2,9 +2,10 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 <mapper namespace="com.backendsys.modules.crt.dao.CrtDramaProjectStoryboardDao">
 
-
-
-    <!-- 编辑 用户角色 -->
+    <!-- 编辑分镜 -->
+    <!-- { user_id } 用户ID不能改 -->
+    <!-- { drama_project_id, episode_num } 项目ID、集数 不能改 -->
+    <!-- { generate_image_status, generate_video_status } 任务状态 不能改 -->
     <update id="updateStoryboard" parameterType="com.backendsys.modules.crt.entity.CrtDramaProjectStoryboard">
         UPDATE crt_drama_project_storyboard SET
         <trim suffixOverrides="," suffix=" ">
@@ -14,58 +15,18 @@
             <if test="story_scene != null and story_scene != ''">story_scene = #{story_scene},</if>
             <if test="story_weather_time != null and story_weather_time != ''">story_weather_time = #{story_weather_time},</if>
             <if test="lora_figure_ids != null and lora_figure_ids != ''">lora_figure_ids = #{lora_figure_ids},</if>
-<!--            <if test="role_description != null and role_description != ''">role_description = #{role_description},</if>-->
-<!--            <if test="sort != null and sort != ''">sort = #{sort},</if>-->
-<!--            <if test="status != null and status != ''">status = #{status},</if>-->
+            <if test="param_image_count != null and param_image_count != ''">param_image_count = #{param_image_count},</if>
+            <if test="param_prompt_weight != null and param_prompt_weight != ''">param_prompt_weight = #{param_prompt_weight},</if>
+            <if test="param_sampling_method != null and param_sampling_method != ''">param_sampling_method = #{param_sampling_method},</if>
+            <if test="param_step_count != null and param_step_count != ''">param_step_count = #{param_step_count},</if>
+            <if test="param_random_seed != null and param_random_seed != ''">param_random_seed = #{param_random_seed},</if>
+            <if test="param_random_seed_custom != null and param_random_seed_custom != ''">param_random_seed_custom = #{param_random_seed_custom},</if>
+            <if test="text_to_image_prompt != null and text_to_image_prompt != ''">text_to_image_prompt = #{text_to_image_prompt},</if>
+            <if test="param_video_reference_type != null and param_video_reference_type != ''">param_video_reference_type = #{param_video_reference_type},</if>
+            <if test="param_video_reference_images != null and param_video_reference_images != ''">param_video_reference_images = #{param_video_reference_images},</if>
+            <if test="image_to_video_prompt != null and image_to_video_prompt != ''">image_to_video_prompt = #{image_to_video_prompt},</if>
         </trim>
         WHERE id = #{drama_project_storyboard_id}
     </update>
 
-
-
-<!--    <sql id="includeCrtDramaProject">-->
-<!--        p.id,-->
-<!--        p.id drama_project_id,-->
-<!--        p.user_id,-->
-<!--        p.project_name,-->
-<!--        COALESCE(p.drama_lora_style_id, '') drama_lora_style_id,-->
-<!--        COALESCE(p.drama_lora_character_ids, '') drama_lora_character_ids,-->
-<!--        p.create_user_id,-->
-<!--        p.create_time,-->
-<!--        p.update_time-->
-<!--    </sql>-->
-
-<!--    <resultMap id="resultMapCrtDramaProject" type="java.util.LinkedHashMap">-->
-<!--        <id property="id" column="id" jdbcType="BIGINT" />-->
-<!--        <result property="drama_project_id" column="drama_project_id" javaType="java.lang.Long" />-->
-<!--        <result property="user_id" column="user_id" javaType="java.lang.Long" />-->
-<!--        <result property="project_name" column="project_name" />-->
-<!--        <result property="storyboard_episode_nums" column="storyboard_episode_nums" javaType="java.util.List"-->
-<!--                jdbcType="VARCHAR" typeHandler="com.backendsys.config.Mybatis.handler.StringToListTypeHandler" />-->
-<!--        <result property="drama_lora_style_id" column="drama_lora_style_id" javaType="java.lang.Long" />-->
-<!--        <result property="drama_lora_character_ids" column="drama_lora_character_ids" />-->
-<!--        <result property="create_user_id" column="create_user_id" />-->
-<!--        <result property="create_time" column="create_time" />-->
-<!--        <result property="update_time" column="update_time" />-->
-<!--    </resultMap>-->
-
-<!--    &lt;!&ndash; 查 列表 &ndash;&gt;-->
-<!--    <select id="selectCrtDramaProjectList" resultMap="resultMapCrtDramaProject">-->
-<!--        SELECT-->
-<!--            <include refid="includeCrtDramaProject" />,-->
-<!--            GROUP_CONCAT(ps.episode_num ORDER BY ps.episode_num) AS storyboard_episode_nums-->
-<!--        FROM crt_drama_project p-->
-<!--        LEFT JOIN crt_drama_project_storyboard ps ON p.id = ps.drama_project_id-->
-<!--        <where>-->
-<!--            <if test="user_id != null and user_id != ''">-->
-<!--                AND p.user_id = #{user_id}-->
-<!--            </if>-->
-<!--            <if test="project_name != null and project_name != ''">-->
-<!--                AND p.project_name LIKE CONCAT('%', #{project_name}, '%')-->
-<!--            </if>-->
-<!--        </where>-->
-<!--        GROUP BY p.id-->
-<!--        ORDER BY p.create_time DESC-->
-<!--    </select>-->
-
 </mapper>