<?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.miaxis.system.mapper.UserRegisterMapper">
    
    <resultMap type="UserRegister" id="UserRegisterResult">
        <result property="id"    column="id"    />
        <result property="userId"    column="user_id"    />
        <result property="createTime"    column="create_time"    />
        <result property="inscode"    column="inscode"    />
        <result property="bmcx"    column="bmcx"    />
        <result property="coachnum"    column="coachnum"    />
        <result property="updateTime"    column="update_time"    />
        <result property="classId"    column="class_id"    />
    </resultMap>

    <sql id="selectUserRegisterVo">
        select id, user_id, create_time, inscode, bmcx, coachnum, update_time, class_id from user_register
    </sql>

    <select id="selectUserRegisterList" parameterType="UserRegister" resultMap="UserRegisterResult">
        <include refid="selectUserRegisterVo"/>
        <where>  
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="inscode != null  and inscode != ''"> and inscode = #{inscode}</if>
            <if test="bmcx != null  and bmcx != ''"> and bmcx = #{bmcx}</if>
            <if test="coachnum != null  and coachnum != ''"> and coachnum = #{coachnum}</if>
            <if test="classId != null "> and class_id = #{classId}</if>
        </where>
    </select>
    
    <select id="selectUserRegisterById" parameterType="Long" resultMap="UserRegisterResult">
        <include refid="selectUserRegisterVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertUserRegister" parameterType="UserRegister">
        insert into user_register
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="userId != null">user_id,</if>
            <if test="createTime != null">create_time,</if>
            <if test="inscode != null">inscode,</if>
            <if test="bmcx != null">bmcx,</if>
            <if test="coachnum != null">coachnum,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="classId != null">class_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="userId != null">#{userId},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="inscode != null">#{inscode},</if>
            <if test="bmcx != null">#{bmcx},</if>
            <if test="coachnum != null">#{coachnum},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="classId != null">#{classId},</if>
         </trim>
    </insert>

    <update id="updateUserRegister" parameterType="UserRegister">
        update user_register
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">user_id = #{userId},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="inscode != null">inscode = #{inscode},</if>
            <if test="bmcx != null">bmcx = #{bmcx},</if>
            <if test="coachnum != null">coachnum = #{coachnum},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="classId != null">class_id = #{classId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteUserRegisterById" parameterType="Long">
        delete from user_register where id = #{id}
    </delete>

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