<?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.cyl.manager.staff.mapper.StaffImageMapper">
    
    <resultMap type="StaffImage" id="StaffImageResult">
        <result property="id"    column="id"    />
        <result property="staffId"    column="staff_id"    />
        <result property="url"    column="url"    />
        <result property="orderNumber"    column="order_number"    />
        <result property="delFlag"    column="del_flag"    />
        <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="selectStaffImageVo">
        select id, staff_id, url, order_number, del_flag, create_by, create_time, update_by, update_time from staff_image
    </sql>

    <select id="selectStaffImageList" parameterType="StaffImage" resultMap="StaffImageResult">
        <include refid="selectStaffImageVo"/>
        <where>  
            <if test="staffId != null "> and staff_id = #{staffId}</if>
            <if test="url != null  and url != ''"> and url = #{url}</if>
            <if test="orderNumber != null "> and order_number = #{orderNumber}</if>
        </where>
    </select>
    
    <select id="selectStaffImageById" parameterType="Long" resultMap="StaffImageResult">
        <include refid="selectStaffImageVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertStaffImage" parameterType="StaffImage" useGeneratedKeys="true" keyProperty="id">
        insert into staff_image
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="staffId != null">staff_id,</if>
            <if test="url != null">url,</if>
            <if test="orderNumber != null">order_number,</if>
            <if test="delFlag != null">del_flag,</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="staffId != null">#{staffId},</if>
            <if test="url != null">#{url},</if>
            <if test="orderNumber != null">#{orderNumber},</if>
            <if test="delFlag != null">#{delFlag},</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="updateStaffImage" parameterType="StaffImage">
        update staff_image
        <trim prefix="SET" suffixOverrides=",">
            <if test="staffId != null">staff_id = #{staffId},</if>
            <if test="url != null">url = #{url},</if>
            <if test="orderNumber != null">order_number = #{orderNumber},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</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="deleteStaffImageById" parameterType="Long">
        delete from staff_image where id = #{id}
    </delete>

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