<?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.WxInstrumentSerialLogMapper">
    
    <resultMap type="WxInstrumentSerialLog" id="WxInstrumentSerialLogResult">
        <result property="id"    column="id"    />
        <result property="userId"    column="user_id"    />
        <result property="userName"    column="user_name"    />
        <result property="userMobile"    column="user_mobile"    />
        <result property="userHeadimg"    column="user_headimg"    />
        <result property="instrumentId"    column="instrument_id"    />
        <result property="instrumentName"    column="instrument_name"    />
        <result property="serial"    column="serial"    />
        <result property="bindingStatus"    column="binding_status"    />
        <result property="status"    column="status"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectWxInstrumentSerialLogVo">
        select id, user_id, user_name, user_mobile, user_headimg, instrument_id, instrument_name, serial, binding_status, status, create_by, create_time, remark from wx_instrument_serial_log
    </sql>

    <select id="selectWxInstrumentSerialLogList" parameterType="WxInstrumentSerialLog" resultMap="WxInstrumentSerialLogResult">
        <include refid="selectWxInstrumentSerialLogVo"/>
        <where>  
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="userName != null  and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
            <if test="userMobile != null  and userMobile != ''"> and user_mobile = #{userMobile}</if>
            <if test="userHeadimg != null  and userHeadimg != ''"> and user_headimg = #{userHeadimg}</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="serial != null  and serial != ''"> and serial = #{serial}</if>
            <if test="bindingStatus != null "> and binding_status = #{bindingStatus}</if>
            <if test="status != null "> and status = #{status}</if>
        </where>
    </select>
    
    <select id="selectWxInstrumentSerialLogById" parameterType="Long" resultMap="WxInstrumentSerialLogResult">
        <include refid="selectWxInstrumentSerialLogVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertWxInstrumentSerialLog" parameterType="WxInstrumentSerialLog" useGeneratedKeys="true" keyProperty="id">
        insert into wx_instrument_serial_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null">user_id,</if>
            <if test="userName != null">user_name,</if>
            <if test="userMobile != null">user_mobile,</if>
            <if test="userHeadimg != null">user_headimg,</if>
            <if test="instrumentId != null">instrument_id,</if>
            <if test="instrumentName != null and instrumentName != ''">instrument_name,</if>
            <if test="serial != null and serial != ''">serial,</if>
            <if test="bindingStatus != null">binding_status,</if>
            <if test="status != null">status,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="userId != null">#{userId},</if>
            <if test="userName != null">#{userName},</if>
            <if test="userMobile != null">#{userMobile},</if>
            <if test="userHeadimg != null">#{userHeadimg},</if>
            <if test="instrumentId != null">#{instrumentId},</if>
            <if test="instrumentName != null and instrumentName != ''">#{instrumentName},</if>
            <if test="serial != null and serial != ''">#{serial},</if>
            <if test="bindingStatus != null">#{bindingStatus},</if>
            <if test="status != null">#{status},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateWxInstrumentSerialLog" parameterType="WxInstrumentSerialLog">
        update wx_instrument_serial_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">user_id = #{userId},</if>
            <if test="userName != null">user_name = #{userName},</if>
            <if test="userMobile != null">user_mobile = #{userMobile},</if>
            <if test="userHeadimg != null">user_headimg = #{userHeadimg},</if>
            <if test="instrumentId != null">instrument_id = #{instrumentId},</if>
            <if test="instrumentName != null and instrumentName != ''">instrument_name = #{instrumentName},</if>
            <if test="serial != null and serial != ''">serial = #{serial},</if>
            <if test="bindingStatus != null">binding_status = #{bindingStatus},</if>
            <if test="status != null">status = #{status},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteWxInstrumentSerialLogById" parameterType="Long">
        delete from wx_instrument_serial_log where id = #{id}
    </delete>

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