<?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.ruoyi.base.mapper.RobotOpsMediaAssetMapper">

    <resultMap type="RobotOpsMediaAsset" id="RobotOpsMediaAssetResult">
        <result property="id"    column="id"    />
        <result property="assetName"    column="asset_name"    />
        <result property="assetType"    column="asset_type"    />
        <result property="fileUrl"    column="file_url"    />
        <result property="thumbnailUrl"    column="thumbnail_url"    />
        <result property="fileSize"    column="file_size"    />
        <result property="fileFormat"    column="file_format"    />
        <result property="mimeType"    column="mime_type"    />
        <result property="durationSeconds"    column="duration_seconds"    />
        <result property="resolution"    column="resolution"    />
        <result property="status"    column="status"    />
        <result property="quotedFlag"    column="quoted_flag"    />
        <result property="remark"    column="remark"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectRobotOpsMediaAssetVo">
        select id, asset_name, asset_type, file_url, thumbnail_url, file_size, file_format, mime_type, duration_seconds, resolution, status, quoted_flag, remark, create_by, create_time, update_by, update_time from robot_ops_media_asset
    </sql>

    <select id="selectRobotOpsMediaAssetList" parameterType="RobotOpsMediaAsset" resultMap="RobotOpsMediaAssetResult">
        <include refid="selectRobotOpsMediaAssetVo"/>
        <where>
            <if test="assetName != null  and assetName != ''"> and asset_name like concat('%', #{assetName}, '%')</if>
            <if test="assetType != null  and assetType != ''"> and asset_type = #{assetType}</if>
            <if test="mimeType != null  and mimeType != ''"> and mime_type = #{mimeType}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="quotedFlag != null  and quotedFlag != ''"> and quoted_flag = #{quotedFlag}</if>
            <if test="params.beginCreateTime != null and params.beginCreateTime != ''">
                and date_format(create_time,'%Y%m%d') &gt;= date_format(#{params.beginCreateTime},'%Y%m%d')
            </if>
            <if test="params.endCreateTime != null and params.endCreateTime != ''">
                and date_format(create_time,'%Y%m%d') &lt;= date_format(#{params.endCreateTime},'%Y%m%d')
            </if>
        </where>
    </select>

    <select id="selectRobotOpsMediaAssetById" parameterType="Long" resultMap="RobotOpsMediaAssetResult">
        <include refid="selectRobotOpsMediaAssetVo"/>
        where id = #{id}
    </select>

    <insert id="insertRobotOpsMediaAsset" parameterType="RobotOpsMediaAsset" useGeneratedKeys="true" keyProperty="id">
        insert into robot_ops_media_asset
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="assetName != null and assetName != ''">asset_name,</if>
            <if test="assetType != null and assetType != ''">asset_type,</if>
            <if test="fileUrl != null and fileUrl != ''">file_url,</if>
            <if test="thumbnailUrl != null">thumbnail_url,</if>
            <if test="fileSize != null">file_size,</if>
            <if test="fileFormat != null">file_format,</if>
            <if test="mimeType != null">mime_type,</if>
            <if test="durationSeconds != null">duration_seconds,</if>
            <if test="resolution != null">resolution,</if>
            <if test="status != null and status != ''">status,</if>
            <if test="quotedFlag != null and quotedFlag != ''">quoted_flag,</if>
            <if test="remark != null">remark,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="assetName != null and assetName != ''">#{assetName},</if>
            <if test="assetType != null and assetType != ''">#{assetType},</if>
            <if test="fileUrl != null and fileUrl != ''">#{fileUrl},</if>
            <if test="thumbnailUrl != null">#{thumbnailUrl},</if>
            <if test="fileSize != null">#{fileSize},</if>
            <if test="fileFormat != null">#{fileFormat},</if>
            <if test="mimeType != null">#{mimeType},</if>
            <if test="durationSeconds != null">#{durationSeconds},</if>
            <if test="resolution != null">#{resolution},</if>
            <if test="status != null and status != ''">#{status},</if>
            <if test="quotedFlag != null and quotedFlag != ''">#{quotedFlag},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateRobotOpsMediaAsset" parameterType="RobotOpsMediaAsset">
        update robot_ops_media_asset
        <trim prefix="SET" suffixOverrides=",">
            <if test="assetName != null and assetName != ''">asset_name = #{assetName},</if>
            <if test="assetType != null and assetType != ''">asset_type = #{assetType},</if>
            <if test="fileUrl != null and fileUrl != ''">file_url = #{fileUrl},</if>
            <if test="thumbnailUrl != null">thumbnail_url = #{thumbnailUrl},</if>
            <if test="fileSize != null">file_size = #{fileSize},</if>
            <if test="fileFormat != null">file_format = #{fileFormat},</if>
            <if test="mimeType != null">mime_type = #{mimeType},</if>
            <if test="durationSeconds != null">duration_seconds = #{durationSeconds},</if>
            <if test="resolution != null">resolution = #{resolution},</if>
            <if test="status != null and status != ''">status = #{status},</if>
            <if test="quotedFlag != null and quotedFlag != ''">quoted_flag = #{quotedFlag},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteRobotOpsMediaAssetById" parameterType="Long">
        delete from robot_ops_media_asset where id = #{id}
    </delete>

    <delete id="deleteRobotOpsMediaAssetByIds" parameterType="String">
        delete from robot_ops_media_asset where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>
