首页-后台-最近
This commit is contained in:
@@ -1,35 +1,235 @@
|
||||
package com.accompany.admin.service.room;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.accompany.business.model.roomtab.RoomTabHome;
|
||||
import com.accompany.business.model.roomtab.RoomTabNewest;
|
||||
import com.accompany.business.service.homeV2.HomeV2Service;
|
||||
import com.accompany.business.service.homeV2.filter.HomeRoomFilterEnum;
|
||||
import com.accompany.business.service.homeV2.filter.HomeRoomFilterService;
|
||||
import com.accompany.business.service.homeV2.sort.HomeRoomSortService;
|
||||
import com.accompany.business.service.homeV2.sort.HomeRoomSorterEnum;
|
||||
import com.accompany.business.service.room.RoomService;
|
||||
import com.accompany.business.service.roomtab.RoomTabHomeService;
|
||||
import com.accompany.business.service.roomtab.RoomTabNewestService;
|
||||
import com.accompany.business.service.user.UsersService;
|
||||
import com.accompany.business.vo.home.PlayRoomVo;
|
||||
import com.accompany.business.vo.roomtab.RoomTabHomeVo;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.common.utils.DateTimeUtil;
|
||||
import com.accompany.core.exception.AdminServiceException;
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.accompany.core.model.PartitionInfo;
|
||||
import com.accompany.core.model.Room;
|
||||
import com.accompany.core.model.RoomExample;
|
||||
import com.accompany.core.model.Users;
|
||||
import com.accompany.core.mybatismapper.RoomMapper;
|
||||
import com.accompany.core.service.partition.PartitionInfoService;
|
||||
import com.accompany.core.util.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class RoomTabHomeAdminService {
|
||||
|
||||
@Autowired
|
||||
private PartitionInfoService partitionInfoService;
|
||||
@Autowired
|
||||
private UsersService usersService;
|
||||
@Autowired
|
||||
private RoomService roomService;
|
||||
@Autowired
|
||||
private RoomMapper roomMapper;
|
||||
@Autowired
|
||||
private HomeV2Service homeV2Service;
|
||||
@Autowired
|
||||
private HomeRoomFilterService filterService;
|
||||
@Autowired
|
||||
private HomeRoomSortService sortService;
|
||||
@Autowired
|
||||
private RoomTabHomeService roomTabHomeService;
|
||||
@Autowired
|
||||
private RoomTabNewestService roomTabNewestService;
|
||||
|
||||
public Page<RoomTabHomeVo> roomTabHomeList(Integer page, Integer pageSize, Long erbanNo, String roomTitle, Integer partitionId) {
|
||||
public List<RoomTabHomeVo> roomTabHomeList(Long erbanNo, String roomTitle, Integer partitionId, String simpleName) {
|
||||
List<PlayRoomVo> roomVoList = null;
|
||||
if (RoomTabHome.class.getSimpleName().equals(simpleName)){
|
||||
roomVoList = roomTabHomeList(erbanNo, roomTitle, partitionId, null, HomeRoomSorterEnum.Hot.name());
|
||||
} else if (RoomTabNewest.class.getSimpleName().equals(simpleName)){
|
||||
roomVoList = roomTabHomeList(erbanNo, roomTitle, partitionId, HomeRoomFilterEnum.Newest_CreateTime.name(), HomeRoomSorterEnum.Hot.name());
|
||||
}
|
||||
|
||||
return null;
|
||||
if (CollectionUtils.isEmpty(roomVoList)){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return decorator(roomVoList, simpleName);
|
||||
}
|
||||
|
||||
public void deleteRoomTabHome(Long id) {
|
||||
public List<PlayRoomVo> roomTabHomeList(Long erbanNo, String roomTitle, Integer partitionId,
|
||||
String filterStrategy, String sorterStrategy) {
|
||||
Set<Long> uidSet = new HashSet<>();
|
||||
if (null != erbanNo){
|
||||
Users u = usersService.getUserByErbanNo(erbanNo);
|
||||
if (null == u){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
uidSet.add(u.getUid());
|
||||
}
|
||||
|
||||
if (StringUtils.isNoneBlank(roomTitle)){
|
||||
RoomExample roomExample = new RoomExample();
|
||||
roomExample.createCriteria().andTitleLike(roomTitle);
|
||||
List<Room> roomList = roomMapper.selectByExample(roomExample);
|
||||
if (CollectionUtils.isEmpty(roomList)){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
roomList.forEach(room -> uidSet.add(room.getUid()));
|
||||
}
|
||||
|
||||
PartitionInfo partitionInfo = partitionInfoService.getById(partitionId);
|
||||
if (null == partitionInfo){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
Room room = roomService.getRoomByRoomId(partitionInfo.getPublicChatRoomId());
|
||||
if (null == room){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
Set<Long> roomUidSet = homeV2Service.getPartitionPoolSet(partitionId);
|
||||
|
||||
if (!CollectionUtils.isEmpty(uidSet)){
|
||||
roomUidSet.retainAll(uidSet);
|
||||
}
|
||||
|
||||
if (CollectionUtils.isEmpty(roomUidSet)){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
filterService.filter(roomUidSet, room.getUid(), filterStrategy);
|
||||
|
||||
if (CollectionUtils.isEmpty(roomUidSet)){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<Long> roomUidList = sortService.sort(roomUidSet, room.getUid(), sorterStrategy);
|
||||
|
||||
return homeV2Service.decorator(roomUidList, partitionId);
|
||||
}
|
||||
|
||||
public HashMap<String, Object> getRoomTabHome(Long id) {
|
||||
return null;
|
||||
private List<RoomTabHomeVo> decorator(List<PlayRoomVo> roomVoList, String simpleName) {
|
||||
Map<Long, RoomTabHome> roomTabHomeMap = (RoomTabHome.class.getSimpleName().equals(simpleName)?
|
||||
roomTabHomeService.lambdaQuery().list(): roomTabNewestService.lambdaQuery().list())
|
||||
.stream().collect(Collectors.toMap(RoomTabHome::getRoomUid, roomTabHome->roomTabHome));
|
||||
|
||||
return roomVoList.stream().map(playRoomVo -> {
|
||||
RoomTabHomeVo vo = new RoomTabHomeVo();
|
||||
vo.setRoomUid(playRoomVo.getUid());
|
||||
vo.setErbanNo(playRoomVo.getErbanNo());
|
||||
vo.setRoomTitle(playRoomVo.getTitle());
|
||||
vo.setAvatar(playRoomVo.getAvatar());
|
||||
vo.setRoomDesc(playRoomVo.getRoomDesc());
|
||||
vo.setRoomTag(playRoomVo.getRoomTag());
|
||||
vo.setIsPermitRoom(playRoomVo.getIsPermitRoom());
|
||||
vo.setMicUserCount(playRoomVo.getMicUserCount());
|
||||
vo.setOnlineNum(playRoomVo.getOnlineNum());
|
||||
vo.setIsHourTop1(playRoomVo.getIsHourTop1() > 0);
|
||||
vo.setIsWeekTop1(playRoomVo.getIsWeekTop1() > 0);
|
||||
vo.setCrossPking(playRoomVo.getCrossPking());
|
||||
|
||||
RoomTabHome home = roomTabHomeMap.get(playRoomVo.getUid());
|
||||
if (null != home) {
|
||||
vo.setId(home.getId());
|
||||
vo.setIsShow(home.getIsShow());
|
||||
vo.setIsTop(home.getIsTop());
|
||||
vo.setSeq(home.getSeq());
|
||||
vo.setTopStart(home.getTopStart());
|
||||
vo.setTopEnd(home.getTopEnd());
|
||||
vo.setCreateTime(home.getCreateTime());
|
||||
vo.setUpdateTime(home.getUpdateTime());
|
||||
}
|
||||
|
||||
return vo;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public Boolean saveRoomTabHome(Long id, Long roomUid, Integer seq, Boolean isTop, String topStart, String topEnd, Boolean isShow) {
|
||||
return Boolean.TRUE;
|
||||
public void deleteRoomTabHome(Long id, String simpleName) {
|
||||
if (RoomTabHome.class.getSimpleName().equals(simpleName)){
|
||||
roomTabHomeService.removeById(id);
|
||||
} else if (RoomTabNewest.class.getSimpleName().equals(simpleName)) {
|
||||
roomTabNewestService.removeById(id);
|
||||
}
|
||||
}
|
||||
|
||||
public RoomTabHome getRoomTabHome(Long id, String simpleName) {
|
||||
if (RoomTabHome.class.getSimpleName().equals(simpleName)){
|
||||
return roomTabHomeService.getById(id);
|
||||
} else if (RoomTabNewest.class.getSimpleName().equals(simpleName)) {
|
||||
return roomTabNewestService.getById(id);
|
||||
}
|
||||
throw new AdminServiceException(BusiStatus.PARAMERROR);
|
||||
}
|
||||
|
||||
public void saveRoomTabHome(Long id, Long roomUid, Integer seq, Boolean isTop, String topStart, String topEnd, Boolean isShow, String simpleName) {
|
||||
RoomTabHome dbEntity = new RoomTabHome();
|
||||
|
||||
if (null != id){
|
||||
RoomTabHome roomTabHome = null;
|
||||
if (RoomTabHome.class.getSimpleName().equals(simpleName)){
|
||||
roomTabHome = roomTabHomeService.getById(id);
|
||||
} else if (RoomTabNewest.class.getSimpleName().equals(simpleName)) {
|
||||
roomTabHome = roomTabNewestService.getById(id);
|
||||
}
|
||||
|
||||
if (null == roomTabHome){
|
||||
throw new AdminServiceException(BusiStatus.PARAMERROR);
|
||||
}
|
||||
|
||||
BeanUtils.copyProperties(roomTabHome, dbEntity);
|
||||
}
|
||||
|
||||
dbEntity.setRoomUid(roomUid);
|
||||
dbEntity.setSeq(seq);
|
||||
dbEntity.setIsTop(isTop);
|
||||
dbEntity.setIsShow(isShow);
|
||||
|
||||
if (!isTop) {
|
||||
// 不置顶排序变为0,置顶时间为空
|
||||
dbEntity.setSeq(0);
|
||||
dbEntity.setTopStart(null);
|
||||
dbEntity.setTopEnd(null);
|
||||
} else {
|
||||
dbEntity.setSeq(seq);
|
||||
// 判断置顶时间
|
||||
Date startDate = DateTimeUtil.convertStrToDate(topStart);
|
||||
Date endDate = DateTimeUtil.convertStrToDate(topEnd);
|
||||
if (startDate != null && endDate != null && endDate.getTime() > startDate.getTime()) {
|
||||
dbEntity.setTopStart(startDate);
|
||||
dbEntity.setTopEnd(endDate);
|
||||
} else {
|
||||
throw new ServiceException(BusiStatus.NO_TIME_SET_FOR_TOPPING);
|
||||
}
|
||||
}
|
||||
|
||||
if (id != null) {
|
||||
if (RoomTabHome.class.getSimpleName().equals(simpleName)){
|
||||
roomTabHomeService.updateById(dbEntity);
|
||||
} else if (RoomTabNewest.class.getSimpleName().equals(simpleName)) {
|
||||
roomTabNewestService.updateById((RoomTabNewest) dbEntity);
|
||||
}
|
||||
} else {
|
||||
if (RoomTabHome.class.getSimpleName().equals(simpleName)){
|
||||
roomTabHomeService.save(dbEntity);
|
||||
} else if (RoomTabNewest.class.getSimpleName().equals(simpleName)) {
|
||||
roomTabNewestService.save((RoomTabNewest) dbEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,20 +2,18 @@ package com.accompany.admin.controller.room;
|
||||
|
||||
import com.accompany.admin.controller.BaseController;
|
||||
import com.accompany.admin.service.room.RoomTabHomeAdminService;
|
||||
import com.accompany.business.model.roomtab.RoomTabHome;
|
||||
import com.accompany.business.vo.roomtab.RoomTabHomeVo;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.core.exception.AdminServiceException;
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.accompany.core.result.PageResult;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/admin/roomTabHome")
|
||||
@@ -25,13 +23,9 @@ public class RoomTabHomeAdminController extends BaseController {
|
||||
private RoomTabHomeAdminService service;
|
||||
|
||||
@GetMapping("/list")
|
||||
public BusiResult<PageResult<RoomTabHomeVo>> roomTabHomeList(Integer page, Integer pageSize,
|
||||
Long erbanNo, String roomTitle, Integer partitionId) {
|
||||
if (null == page || null == pageSize || page < 1 || pageSize < 1) {
|
||||
throw new AdminServiceException(BusiStatus.PARAMETERILLEGAL);
|
||||
}
|
||||
Page<RoomTabHomeVo> pageVo = service.roomTabHomeList(page, pageSize, erbanNo, roomTitle, partitionId);
|
||||
return BusiResult.success(new PageResult<>(pageVo));
|
||||
public BusiResult<List<RoomTabHomeVo>> roomTabHomeList(Long erbanNo, String roomTitle, Integer partitionId) {
|
||||
List<RoomTabHomeVo> voList = service.roomTabHomeList(erbanNo, roomTitle, partitionId, RoomTabHome.class.getSimpleName());
|
||||
return BusiResult.success(voList);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@@ -39,13 +33,13 @@ public class RoomTabHomeAdminController extends BaseController {
|
||||
if (null == id) {
|
||||
throw new AdminServiceException(BusiStatus.PARAMETERILLEGAL);
|
||||
}
|
||||
service.deleteRoomTabHome(id);
|
||||
service.deleteRoomTabHome(id, RoomTabHome.class.getSimpleName());
|
||||
return BusiResult.success();
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
public BusiResult<HashMap<String, Object>> getRoomTabHome(Long id) {
|
||||
return new BusiResult<>(BusiStatus.SUCCESS, service.getRoomTabHome(id));
|
||||
public BusiResult<RoomTabHome> getRoomTabHome(Long id) {
|
||||
return new BusiResult<>(BusiStatus.SUCCESS, service.getRoomTabHome(id, RoomTabHome.class.getSimpleName()));
|
||||
}
|
||||
|
||||
@PostMapping("/save")
|
||||
@@ -59,12 +53,8 @@ public class RoomTabHomeAdminController extends BaseController {
|
||||
if (isShow == null) {
|
||||
isShow = false;
|
||||
}
|
||||
Boolean result = service.saveRoomTabHome(id, roomUid, seq, isTop, topStart, topEnd, isShow);
|
||||
if (result) {
|
||||
return new BusiResult<>(BusiStatus.SUCCESS);
|
||||
} else {
|
||||
return new BusiResult<>(BusiStatus.UNKNOWN);
|
||||
}
|
||||
service.saveRoomTabHome(id, roomUid, seq, isTop, topStart, topEnd, isShow, RoomTabHome.class.getSimpleName());
|
||||
return new BusiResult<>(BusiStatus.SUCCESS);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,20 +2,19 @@ package com.accompany.admin.controller.room;
|
||||
|
||||
import com.accompany.admin.controller.BaseController;
|
||||
import com.accompany.admin.service.room.RoomTabHomeAdminService;
|
||||
import com.accompany.business.model.roomtab.RoomTabHome;
|
||||
import com.accompany.business.model.roomtab.RoomTabNewest;
|
||||
import com.accompany.business.vo.roomtab.RoomTabHomeVo;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.core.exception.AdminServiceException;
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.accompany.core.result.PageResult;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/admin/roomTabNewest")
|
||||
@@ -25,13 +24,9 @@ public class RoomTabNewestAdminController extends BaseController {
|
||||
private RoomTabHomeAdminService service;
|
||||
|
||||
@GetMapping("/list")
|
||||
public BusiResult<PageResult<RoomTabHomeVo>> roomTabHomeList(Integer page, Integer pageSize,
|
||||
Long erbanNo, String roomTitle, Integer partitionId) {
|
||||
if (null == page || null == pageSize || page < 1 || pageSize < 1) {
|
||||
throw new ServiceException(BusiStatus.PARAMETERILLEGAL);
|
||||
}
|
||||
Page<RoomTabHomeVo> pageVo = service.roomTabHomeList(page, pageSize, erbanNo, roomTitle, partitionId);
|
||||
return BusiResult.success(new PageResult<>(pageVo));
|
||||
public BusiResult<List<RoomTabHomeVo>> roomTabHomeList(Long erbanNo, String roomTitle, Integer partitionId) {
|
||||
List<RoomTabHomeVo> voList = service.roomTabHomeList(erbanNo, roomTitle, partitionId, RoomTabNewest.class.getSimpleName());
|
||||
return BusiResult.success(voList);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@@ -39,13 +34,13 @@ public class RoomTabNewestAdminController extends BaseController {
|
||||
if (null == id) {
|
||||
throw new AdminServiceException(BusiStatus.PARAMETERILLEGAL);
|
||||
}
|
||||
service.deleteRoomTabHome(id);
|
||||
service.deleteRoomTabHome(id, RoomTabNewest.class.getSimpleName());
|
||||
return BusiResult.success();
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
public BusiResult<HashMap<String, Object>> getRoomTabHome(Long id) {
|
||||
return new BusiResult<>(BusiStatus.SUCCESS, service.getRoomTabHome(id));
|
||||
public BusiResult<RoomTabHome> getRoomTabHome(Long id) {
|
||||
return new BusiResult<>(BusiStatus.SUCCESS, service.getRoomTabHome(id, RoomTabNewest.class.getSimpleName()));
|
||||
}
|
||||
|
||||
@PostMapping("/save")
|
||||
@@ -59,12 +54,8 @@ public class RoomTabNewestAdminController extends BaseController {
|
||||
if (isShow == null) {
|
||||
isShow = false;
|
||||
}
|
||||
Boolean result = service.saveRoomTabHome(id, roomUid, seq, isTop, topStart, topEnd, isShow);
|
||||
if (result) {
|
||||
return new BusiResult<>(BusiStatus.SUCCESS);
|
||||
} else {
|
||||
return new BusiResult<>(BusiStatus.UNKNOWN);
|
||||
}
|
||||
service.saveRoomTabHome(id, roomUid, seq, isTop, topStart, topEnd, isShow, RoomTabNewest.class.getSimpleName());
|
||||
return new BusiResult<>(BusiStatus.SUCCESS);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -14,10 +14,12 @@ public class RoomTabHomeVo implements Serializable {
|
||||
private Long roomUid; // 房主uid
|
||||
private Long erbanNo; // 房主靓号
|
||||
@ReplaceAppDomain
|
||||
private String iconContent; // 图标内容
|
||||
private String avatar; // 图标内容
|
||||
private String roomTitle; // 房间标题
|
||||
private String roomDesc;
|
||||
private String roomTag; // 房间标签
|
||||
private Integer tabId; // 房间tab id
|
||||
private Integer micUserCount;
|
||||
private Integer onlineNum;
|
||||
private Integer seq; // 排序
|
||||
private Boolean isTop; // 是否置顶
|
||||
private Date topStart; // 置顶开始时间
|
||||
@@ -37,9 +39,8 @@ public class RoomTabHomeVo implements Serializable {
|
||||
@ApiModelProperty("是否在App首页展示")
|
||||
private Boolean isShow;
|
||||
|
||||
/**
|
||||
* 地区
|
||||
*/
|
||||
@ApiModelProperty("地区")
|
||||
private String partitionDesc;
|
||||
private Boolean isHourTop1;
|
||||
private Boolean isWeekTop1;
|
||||
private Boolean crossPking;
|
||||
|
||||
}
|
||||
|
@@ -155,7 +155,7 @@ public class HomeV2Service {
|
||||
roomTabMapList.forEach(roomTabMap->roomUidSet.add(roomTabMap.getRoomUid()));
|
||||
}
|
||||
|
||||
private Set<Long> getPartitionPoolSet(Integer partitionId){
|
||||
public Set<Long> getPartitionPoolSet(Integer partitionId){
|
||||
return poolService.getPartitionMap(partitionId).readAllKeySet();
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ public class HomeV2Service {
|
||||
return roomUidList.subList(startIndex, endIndex);
|
||||
}
|
||||
|
||||
private List<PlayRoomVo> decorator(List<Long> roomUidPage, Integer partitionId) {
|
||||
public List<PlayRoomVo> decorator(List<Long> roomUidPage, Integer partitionId) {
|
||||
Map<Long, Room> roomMap = roomService.getRoomMap(roomUidPage);
|
||||
|
||||
String[] uidArray = roomUidPage.stream().map(Object::toString).toArray(String[]::new);
|
||||
|
@@ -22,6 +22,7 @@ public enum HomeRoomFilterEnum {
|
||||
|
||||
Hot(getHotFilter()),
|
||||
Newest(getNewestFilter()),
|
||||
Newest_CreateTime(getNewestCreateTimeFilter()),
|
||||
Recently(getRecentlyFilter()),
|
||||
Collection(getCollectionFilter()),
|
||||
;
|
||||
@@ -50,6 +51,12 @@ public enum HomeRoomFilterEnum {
|
||||
newestUnShowList.forEach(roomTabNewest -> roomUidSet.remove(roomTabNewest.getRoomUid()));
|
||||
}
|
||||
|
||||
getNewestCreateTimeFilter().accept(roomUidSet, uid);
|
||||
};
|
||||
}
|
||||
|
||||
private static BiConsumer<Collection<Long>, Long> getNewestCreateTimeFilter() {
|
||||
return (roomUidSet, uid)->{
|
||||
List<Users> usersList = SpringContextHolder.getBean(UsersService.class).getUsersListByUids(new ArrayList<>(roomUidSet));
|
||||
if (CollectionUtils.isEmpty(usersList)){
|
||||
roomUidSet.clear();
|
||||
|
@@ -31,66 +31,6 @@ public class RoomTabHomeService extends ServiceImpl<RoomTabHomeMapper, RoomTabHo
|
||||
@Autowired
|
||||
private RoomTabHomeMapper roomTabHomeMapper;
|
||||
|
||||
@Autowired
|
||||
private HomeIndexService homeIndexService;
|
||||
|
||||
@Autowired
|
||||
private PartitionInfoService partitionInfoService;
|
||||
|
||||
public HashMap<String, Object> roomTabHomeList(Integer page, Integer pageSize, Long erBanNo, String roomTitle, Integer partitionId) {
|
||||
HashMap<String, Object> data = new HashMap<>();
|
||||
List<PlayRoomVo> playRooms = homeIndexService.hotRoom();
|
||||
if (CollectionUtil.isEmpty(playRooms)) {
|
||||
data.put("roomTabHomeList", Collections.emptyList());
|
||||
data.put("totalPage", 0);
|
||||
return data;
|
||||
}
|
||||
playRooms = playRooms.stream().filter(v -> erBanNo == null || String.valueOf(v.getErbanNo()).contains(erBanNo.toString()))
|
||||
.filter(v -> StrUtil.isEmpty(roomTitle) || v.getTitle().contains(roomTitle)).collect(Collectors.toList());
|
||||
int startIndex = (page - 1) * pageSize;
|
||||
int endIndex = startIndex + pageSize;
|
||||
playRooms = ListUtil.subList(startIndex, endIndex, playRooms);
|
||||
Map<Long, RoomTabHome> roomTabHomeMap = null;
|
||||
List<RoomTabHome> roomTabHomes = roomTabHomeMapper.selectList(Wrappers.emptyWrapper());
|
||||
if (CollectionUtil.isNotEmpty(roomTabHomes)) {
|
||||
roomTabHomeMap = roomTabHomes.stream().collect(Collectors.toMap(RoomTabHome::getRoomUid, Function.identity(), (v1, v2) -> v1));
|
||||
}
|
||||
Map<Integer, String> partitionInfoDescMap = partitionInfoService.listAll().stream().collect(Collectors.toMap(PartitionInfo::getId, PartitionInfo::getDesc));
|
||||
List<RoomTabHomeVo> records = new ArrayList<>();
|
||||
for (PlayRoomVo playRoom : playRooms) {
|
||||
if (partitionId != null && playRoom.getPartitionId() != null && !playRoom.getPartitionId().equals(partitionId)) {
|
||||
continue;
|
||||
}
|
||||
Long roomUid = playRoom.getUid();
|
||||
RoomTabHomeVo room = new RoomTabHomeVo();
|
||||
room.setRoomUid(roomUid);
|
||||
room.setErbanNo(playRoom.getErbanNo());
|
||||
room.setIconContent(playRoom.getAvatar());
|
||||
room.setRoomTitle(playRoom.getTitle());
|
||||
room.setRoomTag(playRoom.getRoomTag());
|
||||
room.setIsPermitRoom(playRoom.getIsPermitRoom());
|
||||
if (CollectionUtil.isNotEmpty(roomTabHomeMap) && roomTabHomeMap.containsKey(roomUid)) {
|
||||
RoomTabHome roomTabHome = roomTabHomeMap.get(roomUid);
|
||||
room.setId(roomTabHome.getId());
|
||||
room.setTabId(roomTabHome.getTabId());
|
||||
room.setSeq(roomTabHome.getSeq());
|
||||
room.setIsTop(roomTabHome.getIsTop());
|
||||
room.setTopStart(roomTabHome.getTopStart());
|
||||
room.setTopEnd(roomTabHome.getTopEnd());
|
||||
room.setCreateTime(roomTabHome.getCreateTime());
|
||||
room.setUpdateTime(roomTabHome.getUpdateTime());
|
||||
room.setIsShow(roomTabHome.getIsShow());
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(partitionInfoDescMap)) {
|
||||
room.setPartitionDesc(partitionInfoDescMap.get(playRoom.getPartitionId()));
|
||||
}
|
||||
records.add(room);
|
||||
}
|
||||
data.put("roomTabHomeList", records);
|
||||
data.put("totalPage", playRooms.size());
|
||||
return data;
|
||||
}
|
||||
|
||||
public void deleteRoomTabHome(Long id) {
|
||||
roomTabHomeMapper.deleteById(id);
|
||||
}
|
||||
|
Reference in New Issue
Block a user