<?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.flossom.common.core.mapper.WxClockInstrumentLogMapper">
    
    <resultMap type="WxClockInstrumentLog" id="WxClockInstrumentLogResult">
        <result property="id"    column="id"    />
        <result property="userId"    column="user_id"    />
        <result property="instrumentId"    column="instrument_id"    />
        <result property="instrumentName"    column="instrument_name"    />
        <result property="status"    column="status"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectWxClockInstrumentLogVo">
        select id, user_id, instrument_id, instrument_name, status, create_by, create_time from wx_clock_instrument_log
    </sql>

    <select id="selectWxClockInstrumentLogList" parameterType="WxClockInstrumentLog" resultMap="WxClockInstrumentLogResult">
        <include refid="selectWxClockInstrumentLogVo"/>
        <where>  
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="instrumentId != null "> and instrument_id = #{instrumentId}</if>
            <if test="instrumentName != null  and instrumentName != ''"> and instrument_name like concat('%', #{instrumentName}, '%')</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="params != null and params.beginTime != null">
                and create_time &gt;= #{params.beginTime}
            </if>
            <if test="params != null and params.endTime != null">
                and create_time &lt;= #{params.endTime}
            </if>
        </where>
    </select>
    
    <select id="selectWxClockInstrumentLogById" parameterType="Long" resultMap="WxClockInstrumentLogResult">
        <include refid="selectWxClockInstrumentLogVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertWxClockInstrumentLog" parameterType="WxClockInstrumentLog" useGeneratedKeys="true" keyProperty="id">
        insert into wx_clock_instrument_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null">user_id,</if>
            <if test="instrumentId != null">instrument_id,</if>
            <if test="instrumentName != null">instrument_name,</if>
            <if test="status != null">status,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="userId != null">#{userId},</if>
            <if test="instrumentId != null">#{instrumentId},</if>
            <if test="instrumentName != null">#{instrumentName},</if>
            <if test="status != null">#{status},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateWxClockInstrumentLog" parameterType="WxClockInstrumentLog">
        update wx_clock_instrument_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">user_id = #{userId},</if>
            <if test="instrumentId != null">instrument_id = #{instrumentId},</if>
            <if test="instrumentName != null">instrument_name = #{instrumentName},</if>
            <if test="status != null">status = #{status},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteWxClockInstrumentLogById" parameterType="Long">
        delete from wx_clock_instrument_log where id = #{id}
    </delete>

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