feat: expose store status on props resources

This commit is contained in:
hy001 2026-05-17 01:02:17 +08:00
parent d17f75e42d
commit 3fc5d4a4ff
6 changed files with 148 additions and 84 deletions

View File

@ -2,11 +2,13 @@ package com.red.circle.other.inner.endpoint.material.props.api;
import com.red.circle.framework.dto.PageResult; import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.dto.ResultResponse; import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.other.inner.model.cmd.material.PropsCommodityStoreQryCmd; import com.red.circle.other.inner.model.cmd.material.PropsCommodityStoreQryCmd;
import com.red.circle.other.inner.model.dto.material.PropsCommodityStoreDTO; import com.red.circle.other.inner.model.dto.material.PropsCommodityStoreDTO;
import org.springframework.web.bind.annotation.GetMapping; import java.util.Map;
import org.springframework.web.bind.annotation.PostMapping; import java.util.Set;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
/** /**
@ -23,13 +25,21 @@ public interface PropsCommodityStoreClientApi {
* 获取平台指定资源. * 获取平台指定资源.
*/ */
@GetMapping("/getPropsCommodityStore") @GetMapping("/getPropsCommodityStore")
ResultResponse<PropsCommodityStoreDTO> getPropsCommodityStore( ResultResponse<PropsCommodityStoreDTO> getPropsCommodityStore(
@RequestParam("sysOrigin") String sysOrigin, @RequestParam("sysOrigin") String sysOrigin,
@RequestParam("sourceId") Long sourceId @RequestParam("sourceId") Long sourceId
); );
/** /**
* 商店分页列表. * 批量获取资源对应商品.
*/
@PostMapping("/mapBySourceIds")
ResultResponse<Map<Long, PropsCommodityStoreDTO>> mapBySourceIds(
@RequestParam("sysOrigin") String sysOrigin,
@RequestBody Set<Long> sourceIds);
/**
* 商店分页列表.
*/ */
@PostMapping("/pageOps") @PostMapping("/pageOps")
ResultResponse<PageResult<PropsCommodityStoreDTO>> pageOps( ResultResponse<PageResult<PropsCommodityStoreDTO>> pageOps(

View File

@ -4,18 +4,21 @@ import com.red.circle.console.app.convertor.PropsAppConvertor;
import com.red.circle.console.app.dto.clienobject.props.PropsResourcesOpsCO; import com.red.circle.console.app.dto.clienobject.props.PropsResourcesOpsCO;
import com.red.circle.console.app.dto.cmd.app.props.PropsSourceRecordSaveOrUpdateCmd; import com.red.circle.console.app.dto.cmd.app.props.PropsSourceRecordSaveOrUpdateCmd;
import com.red.circle.framework.core.asserts.ResponseAssert; import com.red.circle.framework.core.asserts.ResponseAssert;
import com.red.circle.framework.dto.PageResult; import com.red.circle.framework.dto.PageResult;
import com.red.circle.other.inner.endpoint.material.props.PropsRedPacketSkinClient; import com.red.circle.other.inner.endpoint.material.props.PropsCommodityStoreClient;
import com.red.circle.other.inner.endpoint.material.props.PropsSourceClient; import com.red.circle.other.inner.endpoint.material.props.PropsRedPacketSkinClient;
import com.red.circle.other.inner.enums.material.ConsolePropsTypeEnum; import com.red.circle.other.inner.endpoint.material.props.PropsSourceClient;
import com.red.circle.other.inner.model.cmd.material.PropsSourceRecordQryCmd; import com.red.circle.other.inner.enums.material.ConsolePropsTypeEnum;
import com.red.circle.other.inner.model.dto.material.PropsRedPacketSkinDTO; import com.red.circle.other.inner.model.cmd.material.PropsSourceRecordQryCmd;
import com.red.circle.other.inner.model.dto.material.PropsResourcesDTO; import com.red.circle.other.inner.model.dto.material.PropsCommodityStoreDTO;
import com.red.circle.other.inner.model.dto.material.PropsRedPacketSkinDTO;
import com.red.circle.other.inner.model.dto.material.PropsResourcesDTO;
import com.red.circle.tool.core.collection.CollectionUtils; import com.red.circle.tool.core.collection.CollectionUtils;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors; import java.util.Set;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -33,9 +36,10 @@ import org.springframework.stereotype.Service;
public class PropsSourceServiceImpl implements PropsSourceService { public class PropsSourceServiceImpl implements PropsSourceService {
@Qualifier("PropsAppConvertorNew") @Qualifier("PropsAppConvertorNew")
private final PropsAppConvertor propsAppConvertor; private final PropsAppConvertor propsAppConvertor;
private final PropsSourceClient propsSourceClient; private final PropsSourceClient propsSourceClient;
private final PropsRedPacketSkinClient propsRedPacketSkinClient; private final PropsRedPacketSkinClient propsRedPacketSkinClient;
private final PropsCommodityStoreClient propsCommodityStoreClient;
@Override @Override
public List<PropsResourcesDTO> listSysOrigin(String sysOrigin, String type) { public List<PropsResourcesDTO> listSysOrigin(String sysOrigin, String type) {
@ -62,14 +66,16 @@ public class PropsSourceServiceImpl implements PropsSourceService {
if (CollectionUtils.isEmpty(pageResult.getRecords())) { if (CollectionUtils.isEmpty(pageResult.getRecords())) {
return pageResult.emptyRecords(); return pageResult.emptyRecords();
} }
Map<Long, PropsRedPacketSkinDTO> redPacketSkinMap = ResponseAssert.requiredSuccess( Set<Long> sourceIds = pageResult.getRecords().stream().map(PropsResourcesDTO::getId).collect(
propsRedPacketSkinClient.mapRedPacketSkinByIds( Collectors.toSet());
pageResult.getRecords().stream().map(PropsResourcesDTO::getId).collect( Map<Long, PropsRedPacketSkinDTO> redPacketSkinMap = ResponseAssert.requiredSuccess(
Collectors.toSet()))); propsRedPacketSkinClient.mapRedPacketSkinByIds(sourceIds));
Map<Long, PropsCommodityStoreDTO> storeCommodityMap = ResponseAssert.requiredSuccess(
return pageResult.convert(propsResources -> { propsCommodityStoreClient.mapBySourceIds(qryCmd.getSysOrigin(), sourceIds));
PropsResourcesOpsCO propsResourcesOpsCO = propsAppConvertor.toPropsResourcesOpsCO(propsResources);
return pageResult.convert(propsResources -> {
PropsResourcesOpsCO propsResourcesOpsCO = propsAppConvertor.toPropsResourcesOpsCO(propsResources);
PropsRedPacketSkinDTO redPacketSkin = redPacketSkinMap.get(propsResources.getId()); PropsRedPacketSkinDTO redPacketSkin = redPacketSkinMap.get(propsResources.getId());
if (Objects.nonNull(redPacketSkin)) { if (Objects.nonNull(redPacketSkin)) {
propsResourcesOpsCO.setImNotOpenedUrl(redPacketSkin.getImNotOpenedUrl()); propsResourcesOpsCO.setImNotOpenedUrl(redPacketSkin.getImNotOpenedUrl());
@ -77,12 +83,13 @@ public class PropsSourceServiceImpl implements PropsSourceService {
propsResourcesOpsCO.setRoomNotOpenedUrl(redPacketSkin.getRoomNotOpenedUrl()); propsResourcesOpsCO.setRoomNotOpenedUrl(redPacketSkin.getRoomNotOpenedUrl());
propsResourcesOpsCO.setRoomOpenedUrl(redPacketSkin.getRoomOpenedUrl()); propsResourcesOpsCO.setRoomOpenedUrl(redPacketSkin.getRoomOpenedUrl());
propsResourcesOpsCO.setRoomSendCoverUrl(redPacketSkin.getRoomSendCoverUrl()); propsResourcesOpsCO.setRoomSendCoverUrl(redPacketSkin.getRoomSendCoverUrl());
propsResourcesOpsCO.setImSendCoverUrl(redPacketSkin.getImSendCoverUrl()); propsResourcesOpsCO.setImSendCoverUrl(redPacketSkin.getImSendCoverUrl());
propsResourcesOpsCO.setImOpenedUrlTwo(redPacketSkin.getImOpenedUrlTwo()); propsResourcesOpsCO.setImOpenedUrlTwo(redPacketSkin.getImOpenedUrlTwo());
} }
propsResourcesOpsCO.setTypeName(ConsolePropsTypeEnum.getDescValue(propsResources.getType())); propsResourcesOpsCO.setStoreCommodity(storeCommodityMap.get(propsResources.getId()));
return propsResourcesOpsCO; propsResourcesOpsCO.setTypeName(ConsolePropsTypeEnum.getDescValue(propsResources.getType()));
} return propsResourcesOpsCO;
}
); );
} }

View File

@ -1,9 +1,10 @@
package com.red.circle.console.app.dto.clienobject.props; package com.red.circle.console.app.dto.clienobject.props;
import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.red.circle.framework.dto.ClientObject; import com.red.circle.framework.dto.ClientObject;
import com.red.circle.other.inner.model.dto.material.PropsResourcesDTO; import com.red.circle.other.inner.model.dto.material.PropsCommodityStoreDTO;
import com.red.circle.other.inner.model.dto.material.PropsResourcesDTO;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.Timestamp; import java.sql.Timestamp;
import lombok.Data; import lombok.Data;
@ -63,13 +64,18 @@ public class PropsResourcesOpsCO extends ClientObject {
*/ */
private String expand; private String expand;
/** /**
* 底价. * 底价.
*/ */
private BigDecimal amount; private BigDecimal amount;
/** /**
* 0.未删除 1.已删除. * 对应道具商店商品.
*/
private PropsCommodityStoreDTO storeCommodity;
/**
* 0.未删除 1.已删除.
*/ */
private Boolean del; private Boolean del;

View File

@ -4,9 +4,11 @@ import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.dto.ResultResponse; import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.other.app.inner.service.material.props.PropsCommodityStoreClientService; import com.red.circle.other.app.inner.service.material.props.PropsCommodityStoreClientService;
import com.red.circle.other.inner.endpoint.material.props.api.PropsCommodityStoreClientApi; import com.red.circle.other.inner.endpoint.material.props.api.PropsCommodityStoreClientApi;
import com.red.circle.other.inner.model.cmd.material.PropsCommodityStoreQryCmd; import com.red.circle.other.inner.model.cmd.material.PropsCommodityStoreQryCmd;
import com.red.circle.other.inner.model.dto.material.PropsCommodityStoreDTO; import com.red.circle.other.inner.model.dto.material.PropsCommodityStoreDTO;
import lombok.RequiredArgsConstructor; import java.util.Map;
import java.util.Set;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -26,14 +28,21 @@ public class PropsCommodityStoreClientEndpoint implements PropsCommodityStoreCli
private final PropsCommodityStoreClientService propsCommodityStoreClientService; private final PropsCommodityStoreClientService propsCommodityStoreClientService;
@Override @Override
public ResultResponse<PropsCommodityStoreDTO> getPropsCommodityStore(String sysOrigin, public ResultResponse<PropsCommodityStoreDTO> getPropsCommodityStore(String sysOrigin,
Long sourceId) { Long sourceId) {
return ResultResponse.success( return ResultResponse.success(
propsCommodityStoreClientService.getPropsCommodityStore(sysOrigin, sourceId)); propsCommodityStoreClientService.getPropsCommodityStore(sysOrigin, sourceId));
} }
@Override @Override
public ResultResponse<PageResult<PropsCommodityStoreDTO>> pageOps( public ResultResponse<Map<Long, PropsCommodityStoreDTO>> mapBySourceIds(String sysOrigin,
Set<Long> sourceIds) {
return ResultResponse.success(
propsCommodityStoreClientService.mapBySourceIds(sysOrigin, sourceIds));
}
@Override
public ResultResponse<PageResult<PropsCommodityStoreDTO>> pageOps(
PropsCommodityStoreQryCmd qryCmd) { PropsCommodityStoreQryCmd qryCmd) {
return ResultResponse.success(propsCommodityStoreClientService.pageOps(qryCmd)); return ResultResponse.success(propsCommodityStoreClientService.pageOps(qryCmd));
} }

View File

@ -1,8 +1,10 @@
package com.red.circle.other.app.inner.service.material.props; package com.red.circle.other.app.inner.service.material.props;
import com.red.circle.framework.dto.PageResult; import com.red.circle.framework.dto.PageResult;
import com.red.circle.other.inner.model.cmd.material.PropsCommodityStoreQryCmd; import com.red.circle.other.inner.model.cmd.material.PropsCommodityStoreQryCmd;
import com.red.circle.other.inner.model.dto.material.PropsCommodityStoreDTO; import com.red.circle.other.inner.model.dto.material.PropsCommodityStoreDTO;
import java.util.Map;
import java.util.Set;
/** /**
* 道具商店. * 道具商店.
@ -14,10 +16,15 @@ public interface PropsCommodityStoreClientService {
/** /**
* 获取平台指定资源. * 获取平台指定资源.
*/ */
PropsCommodityStoreDTO getPropsCommodityStore(String sysOrigin, Long sourceId); PropsCommodityStoreDTO getPropsCommodityStore(String sysOrigin, Long sourceId);
/** /**
* 商店分页列表. * 批量获取资源对应商品.
*/
Map<Long, PropsCommodityStoreDTO> mapBySourceIds(String sysOrigin, Set<Long> sourceIds);
/**
* 商店分页列表.
*/ */
PageResult<PropsCommodityStoreDTO> pageOps(PropsCommodityStoreQryCmd qryCmd); PageResult<PropsCommodityStoreDTO> pageOps(PropsCommodityStoreQryCmd qryCmd);

View File

@ -4,13 +4,19 @@ import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.mybatis.constant.PageConstant; import com.red.circle.framework.mybatis.constant.PageConstant;
import com.red.circle.other.app.inner.convertor.material.PropsCommodityStoreInnerConvertor; import com.red.circle.other.app.inner.convertor.material.PropsCommodityStoreInnerConvertor;
import com.red.circle.other.app.inner.service.material.props.PropsCommodityStoreClientService; import com.red.circle.other.app.inner.service.material.props.PropsCommodityStoreClientService;
import com.red.circle.other.infra.database.rds.entity.props.PropsCommodityStore; import com.red.circle.other.infra.database.rds.entity.props.PropsCommodityStore;
import com.red.circle.other.infra.database.rds.service.props.PropsCommodityStoreService; import com.red.circle.other.infra.database.rds.service.props.PropsCommodityStoreService;
import com.red.circle.other.inner.model.cmd.material.PropsCommodityStoreQryCmd; import com.red.circle.other.inner.model.cmd.material.PropsCommodityStoreQryCmd;
import com.red.circle.other.inner.model.dto.material.PropsCommodityStoreDTO; import com.red.circle.other.inner.model.dto.material.PropsCommodityStoreDTO;
import com.red.circle.tool.core.text.StringUtils; import com.red.circle.tool.core.collection.CollectionUtils;
import java.util.Objects; import com.red.circle.tool.core.text.StringUtils;
import lombok.RequiredArgsConstructor; import java.util.Collections;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/** /**
@ -26,14 +32,33 @@ public class PropsCommodityStoreClientServiceImpl implements PropsCommodityStore
private final PropsCommodityStoreInnerConvertor propsCommodityStoreInnerConvertor; private final PropsCommodityStoreInnerConvertor propsCommodityStoreInnerConvertor;
@Override @Override
public PropsCommodityStoreDTO getPropsCommodityStore(String sysOrigin, Long sourceId) { public PropsCommodityStoreDTO getPropsCommodityStore(String sysOrigin, Long sourceId) {
return propsCommodityStoreInnerConvertor.toPropsCommodityStoreDTO( return propsCommodityStoreInnerConvertor.toPropsCommodityStoreDTO(
propsCommodityStoreService.getSourceIdById(sysOrigin, sourceId) propsCommodityStoreService.getSourceIdById(sysOrigin, sourceId)
); );
} }
@Override @Override
public PageResult<PropsCommodityStoreDTO> pageOps(PropsCommodityStoreQryCmd qryCmd) { public Map<Long, PropsCommodityStoreDTO> mapBySourceIds(String sysOrigin, Set<Long> sourceIds) {
if (StringUtils.isBlank(sysOrigin) || CollectionUtils.isEmpty(sourceIds)) {
return Collections.emptyMap();
}
return propsCommodityStoreService.query()
.eq(PropsCommodityStore::getSysOrigin, sysOrigin)
.in(PropsCommodityStore::getSourceId, sourceIds)
.eq(PropsCommodityStore::getDel, Boolean.FALSE)
.orderByDesc(PropsCommodityStore::getUpdateTime)
.list()
.stream()
.map(propsCommodityStoreInnerConvertor::toPropsCommodityStoreDTO)
.collect(Collectors.toMap(
PropsCommodityStoreDTO::getSourceId,
Function.identity(),
(first, ignored) -> first));
}
@Override
public PageResult<PropsCommodityStoreDTO> pageOps(PropsCommodityStoreQryCmd qryCmd) {
return propsCommodityStoreInnerConvertor.toPagePropsCommodityStoreDTO( return propsCommodityStoreInnerConvertor.toPagePropsCommodityStoreDTO(
propsCommodityStoreService.query() propsCommodityStoreService.query()
.eq(Objects.nonNull(qryCmd.getId()), PropsCommodityStore::getId, qryCmd.getId()) .eq(Objects.nonNull(qryCmd.getId()), PropsCommodityStore::getId, qryCmd.getId())