<?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.zehong.system.mapper.TSupervisorInfoMapper">
    
    <resultMap type="TSupervisorInfo" id="TSupervisorInfoResult">
        <result property="supervisorId"    column="supervisor_id"    />
        <result property="workId"    column="work_id"    />
        <result property="supervisorContent"    column="supervisor_content"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="isDel"    column="is_del"    />
        <result property="remarks"    column="remarks"    />
    </resultMap>

    <sql id="selectTSupervisorInfoVo">
        select supervisor_id, work_id, supervisor_content, create_by, create_time, is_del, remarks from t_supervisor_info
    </sql>

    <select id="selectTSupervisorInfoList" parameterType="TSupervisorInfo" resultMap="TSupervisorInfoResult">
        <include refid="selectTSupervisorInfoVo"/>
        <where>  
            <if test="workId != null "> and work_id = #{workId}</if>
            <if test="supervisorContent != null  and supervisorContent != ''"> and supervisor_content = #{supervisorContent}</if>
            <if test="isDel != null  and isDel != ''"> and is_del = #{isDel}</if>
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
        </where>
    </select>
    
    <select id="selectTSupervisorInfoById" parameterType="Long" resultMap="TSupervisorInfoResult">
        <include refid="selectTSupervisorInfoVo"/>
        where supervisor_id = #{supervisorId}
    </select>
        
    <insert id="insertTSupervisorInfo" parameterType="TSupervisorInfo" useGeneratedKeys="true" keyProperty="supervisorId">
        insert into t_supervisor_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="workId != null">work_id,</if>
            <if test="supervisorContent != null">supervisor_content,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="isDel != null">is_del,</if>
            <if test="remarks != null">remarks,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="workId != null">#{workId},</if>
            <if test="supervisorContent != null">#{supervisorContent},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="remarks != null">#{remarks},</if>
         </trim>
    </insert>

    <update id="updateTSupervisorInfo" parameterType="TSupervisorInfo">
        update t_supervisor_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="workId != null">work_id = #{workId},</if>
            <if test="supervisorContent != null">supervisor_content = #{supervisorContent},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
        </trim>
        where supervisor_id = #{supervisorId}
    </update>

    <delete id="deleteTSupervisorInfoById" parameterType="Long">
        delete from t_supervisor_info where supervisor_id = #{supervisorId}
    </delete>

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