<?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.github.wxiaoqi.security.admin.mapper.BaseUserMemberMapper">

    <!-- 可根据自己的需求，是否要使用 -->
    <resultMap type="com.github.wxiaoqi.security.admin.vo.UserMemberVo" id="baseUserMemberMap">
        <result property="id" column="id"/>
        <result property="userId" column="user_id"/>
        <result property="memberNo" column="member_no"/>
        <result property="memberLevel" column="member_level"/>
        <result property="cardLeave" column="card_leave"/>
        <result property="isBind" column="is_bind"/>
        <result property="payCount" column="pay_count"/>
        <result property="buyCount" column="buy_count"/>
        <result property="totalNumber" column="total_number"/>
        <result property="rentFreeDays" column="rent_free_days"/>
        <result property="validTime" column="valid_time"/>
        <result property="crtTime" column="crt_time"/>
        <result property="updTime" column="upd_time"/>
        <result property="isDel" column="is_del"/>
        <result property="memberName" column="member_name"/>
        <result property="memberType" column="member_type"/>
    </resultMap>

    <select id="getInfoByUserId" resultMap="baseUserMemberMap">
          select  * from  base_user_member where  user_id=#{userId} and is_del=0 limit 1
    </select>


    <select id="getBaseUserMemberVOByUserId" parameterType="Integer"
            resultType="com.github.wxiaoqi.security.admin.dto.BaseUserMemberVO">
        select
        m.id as id,
        m.user_id as userId,
        m.rent_free_days as rentFreeDays,
        m.member_level as memberLevel,
        m.total_number as totalNumber,
        m.buy_count as buyCount,
        m.valid_time as validTime,
        m.member_name as memberName,
        m.discount as discount,
        ml.name as name,
        m.member_type as memberType
        from
        base_user_member m
        left join
        base_user_member_level ml
        on
        m.member_level =ml.level
        where
        m.user_id=#{userId}
        and
        m.is_del=0
        limit 1
    </select>

</mapper>