房间麦位cp-根据房间获取麦位上cp关系
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package com.accompany.business.vo.relation;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@ApiModel("房间麦位关系用户信息")
|
||||
public class RoomMicRelationUserVo {
|
||||
|
||||
@ApiModelProperty("用户ID")
|
||||
private Long uid;
|
||||
|
||||
@ApiModelProperty("恋人用户ID")
|
||||
private Long loverUid;
|
||||
|
||||
@ApiModelProperty("关系等级")
|
||||
private Integer cpLevel;
|
||||
|
||||
}
|
@@ -43,4 +43,6 @@ public interface RelationUserService extends IService<RelationUser> {
|
||||
RelationUserVO getOneCP(Long uid);
|
||||
|
||||
List<RelationUserVO> getCPNameTypeTopList(Long uid);
|
||||
|
||||
List<RelationUser> listInUidList(List<Long> uidList);
|
||||
}
|
||||
|
@@ -604,6 +604,14 @@ public class RelationUserServiceImpl extends ServiceImpl<RelationUserMapper, Rel
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RelationUser> listInUidList(List<Long> uidList) {
|
||||
return lambdaQuery().in(RelationUser::getUid, uidList).in(RelationUser::getLoverUid, uidList)
|
||||
.eq(RelationUser::getRelationStatus, RelationConstant.RelationStatus.NORMAL)
|
||||
.eq(RelationUser::getRelationType, RelationConstant.RelatinType.CP)
|
||||
.list();
|
||||
}
|
||||
|
||||
private int updateValue(Long uid, Long loverUid, Double intimacy, Integer relationLevel, Byte relationStatus) {
|
||||
LambdaQueryWrapper<RelationUser> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(RelationUser::getUid, uid)
|
||||
|
@@ -0,0 +1,64 @@
|
||||
package com.accompany.business.service.room;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.accompany.business.model.relation.RelationUser;
|
||||
import com.accompany.business.service.relation.RelationUserService;
|
||||
import com.accompany.business.vo.MicUserVo;
|
||||
import com.accompany.business.vo.home.PlayRoomVo;
|
||||
import com.accompany.business.vo.relation.RoomMicRelationUserVo;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.common.utils.GsonUtil;
|
||||
import com.accompany.core.service.common.JedisService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class RoomMicCpInfoService {
|
||||
|
||||
@Autowired
|
||||
private JedisService jedisService;
|
||||
@Autowired
|
||||
private RelationUserService relationUserService;
|
||||
|
||||
public List<RoomMicRelationUserVo> listByRoomUid(Long roomUid) {
|
||||
String playRoomStr = jedisService.hget(RedisKey.room_mic_up.getKey(), String.valueOf(roomUid));
|
||||
if (!StringUtils.hasText(playRoomStr)){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
PlayRoomVo playRoomVo = GsonUtil.getDefGson().fromJson(playRoomStr, PlayRoomVo.class);
|
||||
List<MicUserVo> micUsers = playRoomVo.getMicUsers();
|
||||
if (CollectionUtil.isEmpty(micUsers)){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<Long> uidList = micUsers.stream().map(MicUserVo::getUid).distinct().sorted().toList();
|
||||
List<RelationUser> relationUsers = relationUserService.listInUidList(uidList);
|
||||
return relationUsers.stream().map(po->{
|
||||
RoomMicRelationUserVo vo = new RoomMicRelationUserVo();
|
||||
vo.setUid(po.getUid());
|
||||
vo.setLoverUid(po.getLoverUid());
|
||||
vo.setCpLevel(po.getRelationLevel());
|
||||
return vo;
|
||||
}).toList();
|
||||
}
|
||||
|
||||
public List<RoomMicRelationUserVo> listByUidList(Long uid, List<Long> uidList) {
|
||||
uidList.add(uid);
|
||||
List<RelationUser> relationUsers = relationUserService.listInUidList(uidList);
|
||||
return relationUsers.stream().map(po->{
|
||||
RoomMicRelationUserVo vo = new RoomMicRelationUserVo();
|
||||
vo.setUid(po.getUid());
|
||||
vo.setLoverUid(po.getLoverUid());
|
||||
vo.setCpLevel(po.getRelationLevel());
|
||||
return vo;
|
||||
}).toList();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
package com.accompany.business.controller.room;
|
||||
|
||||
import com.accompany.business.service.room.RoomMicCpInfoService;
|
||||
import com.accompany.business.vo.relation.RoomMicRelationUserVo;
|
||||
import com.accompany.common.annotation.Authorization;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.core.base.UidContextHolder;
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/room/mic/cp")
|
||||
@Api(tags = "房间麦位CP信息接口", description = "房间麦位CP关系相关接口")
|
||||
public class RoomMicCpInfoController {
|
||||
|
||||
@Autowired
|
||||
private RoomMicCpInfoService roomMicCpInfoService;
|
||||
|
||||
@GetMapping("/listByRoomUid")
|
||||
@ApiOperation(value = "根据房间UID获取CP列表", notes = "根据房间UID获取该房间内所有CP关系用户列表")
|
||||
public BusiResult<List<RoomMicRelationUserVo>> listByRoomUid(@ApiParam(name = "roomUid", value = "房间UID", required = true) Long roomUid) {
|
||||
if (null == roomUid){
|
||||
throw new ServiceException(BusiStatus.PARAMERROR);
|
||||
}
|
||||
List<RoomMicRelationUserVo> list = roomMicCpInfoService.listByRoomUid(roomUid);
|
||||
return BusiResult.success(list);
|
||||
}
|
||||
|
||||
@Authorization
|
||||
@GetMapping("/listByUidList")
|
||||
@ApiOperation(value = "根据UID列表获取CP信息", notes = "根据用户ID列表获取与当前用户相关的CP关系信息")
|
||||
public BusiResult<List<RoomMicRelationUserVo>> listByUidList(@ApiParam(name = "uidList", value = "用户ID列表,多个ID用逗号分隔", required = true) String uidList) {
|
||||
if (!StringUtils.hasText(uidList)){
|
||||
throw new ServiceException(BusiStatus.PARAMERROR);
|
||||
}
|
||||
List<Long> list = Arrays.stream(uidList.split( ",")).filter(StringUtils::hasText).map(Long::parseLong).toList();
|
||||
if (CollectionUtils.isEmpty(list)){
|
||||
throw new ServiceException(BusiStatus.PARAMERROR);
|
||||
}
|
||||
|
||||
Long uid = UidContextHolder.get();
|
||||
List<RoomMicRelationUserVo> cpList = roomMicCpInfoService.listByUidList(uid, list);
|
||||
return BusiResult.success(cpList);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user