feat:黑名单搜索
This commit is contained in:
1 parent
0e6b73ca6a
commit
71473ade25
6 files changed
+88
-35
No files matched your search
+1
-1
@@ -33,7 +33,7 @@ public enum MemberRecentOperateEnum {
|
||||
/**
|
||||
* 用户-屏蔽
|
||||
*/
|
||||
MEMBER_SHIELD("5", "屏蔽"),
|
||||
MEMBER_SHIELD("5", "屏蔽/拉黑"),
|
||||
/**
|
||||
* 用户-举报
|
||||
*/
|
||||
|
||||
+6
@@ -21,6 +21,9 @@ public class RecentPageReqVO extends PageParam {
|
||||
@Schema(description = "用户编号")
|
||||
private Long memberId;
|
||||
|
||||
@Schema(description = "排除用户编号")
|
||||
private List<Long> excludeUserIdList;
|
||||
|
||||
@Schema(description = "性别")
|
||||
private Integer memberSex;
|
||||
|
||||
@@ -64,6 +67,9 @@ public class RecentPageReqVO extends PageParam {
|
||||
@Schema(description = "场景")
|
||||
private String sceneBizType;
|
||||
|
||||
@Schema(description = "距离不为空")
|
||||
private Boolean distanceIsNotNull;
|
||||
|
||||
/**
|
||||
* 用户tag相关
|
||||
*/
|
||||
|
||||
+5
@@ -54,4 +54,9 @@ public interface OperationService {
|
||||
List<OperationStatusVo> getRecentOperationStatus(Long operateUserId, List<Long> recentIdList);
|
||||
|
||||
OperationStatusVo getRecentOperationStatus(Long operateUserId, Long recentIdList);
|
||||
|
||||
/**
|
||||
* 获取黑名单列表
|
||||
*/
|
||||
List<Long> getBlackUserIdList(Long memberId);
|
||||
}
|
||||
+21
@@ -1,6 +1,7 @@
|
||||
package cn.iocoder.yudao.module.member.service.recent;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.recent.vo.OperationPageReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.recent.vo.OperationRespVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.recent.vo.OperationSaveReqVO;
|
||||
@@ -8,6 +9,7 @@ import cn.iocoder.yudao.module.member.controller.admin.recent.vo.OperationStatus
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.recent.OperationDO;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.recent.OperationMapper;
|
||||
import cn.iocoder.yudao.module.member.enums.MemberErrorCode;
|
||||
import cn.iocoder.yudao.module.member.enums.MemberRecentOperateEnum;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -21,6 +23,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
@@ -111,4 +114,22 @@ public class OperationServiceImpl implements OperationService {
|
||||
}
|
||||
return new OperationStatusVo();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取黑名单列表
|
||||
*/
|
||||
@Override
|
||||
public List<Long> getBlackUserIdList(Long memberId) {
|
||||
List<OperationDO> list = operationMapper.selectList(new LambdaQueryWrapperX<OperationDO>()
|
||||
.select(OperationDO::getMemberId)
|
||||
.eq(OperationDO::getOperatorMemberId, memberId)
|
||||
.eq(OperationDO::getBizType, MemberRecentOperateEnum.MEMBER_SHIELD.getType())
|
||||
.isNull(OperationDO::getCancelTime)
|
||||
.orderByDesc(OperationDO::getTapTime)
|
||||
.orderByDesc(OperationDO::getId)
|
||||
);
|
||||
if (ObjectUtil.isEmpty(list)) return Collections.emptyList();
|
||||
return list.stream().map(OperationDO::getMemberId).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
+33
-26
@@ -52,10 +52,7 @@ import cn.iocoder.yudao.module.member.dal.mysql.recent.RecentMapper;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -221,7 +218,12 @@ public class RecentServiceImpl implements RecentService {
|
||||
if (MemberRecentOperateEnum.recentOperateList.contains(dto.getAction())) {
|
||||
operationDO.setMemberRecentId(dto.getMemberRecentId());
|
||||
}
|
||||
|
||||
// 屏蔽/拉黑
|
||||
if (ObjectUtil.equals(dto.getAction(), MemberRecentOperateEnum.MEMBER_SHIELD)) {
|
||||
if (ObjectUtil.isNotEmpty(operationDO)) {
|
||||
throw exception(MemberErrorCode.EMPTY, "已屏蔽,无需重复操作");
|
||||
}
|
||||
}
|
||||
// 举报
|
||||
List<MemberRecentOperateEnum> reportList = new ArrayList<MemberRecentOperateEnum>() {{
|
||||
add(MemberRecentOperateEnum.RECENT_REPORT);
|
||||
@@ -282,16 +284,7 @@ public class RecentServiceImpl implements RecentService {
|
||||
|
||||
RecentPageReqVO resultQuery = BeanUtil.toBean(bean, RecentPageReqVO.class);
|
||||
resultQuery.setSceneBizType(bean.getScene().getType());
|
||||
// 只查询异性
|
||||
if (ObjectUtil.isNotEmpty(operationUser.getSex())) {
|
||||
SexEnum sexEnum = SexEnum.valueOfSex(operationUser.getSex());
|
||||
SexEnum targetSex = SexEnum.negation(sexEnum.getSex());
|
||||
resultQuery.setMemberSex(targetSex.getSex());
|
||||
}
|
||||
// 查询用户最新的位置
|
||||
LocationDO locationDO = locationService.getCurrentUserLastLocation();
|
||||
resultQuery.setCurrentLat(locationDO.getLat());
|
||||
resultQuery.setCurrentLng(locationDO.getLon());
|
||||
quickBeforeQuery(operationUser, resultQuery);
|
||||
|
||||
IPage<RecentPageResVo> recentPageList = recentMapper.pageJoin(new Page(bean.getPageNo(), bean.getPageSize()), resultQuery);
|
||||
List<RecentPageResVo> resultList = BeanUtils.toBean(recentPageList.getRecords(), RecentPageResVo.class);
|
||||
@@ -316,18 +309,11 @@ public class RecentServiceImpl implements RecentService {
|
||||
|
||||
RecentPageReqVO resultQuery = BeanUtil.toBean(bean, RecentPageReqVO.class);
|
||||
resultQuery.setSceneBizType(bean.getScene().getType());
|
||||
resultQuery.setIssueProvince(bean.getProvince());
|
||||
resultQuery.setIssueCity(bean.getCity());
|
||||
// 只查询异性
|
||||
if (ObjectUtil.isNotEmpty(operationUser.getSex())) {
|
||||
SexEnum sexEnum = SexEnum.valueOfSex(operationUser.getSex());
|
||||
SexEnum targetSex = SexEnum.negation(sexEnum.getSex());
|
||||
resultQuery.setMemberSex(targetSex.getSex());
|
||||
quickBeforeQuery(operationUser, resultQuery);
|
||||
// 广场-最近
|
||||
if (ObjectUtil.equals(bean.getScene(), MemberRecentSceneEnum.SQUARE_NEW_TIME)) {
|
||||
resultQuery.setDistanceIsNotNull(true);
|
||||
}
|
||||
// 查询用户最新的位置
|
||||
LocationDO locationDO = locationService.getCurrentUserLastLocation();
|
||||
resultQuery.setCurrentLat(locationDO.getLat());
|
||||
resultQuery.setCurrentLng(locationDO.getLon());
|
||||
// 广场-新人
|
||||
if (ObjectUtil.equals(MemberRecentSceneEnum.SQUARE_NEW_PERSON, bean.getScene())) {
|
||||
resultQuery.setMemberRecentTagList(new ArrayList<String>() {{
|
||||
@@ -670,4 +656,25 @@ public class RecentServiceImpl implements RecentService {
|
||||
}
|
||||
}
|
||||
|
||||
private void quickBeforeQuery(MemberUserDO operationUser, RecentPageReqVO resultQuery) {
|
||||
if (ObjectUtil.isEmpty(resultQuery)) resultQuery = new RecentPageReqVO();
|
||||
HashSet<Long> excludeUserIdList = new HashSet<>();
|
||||
// 只查询异性
|
||||
if (ObjectUtil.isNotEmpty(operationUser.getSex())) {
|
||||
SexEnum sexEnum = SexEnum.valueOfSex(operationUser.getSex());
|
||||
SexEnum targetSex = SexEnum.negation(sexEnum.getSex());
|
||||
resultQuery.setMemberSex(targetSex.getSex());
|
||||
}
|
||||
// 查询用户最新的位置(根据位置的查询)
|
||||
LocationDO locationDO = locationService.getCurrentUserLastLocation();
|
||||
resultQuery.setCurrentLat(locationDO.getLat());
|
||||
resultQuery.setCurrentLng(locationDO.getLon());
|
||||
// 排除黑名单
|
||||
List<Long> blackUserIdList = operationService.getBlackUserIdList(operationUser.getId());
|
||||
if (ObjectUtil.isNotEmpty(blackUserIdList)) {
|
||||
excludeUserIdList.addAll(blackUserIdList);
|
||||
}
|
||||
resultQuery.setExcludeUserIdList(excludeUserIdList.stream().collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
}
|
||||
+22
-8
@@ -44,6 +44,12 @@
|
||||
<if test="dto.createTime != null and dto.createTime.length == 2">
|
||||
and a.createTime between #{dto.createTime[0]} and #{dto.createTime[1]}
|
||||
</if>
|
||||
<if test="dto.excludeUserIdList != null and dto.excludeUserIdList.size() != 0">
|
||||
and a.member_id not in
|
||||
<foreach collection="dto.excludeUserIdList" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="pageJoin" resultType="cn.iocoder.yudao.module.member.controller.admin.recent.vo.RecentPageResVo">
|
||||
@@ -78,13 +84,13 @@
|
||||
</if>
|
||||
</where>
|
||||
<choose>
|
||||
<when test="dto.sceneBizType != null and dto.sceneBizType != ''">
|
||||
<when test="dto.sceneBizType != null and dto.sceneBizType != ''.toString() ">
|
||||
<!-- 动态-推荐 -->
|
||||
<if test="dto.sceneBizType == '1'">
|
||||
<if test="dto.sceneBizType == '1'.toString() ">
|
||||
order by a.create_time desc , a.id desc
|
||||
</if>
|
||||
<!-- 动态-附近 -->
|
||||
<if test="dto.sceneBizType == '2'">
|
||||
<if test="dto.sceneBizType == '2'.toString() ">
|
||||
order by a.create_time asc , distance desc
|
||||
</if>
|
||||
</when>
|
||||
@@ -118,6 +124,12 @@
|
||||
<if test="dto.issueCity != null">
|
||||
and u.city like concat('%', #{dto.issueCity}, '%')
|
||||
</if>
|
||||
<if test="dto.excludeUserIdList != null and dto.excludeUserIdList.size() != 0">
|
||||
and u.id not in
|
||||
<foreach collection="dto.excludeUserIdList" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="dto.memberRecentTagList != null and dto.memberRecentTagList.size() != 0">
|
||||
and exists (select 1
|
||||
from member_recent_tag t
|
||||
@@ -130,18 +142,21 @@
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
<if test="dto.distanceIsNotNull != null and dto.distanceIsNotNull == true ">
|
||||
having distance is not null
|
||||
</if>
|
||||
<choose>
|
||||
<when test="dto.sceneBizType != null and dto.sceneBizType != ''">
|
||||
<when test="dto.sceneBizType != null and dto.sceneBizType != ''.toString() ">
|
||||
<!-- 广场-广场 -->
|
||||
<if test="dto.sceneBizType == '3'">
|
||||
<if test="dto.sceneBizType == '3'.toString() ">
|
||||
order by u.app_refresh_date desc , u.id desc
|
||||
</if>
|
||||
<!-- 广场-最近 -->
|
||||
<if test="dto.sceneBizType == '4'">
|
||||
<if test="dto.sceneBizType == '4'.toString() ">
|
||||
order by distance asc , u.id desc
|
||||
</if>
|
||||
<!-- 广场-新人 -->
|
||||
<if test="dto.sceneBizType == '5'">
|
||||
<if test="dto.sceneBizType == '5'.toString() ">
|
||||
order by u.app_refresh_date desc
|
||||
</if>
|
||||
</when>
|
||||
@@ -150,5 +165,4 @@
|
||||
</otherwise>
|
||||
</choose>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in new issue
Block a user