v1.1: 动态屏蔽、房间屏蔽功能及相关场景过滤
This commit is contained in:
@@ -5637,5 +5637,20 @@ public class Constant {
|
||||
public static final Integer PENDING = 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户拉黑类型
|
||||
*/
|
||||
public static final class UserBlackType {
|
||||
/**
|
||||
* 动态
|
||||
*/
|
||||
public static final Byte dynamic = 0;
|
||||
/**
|
||||
* 房间
|
||||
*/
|
||||
public static final Byte room = 1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@@ -1772,6 +1772,8 @@ public enum RedisKey {
|
||||
|
||||
user_give_diamond_daily_num, // 用户每日转赠钻石数量
|
||||
user_give_diamond_lock, // 用户转赠钻石锁
|
||||
|
||||
user_black_list, // 用戶拉黑列表
|
||||
;
|
||||
|
||||
|
||||
|
@@ -35,4 +35,6 @@ public class GetMyDynamicReq {
|
||||
private Long fromUid;
|
||||
|
||||
private List<Integer> statusList;
|
||||
|
||||
private List<Long> blackIds;
|
||||
}
|
@@ -1,5 +1,6 @@
|
||||
package com.accompany.community.service.impl;
|
||||
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
@@ -45,6 +45,11 @@
|
||||
<if test="uid != null">
|
||||
and c.uid = #{uid}
|
||||
</if>
|
||||
<if test="fromUid != null">
|
||||
<if test="statusList != null and statusList.size() > 0">
|
||||
and c.id not in (select obj_id from user_black_record where uid = #{fromUid} and `type` = 1)
|
||||
</if>
|
||||
</if>
|
||||
</trim>
|
||||
)
|
||||
UNION ALL
|
||||
|
@@ -0,0 +1,53 @@
|
||||
package com.accompany.business.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 用户屏蔽表
|
||||
*
|
||||
* @author lzm
|
||||
* @email
|
||||
* @date 2022-10-21 19:43:56
|
||||
*/
|
||||
@Data
|
||||
@TableName("user_black_record")
|
||||
public class UserBlackRecord implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long uid;
|
||||
/**
|
||||
* type为1 动态id type为2 用户uid
|
||||
*/
|
||||
private Long objId;
|
||||
/**
|
||||
* 1动态屏蔽 2房间拉黑
|
||||
*/
|
||||
private Byte type;
|
||||
/**
|
||||
* 0无效 1有效
|
||||
*/
|
||||
private Byte status;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date createTime;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
package com.accompany.business.mybatismapper;
|
||||
|
||||
import com.accompany.business.model.UserBlackRecord;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户屏蔽表记录表
|
||||
*
|
||||
* @author lzm
|
||||
* @email
|
||||
* @date 2022-10-17 11:52:24
|
||||
*/
|
||||
@Mapper
|
||||
public interface UserBlackRecordMapper extends BaseMapper<UserBlackRecord> {
|
||||
|
||||
List<Long> getBlackIdList(@Param("uid") Long uid, @Param("type") Byte type);
|
||||
}
|
@@ -385,6 +385,9 @@ public class DynamicService extends CommunityBaseService {
|
||||
request.setStatusList(Arrays.asList(DynamicStatusEnum.PASS.getValue(),
|
||||
DynamicStatusEnum.SHELVE.getValue(),DynamicStatusEnum.PASS_MACHINE.getValue()));
|
||||
}
|
||||
|
||||
// 获取屏蔽的动态id
|
||||
// List<Long> blackIds = userBlackRecordService.getBlackIdList(request.getFromUid(), Constant.UserBlackType.dynamic);
|
||||
//查询动态
|
||||
List<MyDynamicInfoVo> myDynamicList = iDynamicService.getMyDynamic(request);
|
||||
myDynamicList.forEach(dynamic ->{
|
||||
|
@@ -3,6 +3,7 @@ package com.accompany.business.service.community;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.accompany.business.enums.DynamicLabelEnum;
|
||||
import com.accompany.business.service.user.UserBlackRecordService;
|
||||
import com.accompany.business.service.world.WorldService;
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
@@ -71,6 +72,8 @@ public class DynamicSquareService extends CommunityBaseService {
|
||||
private IWorldService iWorldService;
|
||||
@Resource(name = "bizExecutor")
|
||||
private TaskExecutor bizExecutor;
|
||||
@Autowired
|
||||
private UserBlackRecordService userBlackRecordService;
|
||||
|
||||
|
||||
@Autowired
|
||||
@@ -225,6 +228,10 @@ public class DynamicSquareService extends CommunityBaseService {
|
||||
* @return
|
||||
*/
|
||||
public FollowerDynamicListVo followerDynamics(Long uid, FollowerDynamicListReq req) {
|
||||
|
||||
// 获取屏蔽的动态id
|
||||
List<Long> blackIds = userBlackRecordService.getBlackIdList(uid,Constant.UserBlackType.dynamic);
|
||||
|
||||
DynamicListQuery query = DynamicListQuery.builder()
|
||||
.uid(uid)
|
||||
// 本次从哪条动态开始查起,不包括该动态id
|
||||
@@ -235,6 +242,7 @@ public class DynamicSquareService extends CommunityBaseService {
|
||||
DynamicStatusEnum.PASS_MACHINE.getValue()))
|
||||
// 设置查询关注者动态的标识
|
||||
.followerFlag(Boolean.TRUE)
|
||||
.idNotInList(blackIds)
|
||||
.limit(req.getPageSize())
|
||||
.build();
|
||||
List<Dynamic> list = iDynamicService.getDynamicList(query);
|
||||
@@ -257,6 +265,10 @@ public class DynamicSquareService extends CommunityBaseService {
|
||||
* @return
|
||||
*/
|
||||
public LatestDynamicListVo latestDynamics(Long uid, LatestDynamicListReq req) {
|
||||
|
||||
// 获取屏蔽的动态id
|
||||
List<Long> blackIds = userBlackRecordService.getBlackIdList(uid,Constant.UserBlackType.dynamic);
|
||||
|
||||
DynamicListQuery query = DynamicListQuery.builder()
|
||||
.uid(uid)
|
||||
// 本次从哪条动态开始查起,不包括该动态id
|
||||
@@ -267,6 +279,7 @@ public class DynamicSquareService extends CommunityBaseService {
|
||||
DynamicStatusEnum.PASS_MACHINE.getValue()))
|
||||
// 设置查询关注者动态的标识
|
||||
.followerFlag(Boolean.FALSE)
|
||||
.idNotInList(blackIds)
|
||||
.limit(req.getPageSize())
|
||||
.build();
|
||||
List<Dynamic> list = iDynamicService.getDynamicList(query);
|
||||
@@ -596,12 +609,15 @@ public class DynamicSquareService extends CommunityBaseService {
|
||||
if (CollectionUtils.isEmpty(hotDynamicList)) return new ArrayList<>();
|
||||
logger.info("广场动态查询本地缓存获取成功{}", hotDynamicList.size());
|
||||
|
||||
// 获取屏蔽的动态id
|
||||
List<Long> blackIds = userBlackRecordService.getBlackIdList(uid,Constant.UserBlackType.dynamic);
|
||||
|
||||
stw.start("dynamicQueryElapsed");
|
||||
// 根据动态类型过滤动态
|
||||
dynamicList.addAll(hotDynamicList.stream()
|
||||
// 过滤操作:传入的动态类型为null,或传入的动态类型包含动态类型
|
||||
.map(id -> getDynamic(id))
|
||||
.filter(dynamic -> ObjectUtil.isNotNull(dynamic) && DynamicStatusEnum.validStatusList().contains(dynamic.getStatus()))
|
||||
.filter(dynamic -> ObjectUtil.isNotNull(dynamic) && DynamicStatusEnum.validStatusList().contains(dynamic.getStatus()) && !blackIds.contains(dynamic.getId()) )
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
stw.stop();
|
||||
@@ -616,7 +632,9 @@ public class DynamicSquareService extends CommunityBaseService {
|
||||
if (!dynamicMap.containsKey(squareTopId)) {
|
||||
//避免最新发布的动态马上置顶,缓存没有
|
||||
Dynamic dynamic = iDynamicService.getById(squareTopId);
|
||||
if (ObjectUtil.isNotNull(dynamic)) dynamicMap.put(dynamic.getId(), dynamic);
|
||||
if (ObjectUtil.isNotNull(dynamic) && !blackIds.contains(dynamic.getId()) ) {
|
||||
dynamicMap.put(dynamic.getId(), dynamic);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -632,7 +650,7 @@ public class DynamicSquareService extends CommunityBaseService {
|
||||
Set<Integer> typeSet = Sets.newHashSet(ConvertUtil.toIntArray(req.getTypes()));
|
||||
List<Dynamic> rsList = rsIdList.stream().
|
||||
map(dId -> dynamicMap.get(dId)).
|
||||
filter(dynamic -> ObjectUtil.isNotNull(dynamic) && (CollectionUtils.isEmpty(typeSet) || typeSet.contains(dynamic.getType()))).
|
||||
filter(dynamic -> ObjectUtil.isNotNull(dynamic) && !blackIds.contains(dynamic.getId()) && (CollectionUtils.isEmpty(typeSet) || typeSet.contains(dynamic.getType()))).
|
||||
collect(Collectors.toList());
|
||||
|
||||
rsList = baseService.subListByPage(req.getPage(), req.getPageSize(), rsList);
|
||||
|
@@ -24,6 +24,7 @@ import com.accompany.business.service.room.SingleBroadcastPopularityService;
|
||||
import com.accompany.business.service.roomtab.RoomTabHomeService;
|
||||
import com.accompany.business.service.roomtab.RoomTabMapService;
|
||||
import com.accompany.business.service.roomtab.RoomTabService;
|
||||
import com.accompany.business.service.user.UserBlackRecordService;
|
||||
import com.accompany.business.service.user.UserInRoomService;
|
||||
import com.accompany.business.service.user.UsersService;
|
||||
import com.accompany.business.util.ReplaceDomainUtil;
|
||||
@@ -122,6 +123,8 @@ public class HomeService extends BaseService {
|
||||
private MiniGameService miniGameService;
|
||||
@Autowired
|
||||
private ChannelContentPartitionService channelContentPartitionService;
|
||||
@Autowired
|
||||
private UserBlackRecordService userBlackRecordService;
|
||||
|
||||
/**
|
||||
* 获取首页的动态数据
|
||||
@@ -602,12 +605,18 @@ public class HomeService extends BaseService {
|
||||
//进行过滤
|
||||
Integer onMicNum = Integer.valueOf(sysConfService.getDefaultSysConfValueById(Constant.SysConfId.RECOM_NOT_TOP_MIC_NUM, String.valueOf(Constant.BigGooseConstant.home_not_top_default_mic_num)));
|
||||
|
||||
// 过滤屏蔽房间
|
||||
List<Long> blackIdList = userBlackRecordService.getBlackIdList(uid, Constant.UserBlackType.room);
|
||||
|
||||
List<TopRoomTabHomeVo> tabHomeVoList = topRoomTabHomeVos.stream().filter(tabHomeVo -> {
|
||||
Room room = roomMap.get(tabHomeVo.getRoomUid());
|
||||
if (ObjectUtil.isNull(room) || StringUtils.isNotEmpty(room.getRoomPwd()) || !room.getValid()) return false;
|
||||
if (!tabHomeVo.getIsTop()) {
|
||||
// 非置顶房间需要判断麦上人数是否符合要求
|
||||
if (ObjectUtil.isNull(tabHomeVo.getOnMicNum()) || tabHomeVo.getOnMicNum() < onMicNum) return false;
|
||||
|
||||
// 过滤屏蔽房间
|
||||
if (CollectionUtils.isNotEmpty(blackIdList) && blackIdList.contains(tabHomeVo.getRoomUid())) return false;
|
||||
}
|
||||
return true;
|
||||
}).collect(Collectors.toList());
|
||||
@@ -647,6 +656,9 @@ public class HomeService extends BaseService {
|
||||
Map<String, String> listMap = jedisService.hgetAll(RedisKey.room_mic_up.getKey());
|
||||
if (MapUtil.isEmpty(listMap)) return decisionAddBannerToList(bannerVoList, new ArrayList<>());
|
||||
|
||||
// 过滤屏蔽房间
|
||||
List<Long> blackIdList = userBlackRecordService.getBlackIdList(uid, Constant.UserBlackType.room);
|
||||
|
||||
//非置顶的进行过滤
|
||||
Integer onMicNum = Integer.valueOf(sysConfService.getDefaultSysConfValueById(Constant.SysConfId.HOME_HOT_ROOM_MIC_NUM, String.valueOf(Constant.BigGooseConstant.home_hot_room_default_mic_num)));
|
||||
final List<Byte> roomTypeList = Arrays.asList(Constant.PermitType.PERMIT_ROOM);
|
||||
@@ -665,6 +677,9 @@ public class HomeService extends BaseService {
|
||||
|
||||
if (playRoomVo.getMicUserCount() < onMicNum) return false;
|
||||
|
||||
// 过滤屏蔽房间
|
||||
if (CollectionUtils.isNotEmpty(blackIdList) && blackIdList.contains(playRoomVo.getUid())) return false;
|
||||
|
||||
playRoomVo.setErbanNo(users.getErbanNo());
|
||||
playRoomVo.setRoomId(room.getRoomId());
|
||||
playRoomVo.setAvatar(ReplaceDomainUtil.handler(users.getAvatar()));
|
||||
@@ -703,11 +718,14 @@ public class HomeService extends BaseService {
|
||||
final List<Byte> roomTypeList = Arrays.asList(Constant.PermitType.NO_PERMIT_ROOM, Constant.PermitType.NEW_SHOW_ROOM);
|
||||
List<PlayRoomVo> playRoomVos = new ArrayList<>();
|
||||
|
||||
// 过滤屏蔽房间
|
||||
List<Long> blackIdList = userBlackRecordService.getBlackIdList(uid, Constant.UserBlackType.room);
|
||||
|
||||
// 获取有广播的开黑房间数据
|
||||
List<PlayRoomVo> playRoomBroadVos = getBroadPlayRoomVos(roomTypeList);
|
||||
List<PlayRoomVo> playRoomBroadVos = getBroadPlayRoomVos(roomTypeList,blackIdList);
|
||||
|
||||
// 无广播的开黑房间数据
|
||||
List<PlayRoomVo> playRoomNoBroadVos = getPlayRoomNoBroadVos(roomTypeList,playRoomBroadVos);
|
||||
List<PlayRoomVo> playRoomNoBroadVos = getPlayRoomNoBroadVos(roomTypeList,playRoomBroadVos,blackIdList);
|
||||
|
||||
if (CollectionUtils.isNotEmpty(playRoomBroadVos)){
|
||||
playRoomVos.addAll(playRoomBroadVos);
|
||||
@@ -736,7 +754,7 @@ public class HomeService extends BaseService {
|
||||
return playRoomVos;
|
||||
}
|
||||
|
||||
private List<PlayRoomVo> getPlayRoomNoBroadVos(List<Byte> roomTypeList, List<PlayRoomVo> playRoomBroadVos) {
|
||||
private List<PlayRoomVo> getPlayRoomNoBroadVos(List<Byte> roomTypeList, List<PlayRoomVo> playRoomBroadVos, List<Long> blackIdList) {
|
||||
Integer onMicNum = Integer.valueOf(sysConfService.getDefaultSysConfValueById(Constant.SysConfId.MORE_PLAY_ON_MIC_NUM, String.valueOf(Constant.BigGooseConstant.more_play_default_mic_num)));
|
||||
|
||||
Map<String,String> listMap = jedisService.hgetAll(RedisKey.room_mic_up.getKey());
|
||||
@@ -767,6 +785,9 @@ public class HomeService extends BaseService {
|
||||
|
||||
if (playRoomVo.getMicUserCount() < onMicNum) return false;
|
||||
|
||||
// 过滤屏蔽房间
|
||||
if (CollectionUtils.isNotEmpty(blackIdList) && blackIdList.contains(playRoomVo.getUid())) return false;
|
||||
|
||||
playRoomVo.setErbanNo(users.getErbanNo());
|
||||
return true;
|
||||
})
|
||||
@@ -777,8 +798,9 @@ public class HomeService extends BaseService {
|
||||
* 获取符合展示条件的有广播的开黑房间数据
|
||||
* @return
|
||||
* @param roomTypeList
|
||||
* @param blackIdList
|
||||
*/
|
||||
private List<PlayRoomVo> getBroadPlayRoomVos(List<Byte> roomTypeList) {
|
||||
private List<PlayRoomVo> getBroadPlayRoomVos(List<Byte> roomTypeList, List<Long> blackIdList) {
|
||||
|
||||
Integer onMicNum;
|
||||
BroadModelConfig config = broadRecordService.getBroadModelConfig();
|
||||
@@ -814,6 +836,9 @@ public class HomeService extends BaseService {
|
||||
|
||||
if (playRoomVo.getMicUserCount() < onMicNum) return false;
|
||||
|
||||
// 过滤屏蔽房间
|
||||
if (CollectionUtils.isNotEmpty(blackIdList) && blackIdList.contains(playRoomVo.getUid())) return false;
|
||||
|
||||
playRoomVo.setBroadMsg(broadRecord.getMsg());
|
||||
playRoomVo.setBroadId(broadRecord.getId());
|
||||
playRoomVo.setBroadCreateTime(broadRecord.getCreateTime());
|
||||
@@ -837,6 +862,8 @@ public class HomeService extends BaseService {
|
||||
|
||||
//过滤
|
||||
List<Byte> roomTypeList = Arrays.asList(Constant.PermitType.PERMIT_ROOM);
|
||||
// 过滤屏蔽房间
|
||||
List<Long> blackIdList = userBlackRecordService.getBlackIdList(uid, Constant.UserBlackType.room);
|
||||
|
||||
List<PlayRoomVo> playRoomVoList = new ArrayList<>();
|
||||
list = list.stream().filter(roomTabMap -> {
|
||||
@@ -855,6 +882,9 @@ public class HomeService extends BaseService {
|
||||
if (ObjectUtil.isNull(playRoomVo.getMicUserCount())) return false;
|
||||
if (playRoomVo.getMicUserCount() < 1) return false;
|
||||
|
||||
// 过滤屏蔽房间
|
||||
if (CollectionUtils.isNotEmpty(blackIdList) && blackIdList.contains(playRoomVo.getUid())) return false;
|
||||
|
||||
playRoomVoList.add(playRoomVo);
|
||||
return true;
|
||||
}).collect(Collectors.toList());
|
||||
|
@@ -0,0 +1,21 @@
|
||||
package com.accompany.business.service.user;
|
||||
|
||||
import com.accompany.business.model.UserBlackRecord;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户屏蔽表
|
||||
*
|
||||
* @author lzm
|
||||
* @email
|
||||
* @date 2022-10-21 19:43:56
|
||||
*/
|
||||
public interface UserBlackRecordService extends IService<UserBlackRecord> {
|
||||
|
||||
|
||||
void add(Long uid, Long objId, Byte type);
|
||||
|
||||
List<Long> getBlackIdList(Long uid, Byte type);
|
||||
}
|
@@ -0,0 +1,114 @@
|
||||
package com.accompany.business.service.user.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.accompany.business.model.UserBlackRecord;
|
||||
import com.accompany.business.mybatismapper.UserBlackRecordMapper;
|
||||
import com.accompany.business.service.community.DynamicService;
|
||||
import com.accompany.business.service.user.UserBlackRecordService;
|
||||
import com.accompany.business.service.user.UsersService;
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.common.utils.DateTimeUtil;
|
||||
import com.accompany.community.entity.Dynamic;
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.accompany.core.model.Users;
|
||||
import com.accompany.core.service.common.JedisService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 用户屏蔽表
|
||||
*
|
||||
* @author lzm
|
||||
* @email
|
||||
* @date 2022-10-21 19:43:56
|
||||
*/
|
||||
@Service
|
||||
public class UserBlackRecordServiceImpl extends ServiceImpl<UserBlackRecordMapper, UserBlackRecord> implements UserBlackRecordService {
|
||||
|
||||
@Autowired
|
||||
private JedisService jedisService;
|
||||
@Autowired
|
||||
private DynamicService dynamicService;
|
||||
@Autowired
|
||||
private UsersService usersService;
|
||||
@Autowired
|
||||
private UserBlackRecordMapper userBlackRecordMapper;
|
||||
|
||||
@Override
|
||||
public void add(Long uid, Long objId, Byte type) {
|
||||
if (uid == null || objId == null || type == null) {
|
||||
throw new ServiceException(BusiStatus.PARAMETERILLEGAL);
|
||||
}
|
||||
|
||||
List<Byte> types = Arrays.asList(Constant.UserBlackType.dynamic, Constant.UserBlackType.room);
|
||||
if ( !types.contains(type) ) {
|
||||
throw new ServiceException(BusiStatus.PARAMETERILLEGAL);
|
||||
}
|
||||
|
||||
if (Constant.UserBlackType.dynamic.equals(type)) {
|
||||
Dynamic dynamic = dynamicService.getDynamic(objId);
|
||||
if (dynamic == null) {
|
||||
throw new ServiceException(BusiStatus.DYNAMIC_NOT_EXIST);
|
||||
}
|
||||
}
|
||||
|
||||
if (Constant.UserBlackType.room.equals(type)) {
|
||||
Users users = usersService.getUsersByUid(objId);
|
||||
if (users == null) {
|
||||
throw new ServiceException(BusiStatus.ROOMNOTEXIST);
|
||||
}
|
||||
}
|
||||
|
||||
UserBlackRecord record = buildUserBlackRecord(uid, objId, type);
|
||||
this.save(record);
|
||||
|
||||
jedisService.del(getUserBlackListKey(uid,type));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取拉黑的名单列表
|
||||
* @param uid
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<Long> getBlackIdList(Long uid, Byte type) {
|
||||
String key = getUserBlackListKey(uid, type);
|
||||
Set<String> smembers = jedisService.smembers(key);
|
||||
if (CollectionUtils.isEmpty(smembers)){
|
||||
List<Long> blackIdList = userBlackRecordMapper.getBlackIdList(uid, type);
|
||||
if (CollectionUtils.isEmpty(blackIdList)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
jedisService.saddSet(key,blackIdList);
|
||||
jedisService.expire(key,DateTimeUtil.getSecondsOfDays(1));
|
||||
|
||||
return blackIdList;
|
||||
}
|
||||
return smembers.stream().map(Long::parseLong).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private String getUserBlackListKey(Long uid, Byte type) {
|
||||
return RedisKey.user_black_list.getKey(uid + StrUtil.UNDERLINE + type);
|
||||
}
|
||||
|
||||
private UserBlackRecord buildUserBlackRecord(Long uid, Long objId, Byte type) {
|
||||
UserBlackRecord record = new UserBlackRecord();
|
||||
record.setUid(uid);
|
||||
record.setObjId(objId);
|
||||
record.setStatus(Constant.GlobalStatus.valid);
|
||||
record.setType(type);
|
||||
record.setCreateTime(new Date());
|
||||
record.setUpdateTime(new Date());
|
||||
return record;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
<?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.accompany.business.mybatismapper.UserBlackRecordMapper">
|
||||
|
||||
<!-- 可根据自己的需求,是否要使用 -->
|
||||
<resultMap type="com.accompany.business.model.UserBlackRecord" id="userBlackRecordMap">
|
||||
<result property="id" column="id"/>
|
||||
<result property="uid" column="uid"/>
|
||||
<result property="objId" column="obj_id"/>
|
||||
<result property="type" column="type"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
</resultMap>
|
||||
<select id="getBlackIdList" resultType="java.lang.Long">
|
||||
select obj_id from user_black_record where uid = #{uid} and `type` = #{type}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
@@ -0,0 +1,36 @@
|
||||
package com.accompany.business.controller.user;
|
||||
|
||||
import com.accompany.business.common.BaseController;
|
||||
import com.accompany.business.service.user.UserBlackRecordService;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 用户屏蔽表
|
||||
*
|
||||
* @author lzm
|
||||
* @email
|
||||
* @date 2022-10-21 19:43:56
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/user/black")
|
||||
public class UserBlackRecordController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private UserBlackRecordService userBlackRecordService;
|
||||
|
||||
@ApiOperation("用戶屏蔽")
|
||||
@PostMapping("/add")
|
||||
public BusiResult add(Long objId, Byte type) {
|
||||
userBlackRecordService.add(this.getUid(),objId,type);
|
||||
return new BusiResult(BusiStatus.SUCCESS);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user