<?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.ygtx.gxt.mapper.GxtUserOperatorHistoryMapper">

    <resultMap type="GxtUserOperatorHistory" id="GxtUserOperatorHistoryResult">
        <result property="id"    column="id"    />
        <result property="opType"    column="op_type"    />
        <result property="opUserid"    column="op_userid"    />
        <result property="opNum"    column="op_num"    />
        <result property="status"    column="status"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
        <result property="opTicket"    column="op_ticket"    />
        <result property="opLeaderId"    column="op_leader_id"    />
        <result property="opLeaderName"    column="op_leader_name"    />
    </resultMap>

    <sql id="selectGxtUserOperatorHistoryVo">
        select id, op_type, op_userid, op_num, status, create_by, create_time, update_by, update_time, remark, op_ticket, op_leader_id, op_leader_name from gxt_user_operator_history
    </sql>

    <select id="selectGxtUserOperatorHistoryList" parameterType="GxtUserOperatorHistory" resultMap="GxtUserOperatorHistoryResult">
        <include refid="selectGxtUserOperatorHistoryVo"/>
        <where>
            <if test="opType != null  and opType != ''"> and op_type = #{opType}</if>
            <if test="opUserid != null "> and op_userid = #{opUserid}</if>
            <if test="opNum != null "> and op_num = #{opNum}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="opTicket != null  and opTicket != ''"> and op_ticket = #{opTicket}</if>
            <if test="opLeaderId != null  and opLeaderId != ''"> and op_leader_id = #{opLeaderId}</if>
            <if test="opLeaderName != null  and opLeaderName != ''"> and op_leader_name like concat('%', #{opLeaderName}, '%')</if>
        </where>
        order by op_num desc,update_time desc
    </select>

    <select id="selectGxtUserOperatorHistoryById" parameterType="Long" resultMap="GxtUserOperatorHistoryResult">
        <include refid="selectGxtUserOperatorHistoryVo"/>
        where id = #{id}
    </select>

    <insert id="insertGxtUserOperatorHistory" parameterType="GxtUserOperatorHistory" useGeneratedKeys="true" keyProperty="id">
        insert into gxt_user_operator_history
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="opType != null">op_type,</if>
            <if test="opUserid != null">op_userid,</if>
            <if test="opNum != null">op_num,</if>
            <if test="status != null">status,</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>
            <if test="remark != null">remark,</if>
            <if test="opTicket != null">op_ticket,</if>
            <if test="opLeaderId != null">op_leader_id,</if>
            <if test="opLeaderName != null">op_leader_name,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="opType != null">#{opType},</if>
            <if test="opUserid != null">#{opUserid},</if>
            <if test="opNum != null">#{opNum},</if>
            <if test="status != null">#{status},</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>
            <if test="remark != null">#{remark},</if>
            <if test="opTicket != null">#{opTicket},</if>
            <if test="opLeaderId != null">#{opLeaderId},</if>
            <if test="opLeaderName != null">#{opLeaderName},</if>
         </trim>
    </insert>

    <update id="updateGxtUserOperatorHistory" parameterType="GxtUserOperatorHistory">
        update gxt_user_operator_history
        <trim prefix="SET" suffixOverrides=",">
            <if test="opType != null">op_type = #{opType},</if>
            <if test="opUserid != null">op_userid = #{opUserid},</if>
            <if test="opNum != null">op_num = #{opNum},</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="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="opTicket != null">op_ticket = #{opTicket},</if>
            <if test="opLeaderId != null">op_leader_id = #{opLeaderId},</if>
            <if test="opLeaderName != null">op_leader_name = #{opLeaderName},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteGxtUserOperatorHistoryById" parameterType="Long">
        delete from gxt_user_operator_history where id = #{id}
    </delete>

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