<?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="org.springblade.modules.ldt.member.mapper.MemberMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="memberResultMap" type="org.springblade.modules.ldt.member.entity.Member">
        <result column="id" property="id"/>
        <result column="create_user" property="createUser"/>
        <result column="create_dept" property="createDept"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
        <result column="user_id" property="userId"/>
        <result column="mall_id" property="mallId"/>
        <result column="shop_id" property="shopId"/>
        <result column="point_total" property="pointTotal"/>
        <result column="point_value" property="pointValue"/>
        <result column="type" property="type"/>
    </resultMap>

    <resultMap id="memberVOResultMap" type="org.springblade.modules.ldt.member.vo.MemberVO" extends="memberResultMap">
        <result column="nick_name" property="nickName"/>
        <result column="avatar" property="avatar"/>
        <result column="phone" property="phone"/>
        <result column="gender" property="gender"/>

    </resultMap>


    <select id="selectMemberPage" resultMap="memberVOResultMap">
        select
            lm.id,lm.user_id,lm.mall_id,lm.shop_id,lm.point_total,lm.point_value,lm.type,
            llu.nick_name,llu.avatar,llu.phone,llu.gender
        from
            ldt_member lm,ldt_login_user llu
        where
            lm.is_deleted = 0 AND  lm.user_id = llu.id
            <if test="member != null">
                <if test="member.nickName != null">
                    AND llu.nick_name like "%${member.nickName}%"
                </if>
                <if test="member.mallId != null">
                    AND lm.mall_id like "%${member.mallId}%"
                </if>
                <if test="member.shopId != null">
                    AND lm.shop_id like "%${member.shopId}%"
                </if>
                <if test="member.type != null">
                    AND lm.type = ${member.type}
                </if>
            </if>

    </select>

</mapper>
