<?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.voluntary.mapper.SelectedGroupMapper">

  <resultMap type="SelectedGroup" id="SelectedGroupResult">
    <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="selectSelectedGroupVo">
    select group_id, mask, `name`, `rank`, course0, course1, newgaokao_type from mxjb_selected_group
  </sql>

  <select id="selectSelectedGroupList" parameterType="SelectedGroup" resultMap="SelectedGroupResult">
    <include refid="selectSelectedGroupVo" />
    <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 = #{newgaokaoType}</if>
    </where>
  </select>

  <select id="selectSelectedGroupByGroupId" parameterType="String" resultMap="SelectedGroupResult">
    <include refid="selectSelectedGroupVo" />
    where group_id = #{groupId}
  </select>

  <insert id="insertSelectedGroup" parameterType="SelectedGroup" 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">course0,</if>
      <if test="course1 != null">course1,</if>
      <if test="newgaokaoType != null">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">#{course0},</if>
      <if test="course1 != null">#{course1},</if>
      <if test="newgaokaoType != null">#{newgaokaoType},</if>
    </trim>
  </insert>

  <update id="updateSelectedGroup" parameterType="SelectedGroup">
    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">course0 = #{course0},</if>
      <if test="course1 != null">course1 = #{course1},</if>
      <if test="newgaokaoType != null">newgaokao_type = #{newgaokaoType},</if>
    </trim>
    where group_id = #{groupId}
  </update>

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

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