<?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.sy.mapper.SyTestSelectCategoryMapper">
    
    <resultMap type="SyTestSelectCategory" id="SyTestSelectCategoryResult">
        <result property="id"    column="id"    />
        <result property="examineeId"    column="examinee_id"    />
        <result property="customerCode"    column="customer_code"    />
        <result property="majorCategoryCode"    column="major_category_code"    />
        <result property="state"    column="state"    />
        <result property="ranking"    column="ranking"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectSyTestSelectCategoryVo">
        select id, examinee_id, customer_code, major_category_code, state, ranking, create_time from sy_test_select_category
    </sql>

    <select id="selectSyTestSelectCategoryList" parameterType="SyTestSelectCategory" resultMap="SyTestSelectCategoryResult">
        <include refid="selectSyTestSelectCategoryVo"/>
        <where>  
            <if test="examineeId != null "> and examinee_id = #{examineeId}</if>
            <if test="customerCode != null  and customerCode != ''"> and customer_code = #{customerCode}</if>
            <if test="majorCategoryCode != null  and majorCategoryCode != ''"> and major_category_code = #{majorCategoryCode}</if>
            <if test="state != null "> and state = #{state}</if>
            <if test="ranking != null "> and ranking = #{ranking}</if>
        </where>
    </select>
    
    <select id="selectSyTestSelectCategoryById" parameterType="Long" resultMap="SyTestSelectCategoryResult">
        <include refid="selectSyTestSelectCategoryVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertSyTestSelectCategory" parameterType="SyTestSelectCategory" useGeneratedKeys="true" keyProperty="id">
        insert into sy_test_select_category
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="examineeId != null">examinee_id,</if>
            <if test="customerCode != null">customer_code,</if>
            <if test="majorCategoryCode != null">major_category_code,</if>
            <if test="state != null">state,</if>
            <if test="ranking != null">ranking,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="examineeId != null">#{examineeId},</if>
            <if test="customerCode != null">#{customerCode},</if>
            <if test="majorCategoryCode != null">#{majorCategoryCode},</if>
            <if test="state != null">#{state},</if>
            <if test="ranking != null">#{ranking},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateSyTestSelectCategory" parameterType="SyTestSelectCategory">
        update sy_test_select_category
        <trim prefix="SET" suffixOverrides=",">
            <if test="examineeId != null">examinee_id = #{examineeId},</if>
            <if test="customerCode != null">customer_code = #{customerCode},</if>
            <if test="majorCategoryCode != null">major_category_code = #{majorCategoryCode},</if>
            <if test="state != null">state = #{state},</if>
            <if test="ranking != null">ranking = #{ranking},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSyTestSelectCategoryById" parameterType="Long">
        delete from sy_test_select_category where id = #{id}
    </delete>

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