<?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.ruoyi.project.patrol.dev.mapper.TDevTesterMapper">

    <resultMap type="TDevTester" id="TDevTesterResult">
        <result property="id"    column="id"    />
        <result property="testerType"    column="tester_type"    />
        <result property="testerModel"    column="tester_model"    />
        <result property="testerNo"    column="tester_no"    />
        <result property="status"    column="status"    />
        <result property="remarks"    column="remarks"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createrCode"    column="creater_code"    />
        <result property="createdate"    column="createdate"    />
        <result property="updaterCode"    column="updater_code"    />
        <result property="updatedate"    column="updatedate"    />
        <result property="deptId"    column="dept_id"    />
        <result property="patrolType"    column="patrol_type"    />
    </resultMap>

    <sql id="selectTDevTesterVo">
        select id, tester_type, tester_model, tester_no, status, remarks, del_flag, creater_code, createdate, updater_code, updatedate, dept_id, patrol_type from t_dev_tester
    </sql>

    <select id="selectTDevTesterList" parameterType="TDevTester" resultMap="TDevTesterResult">
        <include refid="selectTDevTesterVo"/>
        <where>
            <if test="testerType != null  and testerType != ''"> and tester_type = #{testerType}</if>
            <if test="testerModel != null  and testerModel != ''"> and tester_model like concat(concat('%', #{testerModel}), '%')</if>
            <if test="testerNo != null  and testerNo != ''"> and tester_no like concat(concat('%', #{testerNo}), '%')</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
            <if test="createrCode != null  and createrCode != ''"> and creater_code = #{createrCode}</if>
            <if test="createdate != null "> and createdate = #{createdate}</if>
            <if test="updaterCode != null  and updaterCode != ''"> and updater_code = #{updaterCode}</if>
            <if test="updatedate != null "> and updatedate = #{updatedate}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="patrolType != null  and patrolType != ''"> and patrol_type = #{patrolType}</if>
            and del_flag=0
        </where>
    </select>

    <select id="selectTDevTesterById" parameterType="Long" resultMap="TDevTesterResult">
        <include refid="selectTDevTesterVo"/>
        where id = #{id}
    </select>

    <insert id="insertTDevTester" parameterType="TDevTester">
        <selectKey keyProperty="id" resultType="long" order="BEFORE">
            SELECT seq_t_dev_tester.NEXTVAL as id FROM DUAL
        </selectKey>
        insert into t_dev_tester
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="testerType != null and testerType != ''">tester_type,</if>
            <if test="testerModel != null and testerModel != ''">tester_model,</if>
            <if test="testerNo != null and testerNo != ''">tester_no,</if>
            <if test="status != null">status,</if>
            <if test="remarks != null">remarks,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createrCode != null">creater_code,</if>
            <if test="createdate != null">createdate,</if>
            <if test="updaterCode != null">updater_code,</if>
            <if test="updatedate != null">updatedate,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="patrolType != null">patrol_type,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="testerType != null and testerType != ''">#{testerType},</if>
            <if test="testerModel != null and testerModel != ''">#{testerModel},</if>
            <if test="testerNo != null and testerNo != ''">#{testerNo},</if>
            <if test="status != null">#{status},</if>
            <if test="remarks != null">#{remarks},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createrCode != null">#{createrCode},</if>
            <if test="createdate != null">#{createdate},</if>
            <if test="updaterCode != null">#{updaterCode},</if>
            <if test="updatedate != null">#{updatedate},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="patrolType != null">#{patrolType},</if>
         </trim>
    </insert>

    <update id="updateTDevTester" parameterType="TDevTester">
        update t_dev_tester
        <trim prefix="SET" suffixOverrides=",">
            <if test="testerType != null and testerType != ''">tester_type = #{testerType},</if>
            <if test="testerModel != null and testerModel != ''">tester_model = #{testerModel},</if>
            <if test="testerNo != null and testerNo != ''">tester_no = #{testerNo},</if>
            <if test="status != null">status = #{status},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createrCode != null">creater_code = #{createrCode},</if>
            <if test="createdate != null">createdate = #{createdate},</if>
            <if test="updaterCode != null">updater_code = #{updaterCode},</if>
            <if test="updatedate != null">updatedate = #{updatedate},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="patrolType != null">patrol_type = #{patrolType},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTDevTesterById" parameterType="Long">
        delete from t_dev_tester where id = #{id}
    </delete>

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