<?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="org.jeecg.modules.bytedance.common.mapper.MaterialImageInfoMapper">

    <insert id="insertSelective" parameterType="org.jeecg.modules.bytedance.common.entity.MaterialImageInfo">
        replace into ctop_material_image_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="code != null">
                code,
            </if>
            <if test="videoId != null">
                video_id,
            </if>
            <if test="materialName != null">
                material_name,
            </if>
            <if test="userId != null">
                user_id,
            </if>
            <if test="auditorId != null">
                auditor_id,
            </if>
            <if test="status != null">
                status,
            </if>

            <if test="width != null">
                width,
            </if>
            <if test="type != null">
                type,
            </if>
            <if test="height != null">
                height,
            </if>
            <if test="size != null">
                size,
            </if>
            <if test="createTime != null">
                create_time,
            </if>
            <if test="updateTime != null">
                update_time,
            </if>
            <if test="url != null">
                url,
            </if>
            <if test="materialDescribe != null">
                material_describe,
            </if>
            <if test="refuseReason != null">
                refuse_reason,
            </if>
            <if test="refuseFile != null">
                refuse_file,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=VARCHAR},
            </if>
            <if test="code != null">
                #{code,jdbcType=VARCHAR},
            </if>
            <if test="videoId != null">
                #{videoId,jdbcType=VARCHAR},
            </if>
            <if test="materialName != null">
                #{materialName,jdbcType=VARCHAR},
            </if>
            <if test="userId != null">
                #{userId,jdbcType=VARCHAR},
            </if>
            <if test="auditorId != null">
                #{auditorId,jdbcType=VARCHAR},
            </if>
            <if test="status != null">
                #{status,jdbcType=INTEGER},
            </if>

            <if test="width != null">
                #{width,jdbcType=VARCHAR},
            </if>
            <if test="type != null">
                #{type,jdbcType=VARCHAR},
            </if>
            <if test="height != null">
                #{height,jdbcType=VARCHAR},
            </if>
            <if test="size != null">
                #{size,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateTime != null">
                #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="url != null">
                #{url},
            </if>
            <if test="materialDescribe != null">
                #{materialDescribe},
            </if>
            <if test="refuseReason != null">
                #{refuseReason},
            </if>
            <if test="refuseFile != null">
                #{refuseFile},
            </if>
        </trim>
    </insert>


    <select id="getCodeList" resultType="java.lang.String">

     SELECT DISTINCT(code)  from  ctop_material_image_info
    </select>

    <select id="getUrlList" resultType="com.alibaba.fastjson.JSONObject">

        SELECT t.url as 'imageUrl',t.`code` as 'signature'  from (
        SELECT url,`code` from ctop_material_image_info
        WHERE video_id = #{videoId}
        UNION ALL
        SELECT url,signature  from ctop_material_cut_frame WHERE video_signature = #{videoId}
        ) t

    </select>

</mapper>
