<?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.mxjb.mapper.MxjbSelectedGroupMapper">
    
    <resultMap type="MxjbSelectedGroup" id="MxjbSelectedGroupResult">
        <result property="groupId"    column="group_id"    />
        <result property="mask"    column="mask"    />
        <result property="name"    column="name"    />
        <result property="rank"    column="rank"    />
        <result property="course0"    column="course0"    />
        <result property="course1"    column="course1"    />
        <result property="newgaokaoType"    column="newgaokao_type"    />
    </resultMap>

    <sql id="selectMxjbSelectedGroupVo">
        select group_id, mask, name, `rank`, course0, course1, newgaokao_type from mxjb_selected_group
    </sql>

    <select id="selectMxjbSelectedGroupList" parameterType="MxjbSelectedGroup" resultMap="MxjbSelectedGroupResult">
        <include refid="selectMxjbSelectedGroupVo"/>
        <where>  
            <if test="mask != null "> and mask = #{mask}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="rank != null "> and `rank` = #{rank}</if>
            <if test="course0 != null and course0 != '' "> and course0 = #{course0}</if>
            <if test="course1 != null and course1 != '' "> and course1 = #{course1}</if>
            <if test="newgaokaoType != null and newgaokaoType != '' "> and newgaokao_type like concat('%', #{newgaokaoType}, '%') </if>
        </where>
        order by `rank` asc
    </select>
    
    <select id="selectMxjbSelectedGroupById" parameterType="Integer" resultMap="MxjbSelectedGroupResult">
        <include refid="selectMxjbSelectedGroupVo"/>
        where group_id = #{groupId}
    </select>
        
    <insert id="insertMxjbSelectedGroup" parameterType="MxjbSelectedGroup" useGeneratedKeys="true" keyProperty="groupId">
        insert into mxjb_selected_group
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="mask != null">mask,</if>
            <if test="name != null">name,</if>
            <if test="rank != null">`rank`,</if>
            <if test="course0 != null and course0 != ''">course0,</if>
            <if test="course1 != null and course1 != ''">course1,</if>
            <if test="newgaokaoType != null and newgaokaoType != ''">newgaokao_type,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="mask != null">#{mask},</if>
            <if test="name != null">#{name},</if>
            <if test="rank != null">#{rank},</if>
            <if test="course0 != null and course0 != ''">#{course0},</if>
            <if test="course1 != null and course1 != ''">#{course1},</if>
            <if test="newgaokaoType != null and newgaokaoType != ''">#{newgaokaoType},</if>
         </trim>
    </insert>

    <update id="updateMxjbSelectedGroup" parameterType="MxjbSelectedGroup">
        update mxjb_selected_group
        <trim prefix="SET" suffixOverrides=",">
            <if test="mask != null">mask = #{mask},</if>
            <if test="name != null">name = #{name},</if>
            <if test="rank != null">`rank` = #{rank},</if>
            <if test="course0 != null and course0 != ''">course0 = #{course0},</if>
            <if test="course1 != null and course1 != ''">course1 = #{course1},</if>
            <if test="newgaokaoType != null and newgaokaoType != ''">newgaokao_type = #{newgaokaoType},</if>
        </trim>
        where group_id = #{groupId}
    </update>

    <delete id="deleteMxjbSelectedGroupById" parameterType="Integer">
        delete from mxjb_selected_group where group_id = #{groupId}
    </delete>

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