<?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.playlet.system.mapper.PlayletRealizationProjectMapper">

    <resultMap type="PlayletRealizationProject" id="PlayletRealizationProjectResult">
        <result property="id"    column="ID"    />
        <result property="name"    column="NAME"    />
        <result property="type"    column="TYPE"    />
        <result property="imgUrl"    column="IMG_URL"    />
        <result property="detailVideoUrl"    column="DETAIL_VIDEO_URL"    />
        <result property="detailContent"    column="DETAIL_CONTENT"    />
        <result property="relativeUrl"    column="RELATIVE_URL"    />
        <result property="createBy"    column="CREATE_BY"    />
        <result property="createTime"    column="CREATE_TIME"    />
        <result property="updateBy"    column="UPDATE_BY"    />
        <result property="updateTime"    column="UPDATE_TIME"    />
        <result property="remark"    column="REMARK"    />
    </resultMap>

    <sql id="selectPlayletRealizationProjectVo">
        select ID, NAME, TYPE, IMG_URL, DETAIL_VIDEO_URL, DETAIL_CONTENT, RELATIVE_URL, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME, REMARK from playlet_realization_project
    </sql>

    <select id="selectPlayletRealizationProjectList" parameterType="PlayletRealizationProject" resultMap="PlayletRealizationProjectResult">
        <include refid="selectPlayletRealizationProjectVo"/>
        <where>
            <if test="name != null  and name != ''"> and NAME like concat('%', #{name}, '%')</if>
            <if test="type != null  and type != ''"> and TYPE = #{type}</if>
            <if test="imgUrl != null  and imgUrl != ''"> and IMG_URL = #{imgUrl}</if>
            <if test="detailVideoUrl != null  and detailVideoUrl != ''"> and DETAIL_VIDEO_URL = #{detailVideoUrl}</if>
            <if test="detailContent != null  and detailContent != ''"> and DETAIL_CONTENT = #{detailContent}</if>
            <if test="relativeUrl != null  and relativeUrl != ''"> and RELATIVE_URL = #{relativeUrl}</if>
            <if test="createBy != null  and createBy != ''"> and CREATE_BY = #{createBy}</if>
            <if test="createTime != null "> and CREATE_TIME = #{createTime}</if>
            <if test="updateBy != null  and updateBy != ''"> and UPDATE_BY = #{updateBy}</if>
            <if test="updateTime != null "> and UPDATE_TIME = #{updateTime}</if>
            <if test="remark != null  and remark != ''"> and REMARK = #{remark}</if>
        </where>
    </select>

    <select id="selectPlayletRealizationProjectById" parameterType="Long" resultMap="PlayletRealizationProjectResult">
        <include refid="selectPlayletRealizationProjectVo"/>
        where ID = #{id}
    </select>

    <insert id="insertPlayletRealizationProject" parameterType="PlayletRealizationProject" useGeneratedKeys="true" keyProperty="id">
        insert into playlet_realization_project
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null">NAME,</if>
            <if test="type != null">TYPE,</if>
            <if test="imgUrl != null">IMG_URL,</if>
            <if test="detailVideoUrl != null">DETAIL_VIDEO_URL,</if>
            <if test="detailContent != null">DETAIL_CONTENT,</if>
            <if test="relativeUrl != null">RELATIVE_URL,</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>
            <if test="remark != null">REMARK,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null">#{name},</if>
            <if test="type != null">#{type},</if>
            <if test="imgUrl != null">#{imgUrl},</if>
            <if test="detailVideoUrl != null">#{detailVideoUrl},</if>
            <if test="detailContent != null">#{detailContent},</if>
            <if test="relativeUrl != null">#{relativeUrl},</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>
            <if test="remark != null">#{remark},</if>
        </trim>
    </insert>

    <update id="updatePlayletRealizationProject" parameterType="PlayletRealizationProject">
        update playlet_realization_project
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">NAME = #{name},</if>
            <if test="type != null">TYPE = #{type},</if>
            <if test="imgUrl != null">IMG_URL = #{imgUrl},</if>
            <if test="detailVideoUrl != null">DETAIL_VIDEO_URL = #{detailVideoUrl},</if>
            <if test="detailContent != null">DETAIL_CONTENT = #{detailContent},</if>
            <if test="relativeUrl != null">RELATIVE_URL = #{relativeUrl},</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>
            <if test="remark != null">REMARK = #{remark},</if>
        </trim>
        where ID = #{id}
    </update>

    <delete id="deletePlayletRealizationProjectById" parameterType="Long">
        delete from playlet_realization_project where ID = #{id}
    </delete>

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

</mapper>