多语言-合并首页推荐逻辑

This commit is contained in:
liaozetao
2024-04-15 11:42:45 +08:00
committed by khalil
parent 7a9ceaad18
commit 884c776a44

View File

@@ -54,6 +54,7 @@ import com.accompany.community.constant.DynamicStatusEnum;
import com.accompany.community.entity.Dynamic;
import com.accompany.community.service.IDynamicLikeService;
import com.accompany.community.service.IDynamicService;
import com.accompany.core.base.DeviceInfoContextHolder;
import com.accompany.core.base.UidContextHolder;
import com.accompany.core.exception.ServiceException;
import com.accompany.core.model.Room;
@@ -732,6 +733,10 @@ public class HomeService extends BaseService {
* @return
*/
public List<TopRoomTabHomeVo> getRoomTabHomeListV2(Integer tabId, Integer pageNum, Integer pageSize, Long uid, DeviceInfo deviceInfo) throws Exception {
RoomTab roomTab = roomTabService.getById(tabId);
if (roomTab == null) {
return Collections.emptyList();
}
QueryWrapper<RoomTabMap> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(RoomTabMap::getTabId, tabId);
List<RoomTabMap> list = roomTabMapService.list(wrapper);
@@ -762,9 +767,7 @@ public class HomeService extends BaseService {
Map<Long, Room> roomMap = roomList.stream().collect(Collectors.toMap(Room::getUid, room -> room));
List<Users> usersList = usersBaseService.getUsersListByUids(roomUidList);
Map<Long, Users> userMap = usersList.stream().collect(Collectors.toMap(Users::getUid, users -> users));
Users u = usersService.getUsersByUid(uid);
List<TopRoomTabHomeVo> topRoomTabVoList = Lists.newArrayList();
Date now = new Date();
for (RoomTabMap roomTabMap : list) {
@@ -780,9 +783,7 @@ public class HomeService extends BaseService {
Room room = roomMap.get(roomTabMap.getRoomUid());
Users users = userMap.get(roomTabMap.getRoomUid());
if (ObjectUtil.isNull(room) || ObjectUtil.isNull(users)) continue;
if (!u.getPartitionId().equals(room.getPartitionId())) continue;
// 过滤屏蔽房间
if (CollectionUtils.isNotEmpty(blackIdList) && blackIdList.contains(roomTabMap.getRoomUid())) {
continue;
@@ -868,6 +869,18 @@ public class HomeService extends BaseService {
}
}
}
if (roomTab.getIsHomeRecommen() != null && roomTab.getIsHomeRecommen()) {
List<PlayRoomVo> playRooms = hotRoom(UidContextHolder.get(), DeviceInfoContextHolder.get());
if (CollectionUtil.isNotEmpty(playRooms)) {
for (PlayRoomVo playRoom : playRooms) {
TopRoomTabHomeVo topRoomTabHomeVo = new TopRoomTabHomeVo();
BeanUtils.copyProperties(playRoom, topRoomTabHomeVo);
if (topRoomTabVoList.stream().noneMatch(v -> v.getUid().equals(playRoom.getUid()))) {
topRoomTabVoList.add(topRoomTabHomeVo);
}
}
}
}
return topRoomTabVoList;
}