cp新功能-cp空间接口
(cherry picked from commit a8a14ae4126c54e65a38985c2fa0a92bfa636960)
This commit is contained in:
parent
edce43a4ec
commit
1303323df0
@ -4,7 +4,9 @@ import com.red.circle.common.business.dto.cmd.AppExtCommand;
|
||||
import com.red.circle.common.business.dto.cmd.UserIdCmd;
|
||||
import com.red.circle.framework.web.controller.BaseController;
|
||||
import com.red.circle.other.app.command.user.LoveLetterQueryCmdExe;
|
||||
import com.red.circle.other.app.dto.clientobject.user.relation.cp.CoupleSpaceCO;
|
||||
import com.red.circle.other.app.dto.clientobject.user.relation.cp.CpPairUserProfileCO;
|
||||
import com.red.circle.other.app.dto.cmd.user.relation.cp.CoupleSpaceQryCmd;
|
||||
import com.red.circle.other.domain.model.cp.loveletter.LoveLetterDetailCO;
|
||||
import com.red.circle.other.domain.model.cp.loveletter.LoveLetterWallCO;
|
||||
import com.red.circle.other.app.dto.cmd.user.relation.cp.CpApplyCmd;
|
||||
@ -146,4 +148,17 @@ public class CpRelationshipRestController extends BaseController {
|
||||
return loveLetterQueryCmdExe.queryLatestReceived(cmd);
|
||||
}
|
||||
|
||||
/**
|
||||
* CP空间.
|
||||
*
|
||||
* @eo.name CP空间
|
||||
* @eo.url /couple-space
|
||||
* @eo.method get
|
||||
* @eo.request-type formdata
|
||||
*/
|
||||
@GetMapping("/couple-space")
|
||||
public CoupleSpaceCO getCoupleSpace(@Validated CoupleSpaceQryCmd cmd) {
|
||||
return userCpRelationService.getCoupleSpace(cmd);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,125 @@
|
||||
package com.red.circle.other.app.command.user.query;
|
||||
|
||||
import com.red.circle.framework.core.asserts.ResponseAssert;
|
||||
import com.red.circle.other.app.dto.clientobject.user.relation.cp.CoupleSpaceCO;
|
||||
import com.red.circle.other.app.dto.cmd.user.relation.cp.CoupleSpaceQryCmd;
|
||||
import com.red.circle.other.infra.database.cache.service.cp.CpRelationshipCacheService;
|
||||
import com.red.circle.other.infra.database.rds.entity.props.PropsBackpack;
|
||||
import com.red.circle.other.infra.database.rds.entity.props.PropsSourceRecord;
|
||||
import com.red.circle.other.infra.database.rds.service.props.PropsBackpackService;
|
||||
import com.red.circle.other.infra.database.rds.service.props.PropsSourceRecordService;
|
||||
import com.red.circle.other.inner.asserts.user.UserErrorCode;
|
||||
import com.red.circle.other.inner.enums.material.PropsCommodityType;
|
||||
import com.red.circle.other.inner.model.dto.material.props.PropsResources;
|
||||
import com.red.circle.other.inner.model.dto.material.props.UserBackpackProps;
|
||||
import com.red.circle.other.inner.model.dto.user.CpSimpleUserProfileCO;
|
||||
import com.red.circle.tool.core.collection.CollectionUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* CP空间查询.
|
||||
*
|
||||
* @author tf
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class CoupleSpaceQryExe {
|
||||
|
||||
private final CpRelationshipCacheService cpRelationshipCacheService;
|
||||
private final PropsBackpackService propsBackpackService;
|
||||
private final PropsSourceRecordService propsSourceRecordService;
|
||||
|
||||
public CoupleSpaceCO execute(CoupleSpaceQryCmd cmd) {
|
||||
List<CpSimpleUserProfileCO> cpList = cpRelationshipCacheService.getUserCpList(cmd.requiredReqUserId());
|
||||
|
||||
CpSimpleUserProfileCO cpInfo = cpList.stream()
|
||||
.filter(cp -> cp.getCpUserId().equals(cmd.getCpUserId()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
ResponseAssert.notNull(UserErrorCode.USER_INFO_NOT_FOUND, cpInfo);
|
||||
|
||||
CoupleSpaceCO co = new CoupleSpaceCO();
|
||||
// 复制 CpSimpleUserProfileCO 所有字段
|
||||
co.setMeUserId(cpInfo.getMeUserId());
|
||||
co.setMeAccount(cpInfo.getMeAccount());
|
||||
co.setMeUserAvatar(cpInfo.getMeUserAvatar());
|
||||
co.setMeUserNickname(cpInfo.getMeUserNickname());
|
||||
co.setCpUserId(cpInfo.getCpUserId());
|
||||
co.setCpAccount(cpInfo.getCpAccount());
|
||||
co.setCpUserAvatar(cpInfo.getCpUserAvatar());
|
||||
co.setCpUserNickname(cpInfo.getCpUserNickname());
|
||||
co.setCpValId(cpInfo.getCpValId());
|
||||
co.setCpValue(cpInfo.getCpValue());
|
||||
co.setDays(cpInfo.getDays());
|
||||
co.setFirstDay(cpInfo.getFirstDay());
|
||||
co.setCreateTime(cpInfo.getCreateTime());
|
||||
co.setCpLevel(cpInfo.getCpLevel());
|
||||
co.setNextLevelExp(cpInfo.getNextLevelExp());
|
||||
co.setLoveHeartLevel(cpInfo.getLoveHeartLevel());
|
||||
co.setMicEffectLevel(cpInfo.getMicEffectLevel());
|
||||
co.setProfileCardLevel(cpInfo.getProfileCardLevel());
|
||||
co.setGiftWindowLevel(cpInfo.getGiftWindowLevel());
|
||||
co.setHasNonMicEffect(cpInfo.getHasNonMicEffect());
|
||||
co.setSelfRing(cpInfo.getSelfRing());
|
||||
|
||||
// 查双方共同拥有的 CP 戒指背包(取交集)
|
||||
co.setRingBackpackList(buildSharedRingBackpack(cmd.requiredReqUserId(), cmd.getCpUserId()));
|
||||
|
||||
return co;
|
||||
}
|
||||
|
||||
private List<UserBackpackProps> buildSharedRingBackpack(Long meUserId, Long cpUserId) {
|
||||
List<PropsBackpack> meBackpack = propsBackpackService
|
||||
.listNotExpiredByUserIdAndType(meUserId, PropsCommodityType.CP_RING);
|
||||
if (CollectionUtils.isEmpty(meBackpack)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<PropsBackpack> cpBackpack = propsBackpackService
|
||||
.listNotExpiredByUserIdAndType(cpUserId, PropsCommodityType.CP_RING);
|
||||
if (CollectionUtils.isEmpty(cpBackpack)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// 取双方共同拥有的 propsId 交集
|
||||
Set<Long> cpPropsIds = cpBackpack.stream()
|
||||
.map(PropsBackpack::getPropsId)
|
||||
.collect(Collectors.toSet());
|
||||
List<PropsBackpack> shared = meBackpack.stream()
|
||||
.filter(b -> cpPropsIds.contains(b.getPropsId()))
|
||||
.toList();
|
||||
if (CollectionUtils.isEmpty(shared)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// 批量查资源信息
|
||||
Set<Long> propsIds = shared.stream().map(PropsBackpack::getPropsId).collect(Collectors.toSet());
|
||||
Map<Long, PropsSourceRecord> sourceMap = propsSourceRecordService.mapByIds(propsIds);
|
||||
|
||||
return shared.stream().map(backpack -> {
|
||||
PropsSourceRecord source = sourceMap.get(backpack.getPropsId());
|
||||
if (source == null) {
|
||||
return null;
|
||||
}
|
||||
return new UserBackpackProps()
|
||||
.setUserId(backpack.getUserId())
|
||||
.setType(backpack.getType())
|
||||
.setExpireTime(backpack.getExpireTime())
|
||||
.setUseProps(backpack.getUseProps())
|
||||
.setAllowGive(backpack.getAllowGive())
|
||||
.setPropsResources(new PropsResources()
|
||||
.setId(source.getId())
|
||||
.setType(source.getType())
|
||||
.setName(source.getName())
|
||||
.setCover(source.getCover())
|
||||
.setSourceUrl(source.getSourceUrl())
|
||||
.setAmount(source.getAmount())
|
||||
);
|
||||
}).filter(Objects::nonNull).toList();
|
||||
}
|
||||
|
||||
}
|
||||
@ -8,15 +8,18 @@ import com.red.circle.other.app.command.user.LoveLetterQueryCmdExe;
|
||||
import com.red.circle.other.app.command.user.ProcessCpApplyCmd;
|
||||
import com.red.circle.other.app.command.user.SendCpApplyCmdExe;
|
||||
import com.red.circle.other.app.command.user.SendLoveLetterCmdExe;
|
||||
import com.red.circle.other.app.command.user.query.CoupleSpaceQryExe;
|
||||
import com.red.circle.other.app.command.user.query.CpApplyIdQryExe;
|
||||
import com.red.circle.other.app.command.user.query.UserCpPairUserProfileQryExe;
|
||||
import com.red.circle.other.app.command.user.query.UserCpRelationQryExe;
|
||||
import com.red.circle.other.app.command.user.query.UserCpRelationQueryV4Exe;
|
||||
import com.red.circle.other.app.dto.clientobject.user.relation.cp.CoupleSpaceCO;
|
||||
import com.red.circle.other.app.dto.clientobject.user.relation.cp.CpCabinUserProfileCO;
|
||||
import com.red.circle.other.app.dto.clientobject.user.relation.cp.CpPairUserProfileCO;
|
||||
import com.red.circle.other.app.dto.clientobject.user.relation.cp.CpUserProfileCO;
|
||||
import com.red.circle.other.domain.model.cp.loveletter.LoveLetterDetailCO;
|
||||
import com.red.circle.other.domain.model.cp.loveletter.LoveLetterWallCO;
|
||||
import com.red.circle.other.app.dto.cmd.user.relation.cp.CoupleSpaceQryCmd;
|
||||
import com.red.circle.other.app.dto.cmd.user.relation.cp.CpApplyCmd;
|
||||
import com.red.circle.other.app.dto.cmd.user.relation.cp.CpApplyDismissCmd;
|
||||
import com.red.circle.other.app.dto.cmd.user.relation.cp.ProcessApplyCmd;
|
||||
@ -46,6 +49,7 @@ public class UserCpRelationServiceImpl implements UserCpRelationService {
|
||||
private final DistributedLockUtil distributedLockUtil;
|
||||
private final SendLoveLetterCmdExe sendLoveLetterCmdExe;
|
||||
private final LoveLetterQueryCmdExe loveLetterQueryCmdExe;
|
||||
private final CoupleSpaceQryExe coupleSpaceQryExe;
|
||||
|
||||
@Override
|
||||
public CpUserProfileCO getCpUser(UserIdCmd cmd) {
|
||||
@ -94,7 +98,11 @@ public class UserCpRelationServiceImpl implements UserCpRelationService {
|
||||
distributedLockUtil.executeWithLock(key, () -> {
|
||||
sendLoveLetterCmdExe.execute(cmd);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public CoupleSpaceCO getCoupleSpace(CoupleSpaceQryCmd cmd) {
|
||||
return coupleSpaceQryExe.execute(cmd);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
package com.red.circle.other.app.dto.clientobject.user.relation.cp;
|
||||
|
||||
import com.red.circle.other.inner.model.dto.material.props.UserBackpackProps;
|
||||
import com.red.circle.other.inner.model.dto.user.CpSimpleUserProfileCO;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* CP空间页面数据.
|
||||
*
|
||||
* @author tf
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CoupleSpaceCO extends CpSimpleUserProfileCO {
|
||||
|
||||
/**
|
||||
* 当前CP组双方共同拥有的戒指背包列表(双方都有才展示).
|
||||
*/
|
||||
private List<UserBackpackProps> ringBackpackList;
|
||||
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package com.red.circle.other.app.dto.cmd.user.relation.cp;
|
||||
|
||||
import com.red.circle.common.business.dto.cmd.AppExtCommand;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* CP空间查询.
|
||||
*
|
||||
* @author tf
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class CoupleSpaceQryCmd extends AppExtCommand {
|
||||
|
||||
/**
|
||||
* CP用户id.
|
||||
*/
|
||||
@NotNull(message = "cpUserId required.")
|
||||
private Long cpUserId;
|
||||
|
||||
}
|
||||
@ -3,9 +3,11 @@ package com.red.circle.other.app.service.user.relation;
|
||||
import com.red.circle.common.business.dto.cmd.AppExtCommand;
|
||||
import com.red.circle.common.business.dto.cmd.UserIdCmd;
|
||||
import com.red.circle.common.business.dto.cmd.UserIdCommonCmd;
|
||||
import com.red.circle.other.app.dto.clientobject.user.relation.cp.CoupleSpaceCO;
|
||||
import com.red.circle.other.app.dto.clientobject.user.relation.cp.CpCabinUserProfileCO;
|
||||
import com.red.circle.other.app.dto.clientobject.user.relation.cp.CpPairUserProfileCO;
|
||||
import com.red.circle.other.app.dto.clientobject.user.relation.cp.CpUserProfileCO;
|
||||
import com.red.circle.other.app.dto.cmd.user.relation.cp.CoupleSpaceQryCmd;
|
||||
import com.red.circle.other.app.dto.cmd.user.relation.cp.CpApplyCmd;
|
||||
import com.red.circle.other.app.dto.cmd.user.relation.cp.CpApplyDismissCmd;
|
||||
import com.red.circle.other.app.dto.cmd.user.relation.cp.ProcessApplyCmd;
|
||||
@ -36,4 +38,6 @@ public interface UserCpRelationService {
|
||||
|
||||
void sendLoveLetter(SendLoveLetterCmd cmd);
|
||||
|
||||
CoupleSpaceCO getCoupleSpace(CoupleSpaceQryCmd cmd);
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user