<?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.xq.mapper.UserInviteMapper">

    <select id="pageAdmin" resultType="com.ruoyi.xq.dto.admin.user.UserInviteAdminVo">
        select
            t1.*,
            t2.nickname, t2.mobile, t2.avatar,
            t3.nickname as invite_nickname, t3.mobile as invite_mobile, t3.avatar as invite_avatar
        from xq_user_invite t1
        left join xq_user t2 on t1.user_id = t2.id
        left join xq_user t3 on t1.invite_id = t3.id
        <where>
            <if test="bo.usercode != null and bo.usercode != ''">
                and t1.usercode = #{bo.usercode}
            </if>
            <if test="bo.nickname != null and bo.nickname != ''">
                and t2.nickname like concat('%',#{bo.nickname},'%')
            </if>
            <if test="bo.mobile != null and bo.mobile != ''">
                and t2.mobile = #{bo.mobile}
            </if>
            <if test="bo.inviteCode != null and bo.inviteCode != ''">
                and t1.usercode = #{bo.inviteCode}
            </if>
            <if test="bo.inviteNickname != null and bo.inviteNickname != ''">
                and t3.nickname like concat('%',#{bo.inviteNickname},'%')
            </if>
            <if test="bo.inviteMobile != null and bo.inviteMobile != ''">
                and t3.mobile = #{bo.inviteMobile}
            </if>
        </where>
        order by t1.create_time desc
    </select>
    <select id="pageApp" resultType="com.ruoyi.xq.dto.app.invite.UserInviteListVo">
        select
        t2.id as user_id,t2.avatar,t2.gender,t2.nickname, t1.create_time
        from xq_user_invite t1
        join xq_user t2 on t1.user_id = t2.id
        where t1.invite_id = #{userId}
        order by t1.create_time desc
    </select>


</mapper>
