<?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.userInfo.mapper.UserVipMapper">

    <resultMap type="UserVip" id="UserVipResult">
        <result property="id"    column="id"    />
        <result property="userId"    column="user_id"    />
        <result property="userName"    column="user_name"    />
        <result property="subject1"    column="subject1"    />
        <result property="subject2"    column="subject2"    />
        <result property="subject3"    column="subject3"    />
        <result property="subject4"    column="subject4"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectUserVipVo">
        select * from user_vip
    </sql>

    <select id="selectUserVipList" parameterType="UserVip" resultMap="UserVipResult">
        <include refid="selectUserVipVo"/>
        <where>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="userName != null  and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
            <if test="subject1 != null "> and subject1 = #{subject1}</if>
            <if test="subject2 != null "> and subject2 = #{subject2}</if>
            <if test="subject3 != null "> and subject3 = #{subject3}</if>
            <if test="subject4 != null "> and subject4 = #{subject4}</if>
        </where>
    </select>

    <delete id="removeByUserId" parameterType="long">
        delete from user_vip where user_id = #{userId}
    </delete>


    <select id="getUserVipByUserId" resultType="com.miaxis.userInfo.domain.UserVip" parameterType="com.miaxis.userInfo.dto.UserVipDTO">
        select * from user_vip
        <where>
            and user_id = #{userId}
        </where>
    </select>




</mapper>
