<?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.siwei.rsmonitoring.mapper.TDkFieldworkLogMapper">
    
    <resultMap type="TDkFieldworkLog" id="TDkFieldworkLogResult">
        <result property="id"    column="id"    />
        <result property="fieldworId"    column="fieldwor_id"    />
        <result property="stepState"    column="step_state"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="auditflowId"    column="auditflow_id"    />
    </resultMap>

    <sql id="selectTDkFieldworkLogVo">
        select id, fieldwor_id, step_state, create_by, create_time, auditflow_id from t_dk_fieldwork_log
    </sql>

    <select id="selectTDkFieldworkLogList" parameterType="TDkFieldworkLog" resultMap="TDkFieldworkLogResult">
        <include refid="selectTDkFieldworkLogVo"/>
        <where>  
            <if test="fieldworId != null  and fieldworId != ''"> and fieldwor_id = #{fieldworId}</if>
            <if test="stepState != null  and stepState != ''"> and step_state = #{stepState}</if>
            <if test="auditflowId != null  and auditflowId != ''"> and auditflow_id = #{auditflowId}</if>
        </where>
    </select>
    
    <select id="selectTDkFieldworkLogById" parameterType="String" resultMap="TDkFieldworkLogResult">
        <include refid="selectTDkFieldworkLogVo"/>
        where id = #{id}
    </select>

    <insert id="insertTDkFieldworkLog" parameterType="TDkFieldworkLog">
        insert into t_dk_fieldwork_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null and id != ''">id,</if>
            <if test="fieldworId != null and fieldworId != ''">fieldwor_id,</if>
            <if test="stepState != null">step_state,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="auditflowId != null  and auditflowId != ''">auditflow_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null and id != ''">#{id},</if>
            <if test="fieldworId != null and fieldworId != ''">#{fieldworId},</if>
            <if test="stepState != null">#{stepState},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="auditflowId != null  and auditflowId != ''">#{auditflowId},</if>
         </trim>
    </insert>

    <update id="updateTDkFieldworkLog" parameterType="TDkFieldworkLog">
        update t_dk_fieldwork_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="fieldworId != null and fieldworId != ''">fieldwor_id = #{fieldworId},</if>
            <if test="stepState != null">step_state = #{stepState},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="auditflowId != null  and auditflowId != ''">auditflow_id = #{auditflowId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTDkFieldworkLogById" parameterType="String">
        delete from t_dk_fieldwork_log where id = #{id}
    </delete>

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