Files
cai-server/ruoyi-cai/src/main/resources/mapper/cai/UserMapper.xml
张良(004796) 4b35d1d089 123
2024-05-06 16:40:51 +08:00

99 lines
4.1 KiB
XML

<?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.cai.mapper.UserMapper">
<select id="pageAdmin" resultType="com.ruoyi.cai.dto.admin.vo.UserAdminVo">
select t1.*,t2.last_login_ip,t2.last_login_time,t2.reg_ip,t2.reg_time,
t3.usercode as invite_usercode, t3.nickname as invite_nickname, t3.avatar as invite_avatar,
t4.status as online_status
from cai_user t1
left join cai_user_info t2 on t1.id = t2.user_id
left join cai_user t3 on t1.invite_id = t3.id
left join cai_user_online t4 on t1.id = t4.user_id
<where>
<if test="query.onlineStatus != null">
and t4.status = #{query.onlineStatus}
</if>
<if test="query.lastLoginIp != null">
and t2.last_login_ip = #{query.lastLoginIp}
</if>
<if test="query.isAnchor != null">
and t1.is_anchor = #{query.isAnchor}
</if>
<if test="query.nickname != null and query.nickname != ''">
and t1.nickname like concat('%',#{query.nickname},'%')
</if>
<if test="query.mobile != null and query.mobile != ''">
and t1.mobile = #{query.mobile}
</if>
<if test="query.usercode != null and query.usercode != ''">
and t1.usercode = #{query.usercode}
</if>
<if test="query.gender != null">
and t1.gender = #{query.gender}
</if>
<if test="query.city != null">
and t1.city = #{query.city}
</if>
</where>
order by t2.last_login_time desc
</select>
<select id="pageApp" resultType="com.ruoyi.cai.dto.app.vo.user.UserListVo">
select t1.avatar,t1.id as user_id,t1.gender,t1.city,t1.city_id,t1.nickname,t1.usercode,
t1.age,t2.last_live_time as bind_time
from cai_user t1
join cai_user_online t2 on t1.id = t2.user_id
where t1.status = 0
<if test="query.nickname != null and query.nickname != ''">
and t1.nickname like concat(#{query.nickname},'%')
</if>
<if test="query.usercode != null and query.usercode != ''">
and t1.usercode = #{query.usercode}
</if>
<if test="query.usercodeAndNickname != null and query.usercodeAndNickname != ''">
and (t1.usercode = #{query.usercodeAndNickname} or t1.nickname like concat(#{query.usercodeAndNickname},'%') )
</if>
<if test="query.gender != null">
and t1.gender = #{query.gender}
</if>
order by t2.last_live_time desc
</select>
<select id="greetPageApp" resultType="com.ruoyi.cai.dto.app.vo.user.UserListVo">
select t1.avatar,t1.id as user_id,t1.gender,t1.city,t1.city_id,t1.nickname,t1.usercode,t1.age,t2.last_live_time as bind_time
from cai_user t1
join cai_user_online t2 on t1.id = t2.user_id
where t1.status = 0
<if test="query.cityId != null and query.cityId != ''">
and t1.city_id = #{query.cityId}
</if>
<if test="query.justAnchor != null and query.justAnchor == 1">
and t1.is_anchor = 1
</if>
<if test="query.gender != null">
and t1.gender = #{query.gender}
</if>
<if test="query.noAuth != null and query.noAuth == 1">
and 1=2
</if>
order by t2.last_live_time desc
</select>
<select id="getGreetNumId" resultType="java.lang.Long">
select t1.id
from cai_user t1
where t1.status = 0 and t1.gender = 2 and t1.no_greet = 0
and not exists(select 1 from cai_user_blacklist p1 where t1.id = p1.user_id)
and not exists(select 1 from cai_user_blacklist p2 where t1.id = p2.black_uid)
order by t1.update_time desc
limit 20
</select>
<select id="getMinUserById" resultType="com.ruoyi.cai.dto.commom.user.MinUser">
select id,gender
from cai_user t1
where id = #{userId}
</select>
</mapper>