<?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.media.dao.MediaTtvDao">

<!--    <sql id="includeAiGenerateVideo">-->
<!--        id,-->
<!--        user_id,-->
<!--        job_id,-->
<!--        job_status,-->
<!--        title,-->
<!--        COALESCE(request_params, '') request_params,-->
<!--        COALESCE(response_params, '') response_params,-->
<!--        COALESCE(video_origin_url, '') video_origin_url,-->
<!--        COALESCE(video_url, '') video_url,-->
<!--        create_time,-->
<!--        update_time-->
<!--    </sql>-->

<!--    <resultMap id="resultMapAiGenerateVideo" type="java.util.LinkedHashMap">-->
<!--        <id property="id" column="id" jdbcType="BIGINT" />-->
<!--        <result property="user_id" column="user_id" javaType="java.lang.Long" />-->
<!--        <result property="job_id" column="job_id" />-->
<!--        <result property="job_status" column="job_status" javaType="java.lang.Integer" />-->
<!--        <result property="title" column="title" />-->
<!--        <result property="request_params" column="request_params" />-->
<!--        <result property="response_params" column="response_params" />-->
<!--        <result property="video_origin_url" column="video_origin_url" />-->
<!--        <result property="video_url" column="video_url" />-->
<!--        <result property="create_time" column="create_time" />-->
<!--        <result property="update_time" column="update_time" />-->
<!--    </resultMap>-->

    <!-- 列表 -->
<!--    <select id="queryAiGenerateVideoList" resultMap="resultMapAiGenerateVideo">-->
<!--        SELECT <include refid="includeAiGenerateVideo" />-->
<!--        FROM ai_generate_video_task-->
<!--        <where>-->
<!--            user_id = #{user_id}-->
<!--            <if test="job_id != null and job_id != ''">-->
<!--                AND job_id = #{job_id}-->
<!--            </if>-->
<!--            <if test="title != null and title != ''">-->
<!--                AND title LIKE CONCAT('%', #{title}, '%')-->
<!--            </if>-->
<!--            <if test="product_type != null and product_type != ''">-->
<!--                AND product_type = #{product_type}-->
<!--            </if>-->
<!--            <if test="job_status != null and job_status != ''">-->
<!--                AND job_status = #{job_status}-->
<!--            </if>-->
<!--        </where>-->
<!--        ORDER BY create_time DESC-->
<!--    </select>-->

    <!-- 详情 -->
<!--    <select id="queryAiGenerateVideoDetail" resultMap="resultMapAiGenerateVideo">-->
<!--        SELECT <include refid="includeAiGenerateVideo" />-->
<!--        FROM ai_generate_video_task-->
<!--        WHERE job_id = #{job_id} AND user_id = #{user_id}-->
<!--    </select>-->

    <!-- 插入 -->
<!--    <insert id="insertAiGenerateVideo" parameterType="com.backendsys.entity.Ai.AiGenerateVideoDTO"-->
<!--        useGeneratedKeys="true" keyProperty="job_id">-->
<!--        INSERT INTO ai_generate_video_task (-->
<!--            user_id, job_id, title, source, product_type, resolution-->
<!--            <if test="tts_per != null and tts_per != ''">, tts_per</if>-->
<!--            <if test="bg_music_url != null and bg_music_url != ''">, bg_music_url</if>-->
<!--            <if test="video_begin_url != null and video_begin_url != ''">, video_begin_url</if>-->
<!--            <if test="video_end_url != null and video_end_url != ''">, video_end_url</if>-->
<!--            <if test="video_logo_url != null and video_logo_url != ''">, video_logo_url</if>-->
<!--            <if test="video_logo_location != null and video_logo_location != ''">, video_logo_location</if>-->
<!--            <if test="video_logo_margin != null and video_logo_margin != ''">, video_logo_margin</if>-->
<!--            <if test="job_status != null and job_status != ''">, job_status</if>-->
<!--        )-->
<!--        VALUES (-->
<!--            #{user_id}, #{job_id}, #{title}, #{source}, #{product_type}, #{resolutionString}-->
<!--            <if test="tts_per != null and tts_per != ''">, #{tts_per}</if>-->
<!--            <if test="bg_music_url != null and bg_music_url != ''">, #{bg_music_url}</if>-->
<!--            <if test="video_begin_url != null and video_begin_url != ''">, #{video_begin_url}</if>-->
<!--            <if test="video_end_url != null and video_end_url != ''">, #{video_end_url}</if>-->
<!--            <if test="video_logo_url != null and video_logo_url != ''">, #{video_logo_url}</if>-->
<!--            <if test="video_logo_location != null and video_logo_location != ''">, #{video_logo_location}</if>-->
<!--            <if test="video_logo_margin != null and video_logo_margin != ''">, #{video_logo_margin}</if>-->
<!--            <if test="job_status != null and job_status != ''">, #{job_status}</if>-->
<!--        )-->
<!--    </insert>-->

    <!-- 更新 -->
<!--    <update id="updateAiGenerateVideo" parameterType="com.backendsys.entity.Ai.AiGenerateVideoDTO"-->
<!--        useGeneratedKeys="true" keyProperty="job_id">-->
<!--        UPDATE ai_generate_video_task-->
<!--        SET job_status = #{job_status}-->
<!--            <if test="result_video_url != null and result_video_url != ''">, result_video_url = #{result_video_url}</if>-->
<!--            <if test="result_points != null and result_points != ''">, result_points = #{result_points}</if>-->
<!--            <if test="result_basic_duration != null and result_basic_duration != ''">, result_basic_duration = #{result_basic_duration}</if>-->
<!--            <if test="result_fail_reason != null and result_fail_reason != ''">, result_fail_reason = #{result_fail_reason}</if>-->
<!--        WHERE job_id = #{job_id} AND user_id = #{user_id}-->
<!--    </update>-->

<!--    <delete id="deleteAiGenerateVideo">-->
<!--        DELETE FROM ai_generate_video_task WHERE job_id = #{job_id} AND user_id = #{user_id}-->
<!--    </delete>-->

</mapper>