<?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.yanzhu.jh.video.mapper.SurProjectPhotographyMapper">
    
    <resultMap type="SurProjectPhotography" id="SurProjectPhotographyResult">
        <result property="id"    column="id"    />
        <result property="projectId"    column="project_id"    />
        <result property="imageUrl"    column="image_url"    />
        <result property="videoUrl"    column="video_url"    />
        <result property="videoDate"    column="video_date"    />
        <result property="state"    column="state"    />
        <result property="remark"    column="remark"    />
        <result property="isDel"    column="is_del"    />
        <result property="createBy"    column="create_by"    />
        <result property="createDate"    column="create_date"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateDate"    column="update_date"    />
    </resultMap>

    <sql id="selectSurProjectPhotographyVo">
        select id, project_id, image_url, video_url, video_date, state, remark, is_del, create_by, create_date, update_by, update_date from sur_project_photography
    </sql>

    <select id="selectSurProjectPhotographyList" parameterType="SurProjectPhotography" resultMap="SurProjectPhotographyResult">
        <include refid="selectSurProjectPhotographyVo"/>
        <where>  
            <if test="projectId != null "> and project_id = #{projectId}</if>
            <if test="imageUrl != null  and imageUrl != ''"> and image_url = #{imageUrl}</if>
            <if test="videoUrl != null  and videoUrl != ''"> and video_url = #{videoUrl}</if>
            <if test="videoDate != null "> and video_date = #{videoDate}</if>
            <if test="state != null "> and state = #{state}</if>
            <if test="isDel != null "> and is_del = #{isDel}</if>
            <if test="createDate != null "> and create_date = #{createDate}</if>
            <if test="updateDate != null "> and update_date = #{updateDate}</if>
        </where>
        order by video_date
    </select>
    
    <select id="selectSurProjectPhotographyById" parameterType="Long" resultMap="SurProjectPhotographyResult">
        <include refid="selectSurProjectPhotographyVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertSurProjectPhotography" parameterType="SurProjectPhotography" useGeneratedKeys="true" keyProperty="id">
        insert into sur_project_photography
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="projectId != null">project_id,</if>
            <if test="imageUrl != null">image_url,</if>
            <if test="videoUrl != null">video_url,</if>
            <if test="videoDate != null">video_date,</if>
            <if test="state != null">state,</if>
            <if test="remark != null">remark,</if>
            <if test="isDel != null">is_del,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createDate != null">create_date,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateDate != null">update_date,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="projectId != null">#{projectId},</if>
            <if test="imageUrl != null">#{imageUrl},</if>
            <if test="videoUrl != null">#{videoUrl},</if>
            <if test="videoDate != null">#{videoDate},</if>
            <if test="state != null">#{state},</if>
            <if test="remark != null">#{remark},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createDate != null">#{createDate},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateDate != null">#{updateDate},</if>
         </trim>
    </insert>

    <update id="updateSurProjectPhotography" parameterType="SurProjectPhotography">
        update sur_project_photography
        <trim prefix="SET" suffixOverrides=",">
            <if test="projectId != null">project_id = #{projectId},</if>
            <if test="imageUrl != null">image_url = #{imageUrl},</if>
            <if test="videoUrl != null">video_url = #{videoUrl},</if>
            <if test="videoDate != null">video_date = #{videoDate},</if>
            <if test="state != null">state = #{state},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createDate != null">create_date = #{createDate},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateDate != null">update_date = #{updateDate},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSurProjectPhotographyById" parameterType="Long">
        delete from sur_project_photography where id = #{id}
    </delete>

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