155 lines
5.7 KiB
XML
155 lines
5.7 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="cn.iocoder.yudao.module.member.dal.mysql.recent.RecentMapper">
|
|
<sql id="selectA">
|
|
select a.id,
|
|
a.member_id,
|
|
a.cover_pic,
|
|
a.cover_video,
|
|
a.description,
|
|
a.issue_long,
|
|
a.issue_lat,
|
|
a.issue_province,
|
|
a.issue_city,
|
|
a.issue_district,
|
|
a.issue_address,
|
|
a.creator,
|
|
a.create_time,
|
|
a.updater,
|
|
a.update_time,
|
|
a.deleted,
|
|
a.tenant_id
|
|
</sql>
|
|
|
|
<sql id="whereA">
|
|
a.deleted = 0
|
|
<if test="dto.memberId != null">
|
|
and a.member_id = #{dto.memberId}
|
|
</if>
|
|
<if test="dto.description != null">
|
|
and a.description like concat('%', #{dto.description}, '%')
|
|
</if>
|
|
<if test="dto.issueProvince != null">
|
|
and a.issue_province like concat('%', #{dto.issueProvince}, '%')
|
|
</if>
|
|
<if test="dto.issueCity != null">
|
|
and a.issue_city like concat('%', #{dto.issueCity}, '%')
|
|
</if>
|
|
<if test="dto.issueDistrict != null">
|
|
and a.issue_district like concat('%', #{dto.issueDistrict}, '%')
|
|
</if>
|
|
<if test="dto.issueAddress != null">
|
|
and a.issue_address like concat('%', #{dto.issueAddress}, '%')
|
|
</if>
|
|
<if test="dto.createTime != null and dto.createTime.length == 2">
|
|
and a.createTime between #{dto.createTime[0]} and #{dto.createTime[1]}
|
|
</if>
|
|
</sql>
|
|
|
|
<select id="pageJoin" resultType="cn.iocoder.yudao.module.member.controller.admin.recent.vo.RecentPageResVo">
|
|
<include refid="selectA"/>,
|
|
<if test="dto.currentLat != null and dto.currentLng != null ">
|
|
(6371 * acos(
|
|
cos(radians(#{dto.currentLat})) *
|
|
cos(radians(a.issue_lat)) *
|
|
cos(radians(a.issue_long) - radians(#{dto.currentLng})) +
|
|
sin(radians(#{dto.currentLat})) *
|
|
sin(radians(a.issue_lat))
|
|
)) AS distance,
|
|
</if>
|
|
1
|
|
from member_recent a
|
|
left join member_user u on a.member_id = u.id
|
|
<where>
|
|
<include refid="whereA"/>
|
|
<if test="dto.memberSex != null">
|
|
and u.sex = #{dto.memberSex}
|
|
</if>
|
|
<if test="dto.memberRecentTagList != null and dto.memberRecentTagList.size() != 0">
|
|
and exists (select 1
|
|
from member_recent_tag t
|
|
where t.deleted = 0
|
|
and t.member_id = a.member_id
|
|
and t.tag_biz_type in
|
|
<foreach collection="dto.memberRecentTagList" item="v" open="(" close=")" separator=",">
|
|
#{v}
|
|
</foreach>
|
|
)
|
|
</if>
|
|
</where>
|
|
<choose>
|
|
<when test="dto.sceneBizType != null and dto.sceneBizType != ''">
|
|
<!-- 动态-推荐 -->
|
|
<if test="dto.sceneBizType == '1'">
|
|
order by a.create_time desc , a.id desc
|
|
</if>
|
|
<!-- 动态-附近 -->
|
|
<if test="dto.sceneBizType == '2'">
|
|
order by a.create_time asc , distance desc
|
|
</if>
|
|
</when>
|
|
<otherwise>
|
|
order by a.create_time desc , a.id desc
|
|
</otherwise>
|
|
</choose>
|
|
</select>
|
|
|
|
<select id="pageUserJoin" resultType="cn.iocoder.yudao.module.member.controller.admin.recent.vo.RecentPageResVo">
|
|
select u.id as memberId,
|
|
<if test="dto.currentLat != null and dto.currentLng != null ">
|
|
(6371 * acos(
|
|
cos(radians(#{dto.currentLat})) *
|
|
cos(radians(u.lat)) *
|
|
cos(radians(u.lng) - radians(#{dto.currentLng})) +
|
|
sin(radians(#{dto.currentLat})) *
|
|
sin(radians(u.lat))
|
|
)) AS distance,
|
|
</if>
|
|
1
|
|
from member_user u
|
|
<where>
|
|
u.deleted = 0
|
|
<if test="dto.memberSex != null">
|
|
and u.sex = #{dto.memberSex}
|
|
</if>
|
|
<if test="dto.issueProvince != null">
|
|
and u.province like concat('%', #{dto.issueProvince}, '%')
|
|
</if>
|
|
<if test="dto.issueCity != null">
|
|
and u.city like concat('%', #{dto.issueCity}, '%')
|
|
</if>
|
|
<if test="dto.memberRecentTagList != null and dto.memberRecentTagList.size() != 0">
|
|
and exists (select 1
|
|
from member_recent_tag t
|
|
where t.deleted = 0
|
|
and t.member_id = u.id
|
|
and t.tag_biz_type in
|
|
<foreach collection="dto.memberRecentTagList" item="v" open="(" close=")" separator=",">
|
|
#{v}
|
|
</foreach>
|
|
)
|
|
</if>
|
|
</where>
|
|
<choose>
|
|
<when test="dto.sceneBizType != null and dto.sceneBizType != ''">
|
|
<!-- 广场-广场 -->
|
|
<if test="dto.sceneBizType == '3'">
|
|
order by u.app_refresh_date desc , u.id desc
|
|
</if>
|
|
<!-- 广场-最近 -->
|
|
<if test="dto.sceneBizType == '4'">
|
|
order by distance asc , u.id desc
|
|
</if>
|
|
<!-- 广场-新人 -->
|
|
<if test="dto.sceneBizType == '5'">
|
|
order by u.app_refresh_date desc
|
|
</if>
|
|
</when>
|
|
<otherwise>
|
|
order by u.app_refresh_date desc , u.id desc
|
|
</otherwise>
|
|
</choose>
|
|
</select>
|
|
|
|
</mapper>
|