diff --git a/rc-service/rc-inner-api/other-inner/other-inner-api/src/main/java/com/red/circle/other/inner/endpoint/material/props/api/PropsCommodityStoreClientApi.java b/rc-service/rc-inner-api/other-inner/other-inner-api/src/main/java/com/red/circle/other/inner/endpoint/material/props/api/PropsCommodityStoreClientApi.java index 7b5e2b18..45d12ecc 100644 --- a/rc-service/rc-inner-api/other-inner/other-inner-api/src/main/java/com/red/circle/other/inner/endpoint/material/props/api/PropsCommodityStoreClientApi.java +++ b/rc-service/rc-inner-api/other-inner/other-inner-api/src/main/java/com/red/circle/other/inner/endpoint/material/props/api/PropsCommodityStoreClientApi.java @@ -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.ResultResponse; -import com.red.circle.other.inner.model.cmd.material.PropsCommodityStoreQryCmd; -import com.red.circle.other.inner.model.dto.material.PropsCommodityStoreDTO; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; +import com.red.circle.other.inner.model.cmd.material.PropsCommodityStoreQryCmd; +import com.red.circle.other.inner.model.dto.material.PropsCommodityStoreDTO; +import java.util.Map; +import java.util.Set; +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; /** @@ -23,13 +25,21 @@ public interface PropsCommodityStoreClientApi { * 获取平台指定资源. */ @GetMapping("/getPropsCommodityStore") - ResultResponse getPropsCommodityStore( - @RequestParam("sysOrigin") String sysOrigin, - @RequestParam("sourceId") Long sourceId - ); - - /** - * 商店分页列表. + ResultResponse getPropsCommodityStore( + @RequestParam("sysOrigin") String sysOrigin, + @RequestParam("sourceId") Long sourceId + ); + + /** + * 批量获取资源对应商品. + */ + @PostMapping("/mapBySourceIds") + ResultResponse> mapBySourceIds( + @RequestParam("sysOrigin") String sysOrigin, + @RequestBody Set sourceIds); + + /** + * 商店分页列表. */ @PostMapping("/pageOps") ResultResponse> pageOps( diff --git a/rc-service/rc-service-console/console-application/src/main/java/com/red/circle/console/app/service/app/props/PropsSourceServiceImpl.java b/rc-service/rc-service-console/console-application/src/main/java/com/red/circle/console/app/service/app/props/PropsSourceServiceImpl.java index debafb8b..1ec4c8af 100644 --- a/rc-service/rc-service-console/console-application/src/main/java/com/red/circle/console/app/service/app/props/PropsSourceServiceImpl.java +++ b/rc-service/rc-service-console/console-application/src/main/java/com/red/circle/console/app/service/app/props/PropsSourceServiceImpl.java @@ -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.cmd.app.props.PropsSourceRecordSaveOrUpdateCmd; import com.red.circle.framework.core.asserts.ResponseAssert; -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.PropsSourceClient; -import com.red.circle.other.inner.enums.material.ConsolePropsTypeEnum; -import com.red.circle.other.inner.model.cmd.material.PropsSourceRecordQryCmd; -import com.red.circle.other.inner.model.dto.material.PropsRedPacketSkinDTO; -import com.red.circle.other.inner.model.dto.material.PropsResourcesDTO; +import com.red.circle.framework.dto.PageResult; +import com.red.circle.other.inner.endpoint.material.props.PropsCommodityStoreClient; +import com.red.circle.other.inner.endpoint.material.props.PropsRedPacketSkinClient; +import com.red.circle.other.inner.endpoint.material.props.PropsSourceClient; +import com.red.circle.other.inner.enums.material.ConsolePropsTypeEnum; +import com.red.circle.other.inner.model.cmd.material.PropsSourceRecordQryCmd; +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 java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.stream.Collectors; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; @@ -33,9 +36,10 @@ import org.springframework.stereotype.Service; public class PropsSourceServiceImpl implements PropsSourceService { @Qualifier("PropsAppConvertorNew") - private final PropsAppConvertor propsAppConvertor; - private final PropsSourceClient propsSourceClient; - private final PropsRedPacketSkinClient propsRedPacketSkinClient; + private final PropsAppConvertor propsAppConvertor; + private final PropsSourceClient propsSourceClient; + private final PropsRedPacketSkinClient propsRedPacketSkinClient; + private final PropsCommodityStoreClient propsCommodityStoreClient; @Override public List listSysOrigin(String sysOrigin, String type) { @@ -62,14 +66,16 @@ public class PropsSourceServiceImpl implements PropsSourceService { if (CollectionUtils.isEmpty(pageResult.getRecords())) { return pageResult.emptyRecords(); } - Map redPacketSkinMap = ResponseAssert.requiredSuccess( - propsRedPacketSkinClient.mapRedPacketSkinByIds( - pageResult.getRecords().stream().map(PropsResourcesDTO::getId).collect( - Collectors.toSet()))); - - return pageResult.convert(propsResources -> { - PropsResourcesOpsCO propsResourcesOpsCO = propsAppConvertor.toPropsResourcesOpsCO(propsResources); - + Set sourceIds = pageResult.getRecords().stream().map(PropsResourcesDTO::getId).collect( + Collectors.toSet()); + Map redPacketSkinMap = ResponseAssert.requiredSuccess( + propsRedPacketSkinClient.mapRedPacketSkinByIds(sourceIds)); + Map storeCommodityMap = ResponseAssert.requiredSuccess( + propsCommodityStoreClient.mapBySourceIds(qryCmd.getSysOrigin(), sourceIds)); + + return pageResult.convert(propsResources -> { + PropsResourcesOpsCO propsResourcesOpsCO = propsAppConvertor.toPropsResourcesOpsCO(propsResources); + PropsRedPacketSkinDTO redPacketSkin = redPacketSkinMap.get(propsResources.getId()); if (Objects.nonNull(redPacketSkin)) { propsResourcesOpsCO.setImNotOpenedUrl(redPacketSkin.getImNotOpenedUrl()); @@ -77,12 +83,13 @@ public class PropsSourceServiceImpl implements PropsSourceService { propsResourcesOpsCO.setRoomNotOpenedUrl(redPacketSkin.getRoomNotOpenedUrl()); propsResourcesOpsCO.setRoomOpenedUrl(redPacketSkin.getRoomOpenedUrl()); propsResourcesOpsCO.setRoomSendCoverUrl(redPacketSkin.getRoomSendCoverUrl()); - propsResourcesOpsCO.setImSendCoverUrl(redPacketSkin.getImSendCoverUrl()); - propsResourcesOpsCO.setImOpenedUrlTwo(redPacketSkin.getImOpenedUrlTwo()); - } - propsResourcesOpsCO.setTypeName(ConsolePropsTypeEnum.getDescValue(propsResources.getType())); - return propsResourcesOpsCO; - } + propsResourcesOpsCO.setImSendCoverUrl(redPacketSkin.getImSendCoverUrl()); + propsResourcesOpsCO.setImOpenedUrlTwo(redPacketSkin.getImOpenedUrlTwo()); + } + propsResourcesOpsCO.setStoreCommodity(storeCommodityMap.get(propsResources.getId())); + propsResourcesOpsCO.setTypeName(ConsolePropsTypeEnum.getDescValue(propsResources.getType())); + return propsResourcesOpsCO; + } ); } diff --git a/rc-service/rc-service-console/console-client/src/main/java/com/red/circle/console/app/dto/clienobject/props/PropsResourcesOpsCO.java b/rc-service/rc-service-console/console-client/src/main/java/com/red/circle/console/app/dto/clienobject/props/PropsResourcesOpsCO.java index 43a4b449..a0d9999c 100644 --- a/rc-service/rc-service-console/console-client/src/main/java/com/red/circle/console/app/dto/clienobject/props/PropsResourcesOpsCO.java +++ b/rc-service/rc-service-console/console-client/src/main/java/com/red/circle/console/app/dto/clienobject/props/PropsResourcesOpsCO.java @@ -1,9 +1,10 @@ package com.red.circle.console.app.dto.clienobject.props; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; -import com.red.circle.framework.dto.ClientObject; -import com.red.circle.other.inner.model.dto.material.PropsResourcesDTO; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import com.red.circle.framework.dto.ClientObject; +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.sql.Timestamp; import lombok.Data; @@ -63,13 +64,18 @@ public class PropsResourcesOpsCO extends ClientObject { */ private String expand; - /** - * 底价. - */ - private BigDecimal amount; - - /** - * 0.未删除 1.已删除. + /** + * 底价. + */ + private BigDecimal amount; + + /** + * 对应道具商店商品. + */ + private PropsCommodityStoreDTO storeCommodity; + + /** + * 0.未删除 1.已删除. */ private Boolean del; diff --git a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/material/props/PropsCommodityStoreClientEndpoint.java b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/material/props/PropsCommodityStoreClientEndpoint.java index dadff507..cb88532b 100644 --- a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/material/props/PropsCommodityStoreClientEndpoint.java +++ b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/endpoint/material/props/PropsCommodityStoreClientEndpoint.java @@ -4,9 +4,11 @@ import com.red.circle.framework.dto.PageResult; import com.red.circle.framework.dto.ResultResponse; 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.model.cmd.material.PropsCommodityStoreQryCmd; -import com.red.circle.other.inner.model.dto.material.PropsCommodityStoreDTO; -import lombok.RequiredArgsConstructor; +import com.red.circle.other.inner.model.cmd.material.PropsCommodityStoreQryCmd; +import com.red.circle.other.inner.model.dto.material.PropsCommodityStoreDTO; +import java.util.Map; +import java.util.Set; +import lombok.RequiredArgsConstructor; import org.springframework.http.MediaType; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.RequestMapping; @@ -26,14 +28,21 @@ public class PropsCommodityStoreClientEndpoint implements PropsCommodityStoreCli private final PropsCommodityStoreClientService propsCommodityStoreClientService; @Override - public ResultResponse getPropsCommodityStore(String sysOrigin, - Long sourceId) { - return ResultResponse.success( - propsCommodityStoreClientService.getPropsCommodityStore(sysOrigin, sourceId)); - } - - @Override - public ResultResponse> pageOps( + public ResultResponse getPropsCommodityStore(String sysOrigin, + Long sourceId) { + return ResultResponse.success( + propsCommodityStoreClientService.getPropsCommodityStore(sysOrigin, sourceId)); + } + + @Override + public ResultResponse> mapBySourceIds(String sysOrigin, + Set sourceIds) { + return ResultResponse.success( + propsCommodityStoreClientService.mapBySourceIds(sysOrigin, sourceIds)); + } + + @Override + public ResultResponse> pageOps( PropsCommodityStoreQryCmd qryCmd) { return ResultResponse.success(propsCommodityStoreClientService.pageOps(qryCmd)); } diff --git a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/material/props/PropsCommodityStoreClientService.java b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/material/props/PropsCommodityStoreClientService.java index 34af60e0..18536ffa 100644 --- a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/material/props/PropsCommodityStoreClientService.java +++ b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/material/props/PropsCommodityStoreClientService.java @@ -1,8 +1,10 @@ package com.red.circle.other.app.inner.service.material.props; -import com.red.circle.framework.dto.PageResult; -import com.red.circle.other.inner.model.cmd.material.PropsCommodityStoreQryCmd; -import com.red.circle.other.inner.model.dto.material.PropsCommodityStoreDTO; +import com.red.circle.framework.dto.PageResult; +import com.red.circle.other.inner.model.cmd.material.PropsCommodityStoreQryCmd; +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 mapBySourceIds(String sysOrigin, Set sourceIds); + + /** + * 商店分页列表. */ PageResult pageOps(PropsCommodityStoreQryCmd qryCmd); diff --git a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/material/props/impl/PropsCommodityStoreClientServiceImpl.java b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/material/props/impl/PropsCommodityStoreClientServiceImpl.java index f29b6c00..3e5909fe 100644 --- a/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/material/props/impl/PropsCommodityStoreClientServiceImpl.java +++ b/rc-service/rc-service-other/other-inner-endpoint/src/main/java/com/red/circle/other/app/inner/service/material/props/impl/PropsCommodityStoreClientServiceImpl.java @@ -4,13 +4,19 @@ import com.red.circle.framework.dto.PageResult; 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.service.material.props.PropsCommodityStoreClientService; -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.inner.model.cmd.material.PropsCommodityStoreQryCmd; -import com.red.circle.other.inner.model.dto.material.PropsCommodityStoreDTO; -import com.red.circle.tool.core.text.StringUtils; -import java.util.Objects; -import lombok.RequiredArgsConstructor; +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.inner.model.cmd.material.PropsCommodityStoreQryCmd; +import com.red.circle.other.inner.model.dto.material.PropsCommodityStoreDTO; +import com.red.circle.tool.core.collection.CollectionUtils; +import com.red.circle.tool.core.text.StringUtils; +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; /** @@ -26,14 +32,33 @@ public class PropsCommodityStoreClientServiceImpl implements PropsCommodityStore private final PropsCommodityStoreInnerConvertor propsCommodityStoreInnerConvertor; @Override - public PropsCommodityStoreDTO getPropsCommodityStore(String sysOrigin, Long sourceId) { - return propsCommodityStoreInnerConvertor.toPropsCommodityStoreDTO( - propsCommodityStoreService.getSourceIdById(sysOrigin, sourceId) - ); - } - - @Override - public PageResult pageOps(PropsCommodityStoreQryCmd qryCmd) { + public PropsCommodityStoreDTO getPropsCommodityStore(String sysOrigin, Long sourceId) { + return propsCommodityStoreInnerConvertor.toPropsCommodityStoreDTO( + propsCommodityStoreService.getSourceIdById(sysOrigin, sourceId) + ); + } + + @Override + public Map mapBySourceIds(String sysOrigin, Set 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 pageOps(PropsCommodityStoreQryCmd qryCmd) { return propsCommodityStoreInnerConvertor.toPagePropsCommodityStoreDTO( propsCommodityStoreService.query() .eq(Objects.nonNull(qryCmd.getId()), PropsCommodityStore::getId, qryCmd.getId())