用户麦克风列表和上麦新增cp用户信息
(cherry picked from commit 44032e2fdf57ee96bdbee9468ae29470fd187d1c)
This commit is contained in:
parent
9728ff7a76
commit
cff5c76200
@ -5,6 +5,7 @@ import com.red.circle.framework.dto.ResultResponse;
|
||||
import com.red.circle.other.inner.model.cmd.user.CpApplyQryCmd;
|
||||
import com.red.circle.other.inner.model.cmd.user.ListLatestCpCmd;
|
||||
import com.red.circle.other.inner.model.dto.user.CpRelationshipDTO;
|
||||
import com.red.circle.other.inner.model.dto.user.CpUserInfoDTO;
|
||||
import com.red.circle.other.inner.model.dto.user.UserCpApplyDTO;
|
||||
import com.red.circle.other.inner.model.dto.user.WeekCpUserIdDTO;
|
||||
import com.red.circle.other.inner.model.dto.user.WeekCpValueCountDTO;
|
||||
@ -133,4 +134,7 @@ public interface UserCpClientApi {
|
||||
|
||||
@PostMapping("/cpIdList")
|
||||
ResultResponse<Map<Long, Long>> getCpUserIdByUserIds(@RequestBody List<Long> userIds);
|
||||
|
||||
@PostMapping("/cpInfoList")
|
||||
ResultResponse<Map<Long, List<CpUserInfoDTO>>> getCpInfoByUserIds(@RequestBody List<Long> userIds);
|
||||
}
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
package com.red.circle.other.inner.model.dto.user;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* CP用户信息.
|
||||
*
|
||||
* @author tf
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class CpUserInfoDTO {
|
||||
|
||||
/** CP用户id. */
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long cpUserId;
|
||||
|
||||
/** CP等级. */
|
||||
private Integer cpLevel;
|
||||
|
||||
}
|
||||
@ -2,6 +2,7 @@ package com.red.circle.live.app.dto.clientobject;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import com.red.circle.other.inner.model.dto.user.CpUserInfoDTO;
|
||||
import com.red.circle.other.inner.model.dto.user.OwnSpecialIdDTO;
|
||||
import com.red.circle.other.inner.model.dto.user.props.UserUsePropsDTO;
|
||||
import java.io.Serial;
|
||||
@ -28,11 +29,8 @@ public class LiveMicUserCO implements Serializable {
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* CP用户id.
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long cpUserId;
|
||||
/** CP列表. */
|
||||
private List<CpUserInfoDTO> cpList;
|
||||
|
||||
/**
|
||||
* 账号.
|
||||
|
||||
@ -3,6 +3,7 @@ package com.red.circle.live.domain.live;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import com.red.circle.other.inner.model.dto.user.CpUserInfoDTO;
|
||||
import com.red.circle.other.inner.model.dto.user.OwnSpecialIdDTO;
|
||||
import com.red.circle.other.inner.model.dto.user.props.UserUsePropsDTO;
|
||||
import java.io.Serial;
|
||||
@ -30,11 +31,8 @@ public class LiveMicUser implements Serializable {
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* CP用户id.
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long cpUserId;
|
||||
/** CP列表. */
|
||||
private List<CpUserInfoDTO> cpList;
|
||||
|
||||
/**
|
||||
* 账号.
|
||||
|
||||
@ -2,6 +2,7 @@ package com.red.circle.live.domain.live.dto;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import com.red.circle.other.inner.model.dto.user.CpUserInfoDTO;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
@ -26,11 +27,8 @@ public class LiveMicUserDTO implements Serializable {
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* CP用户id.
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long cpUserId;
|
||||
/** CP列表. */
|
||||
private List<CpUserInfoDTO> cpList;
|
||||
|
||||
/**
|
||||
* 账号.
|
||||
|
||||
@ -60,11 +60,7 @@ public class LiveMicCacheServiceImpl implements LiveMicCacheService {
|
||||
|
||||
@Override
|
||||
public void goUp(Long roomId, Integer index, LiveMicrophone microphone) {
|
||||
// if (Objects.isNull(microphone.getRefreshTime())) {
|
||||
// microphone.updateLastActivityTime();
|
||||
// }
|
||||
microphone.updateLastActivityTime();
|
||||
log.info("用户上麦 index = {} microphone = {} ", index, JSON.toJSONString(microphone));
|
||||
redisService.hashPut(LiveMicKey.SEAT.getKey(roomId),
|
||||
Objects.toString(index),
|
||||
microphone);
|
||||
|
||||
@ -42,6 +42,7 @@ import com.red.circle.other.inner.model.cmd.live.LiveHeartbeatCmd;
|
||||
import com.red.circle.other.inner.model.cmd.live.MemberRolesQryCmd;
|
||||
import com.red.circle.other.inner.model.dto.live.RoomProfileDTO;
|
||||
import com.red.circle.other.inner.model.dto.live.RoomProfileManagerDTO;
|
||||
import com.red.circle.other.inner.model.dto.user.CpUserInfoDTO;
|
||||
import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
|
||||
import com.red.circle.other.inner.model.dto.user.WealthAndCharmLevelDTO;
|
||||
import com.red.circle.tool.core.collection.CollectionUtils;
|
||||
@ -196,6 +197,7 @@ public class LiveMicrophoneGatewayImpl implements LiveMicrophoneGateway {
|
||||
micUser.setCharmLevel(body.getCharmLevel());
|
||||
micUser.setWealthLevel(body.getWealthLevel());
|
||||
}
|
||||
micUser.setCpList(userCpClient.getCpInfoByUserIds(List.of(userId)).getBody().get(userId));
|
||||
|
||||
LiveMicrophone liveMicrophone = new LiveMicrophone()
|
||||
.setMicIndex(micSeat.getMicIndex())
|
||||
@ -599,8 +601,6 @@ public class LiveMicrophoneGatewayImpl implements LiveMicrophoneGateway {
|
||||
|
||||
private Map<Integer, LiveMicrophone> mapLiveMicrophone(Long roomId) {
|
||||
List<LiveMicrophone> liveMicrophones = liveMicCacheService.listLiveMicrophone(roomId);
|
||||
log.info("在线取麦克风列表信息 -列表: {}", liveMicrophones);
|
||||
//获取房间用户心动值
|
||||
Map<Long, Long> liveHeartbeatMap = getLiveHeartbeatMap(liveHeartbeatClient.listLiveHeartbeat(roomId).getBody());
|
||||
if (CollectionUtils.isEmpty(liveMicrophones)) {
|
||||
return CollectionUtils.newHashMap();
|
||||
@ -609,13 +609,12 @@ public class LiveMicrophoneGatewayImpl implements LiveMicrophoneGateway {
|
||||
List<LiveMicUser> liveMicUsers = liveMicrophones.stream().map(LiveMicrophone::getUser).toList();
|
||||
List<Long> userIds = liveMicUsers.stream().map(LiveMicUser::getId).toList();
|
||||
updateLiveMicrophoneUserInfo(liveMicrophones, roomId, userIds);
|
||||
Map<Long, Long> cpUserIdMap = userCpClient.getCpUserIdByUserIds(userIds).getBody();
|
||||
log.info("用户ID集合={}, 结果集cpUserIdMap = {}", userIds, cpUserIdMap);
|
||||
Map<Long, List<CpUserInfoDTO>> cpInfoMap = userCpClient.getCpInfoByUserIds(userIds).getBody();
|
||||
return liveMicrophones.stream()
|
||||
.peek(liveMicrophone -> {
|
||||
LiveMicUser user = liveMicrophone.getUser();
|
||||
user.setHeartbeatVal(Objects.nonNull(liveHeartbeatMap.get(user.getId()))? liveHeartbeatMap.get(user.getId()):0L);
|
||||
user.setCpUserId(Objects.nonNull(cpUserIdMap.get(user.getId()))? cpUserIdMap.get(user.getId()):0L);
|
||||
user.setHeartbeatVal(Objects.nonNull(liveHeartbeatMap.get(user.getId())) ? liveHeartbeatMap.get(user.getId()) : 0L);
|
||||
user.setCpList(cpInfoMap.get(user.getId()));
|
||||
liveMicrophone.setUser(user);
|
||||
})
|
||||
.collect(Collectors.toMap(LiveMicrophone::getMicIndex, v -> v));
|
||||
|
||||
@ -7,6 +7,7 @@ import com.red.circle.tool.core.text.StringUtils;
|
||||
import com.red.circle.other.inner.model.cmd.user.CpApplyQryCmd;
|
||||
import com.red.circle.other.inner.model.cmd.user.ListLatestCpCmd;
|
||||
import com.red.circle.other.inner.model.dto.user.CpRelationshipDTO;
|
||||
import com.red.circle.other.inner.model.dto.user.CpUserInfoDTO;
|
||||
import com.red.circle.other.inner.model.dto.user.UserCpApplyDTO;
|
||||
import com.red.circle.other.inner.model.dto.user.WeekCpUserIdDTO;
|
||||
import com.red.circle.other.inner.model.dto.user.WeekCpValueCountDTO;
|
||||
@ -155,4 +156,9 @@ public class UserCpClientEndpoint implements UserCpClientApi {
|
||||
public ResultResponse<Map<Long, Long>> getCpUserIdByUserIds(List<Long> userIds) {
|
||||
return ResultResponse.success(userCpClientService.getCpUserIdByUserIds(userIds));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultResponse<Map<Long, List<CpUserInfoDTO>>> getCpInfoByUserIds(List<Long> userIds) {
|
||||
return ResultResponse.success(userCpClientService.getCpInfoByUserIds(userIds));
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ package com.red.circle.other.app.inner.service.user.user;
|
||||
import com.red.circle.framework.dto.PageResult;
|
||||
import com.red.circle.other.inner.model.cmd.user.CpApplyQryCmd;
|
||||
import com.red.circle.other.inner.model.dto.user.CpRelationshipDTO;
|
||||
import com.red.circle.other.inner.model.dto.user.CpUserInfoDTO;
|
||||
import com.red.circle.other.inner.model.dto.user.UserCpApplyDTO;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
@ -70,4 +71,12 @@ public interface UserCpClientService {
|
||||
* @return cp用户id
|
||||
*/
|
||||
Map<Long, Long> getCpUserIdByUserIds(List<Long> userIds);
|
||||
|
||||
/**
|
||||
* 批量获取cp用户信息(含cpUserId和cpLevel).
|
||||
*
|
||||
* @param userIds 用户id列表
|
||||
* @return userId -> List<CpUserInfoDTO>
|
||||
*/
|
||||
Map<Long, List<CpUserInfoDTO>> getCpInfoByUserIds(List<Long> userIds);
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package com.red.circle.other.app.inner.service.user.user.impl;
|
||||
|
||||
import com.red.circle.framework.dto.PageResult;
|
||||
import com.red.circle.other.infra.database.cache.service.user.UserCpValueCacheService;
|
||||
import com.red.circle.other.infra.database.rds.entity.user.user.CpLevelConfig;
|
||||
import com.red.circle.other.infra.database.rds.entity.user.user.CpRelationship;
|
||||
import com.red.circle.other.infra.database.rds.service.user.user.CpApplyService;
|
||||
import com.red.circle.other.infra.database.rds.service.user.user.CpRelationshipService;
|
||||
@ -9,12 +10,15 @@ import com.red.circle.other.infra.database.rds.service.user.user.CpValueService;
|
||||
import com.red.circle.other.app.inner.convertor.user.UserCpInnerConvertor;
|
||||
import com.red.circle.other.inner.model.cmd.user.CpApplyQryCmd;
|
||||
import com.red.circle.other.inner.model.dto.user.CpRelationshipDTO;
|
||||
import com.red.circle.other.inner.model.dto.user.CpUserInfoDTO;
|
||||
import com.red.circle.other.inner.model.dto.user.UserCpApplyDTO;
|
||||
import com.red.circle.other.app.inner.service.user.user.UserCpClientService;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.red.circle.tool.core.collection.CollectionUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -89,4 +93,30 @@ public class UserCpClientServiceImpl implements UserCpClientService {
|
||||
HashMap::putAll);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, List<CpUserInfoDTO>> getCpInfoByUserIds(List<Long> userIds) {
|
||||
if (CollectionUtils.isEmpty(userIds)) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
List<CpRelationship> list = cpRelationshipService.query()
|
||||
.select(CpRelationship::getUserId, CpRelationship::getCpUserId, CpRelationship::getCpValId)
|
||||
.in(CpRelationship::getUserId, userIds)
|
||||
.list();
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
Set<Long> cpValIds = list.stream().map(CpRelationship::getCpValId).collect(Collectors.toSet());
|
||||
Map<Long, BigDecimal> cpValueMap = cpValueService.mapCpVal(cpValIds);
|
||||
return list.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
CpRelationship::getUserId,
|
||||
Collectors.mapping(v -> {
|
||||
BigDecimal cpVal = cpValueMap.getOrDefault(v.getCpValId(), BigDecimal.ZERO);
|
||||
return new CpUserInfoDTO()
|
||||
.setCpUserId(v.getCpUserId())
|
||||
.setCpLevel(CpLevelConfig.of(cpVal).getLevel());
|
||||
}, Collectors.toList())
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user