Skip to content

Commit

Permalink
统一 boot 和 cloud 代码
Browse files Browse the repository at this point in the history
  • Loading branch information
YunaiV committed Oct 23, 2023
1 parent 633a4c5 commit 7bff98b
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ public CommonResult<PageResult<AppCouponTemplateRespVO>> getCouponTemplatePage(A
*/
private Long getProductScopeValue(Integer productScope, Long spuId) {
// 通用券:没有商品范围
if (productScope == null || ObjectUtils.equalsAny(productScope, PromotionProductScopeEnum.ALL.getScope(), null)) {
if (ObjectUtils.equalsAny(productScope, PromotionProductScopeEnum.ALL.getScope(), null)) {
return null;
}
// 品类券:查询商品的品类编号
if (Objects.equals(productScope, PromotionProductScopeEnum.CATEGORY.getScope()) && spuId != null) {
return Optional.ofNullable(productSpuApi.getSpu(spuId))
.map(ProductSpuRespDTO::getCategoryId).orElse(null);
ProductSpuRespDTO spu = productSpuApi.getSpu(spuId);
return spu != null ? spu.getCategoryId() : null;
}
// 商品卷:直接返回
return spuId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ private void validateProductExists(Long spuId, List<CombinationProductBaseVO> pr
}

// 2. 校验商品 sku 都存在
Map<Long, ProductSkuRespDTO> skuMap = convertMap(productSkuApi.getSkuListBySpuId(singletonList(spuId)),
ProductSkuRespDTO::getId);
List<ProductSkuRespDTO> skus = productSkuApi.getSkuListBySpuId(singletonList(spuId));
Map<Long, ProductSkuRespDTO> skuMap = convertMap(skus, ProductSkuRespDTO::getId);
products.forEach(product -> {
if (!skuMap.containsKey(product.getSkuId())) {
throw exception(SKU_NOT_EXISTS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
Expand Down Expand Up @@ -80,12 +79,11 @@ public void validCoupon(CouponDO coupon) {
public PageResult<CouponDO> getCouponPage(CouponPageReqVO pageReqVO) {
// 获得用户编号
if (StrUtil.isNotEmpty(pageReqVO.getNickname())) {
Set<Long> userIds = CollectionUtils.convertSet(memberUserApi.getUserListByNickname(pageReqVO.getNickname()),
MemberUserRespDTO::getId);
if (CollUtil.isEmpty(userIds)) {
List<MemberUserRespDTO> users = memberUserApi.getUserListByNickname(pageReqVO.getNickname());
if (CollUtil.isEmpty(users)) {
return PageResult.empty();
}
pageReqVO.setUserIds(userIds);
pageReqVO.setUserIds(convertSet(users, MemberUserRespDTO::getId));
}
// 分页查询
return couponMapper.selectPage(pageReqVO);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ private void validateProductExists(Long spuId, List<SeckillProductBaseVO> produc
}

// 2. 校验商品 sku 都存在
Map<Long, ProductSkuRespDTO> skuMap = convertMap(productSkuApi.getSkuListBySpuId(singletonList(spuId)),
ProductSkuRespDTO::getId);
List<ProductSkuRespDTO> skus = productSkuApi.getSkuListBySpuId(singletonList(spuId));
Map<Long, ProductSkuRespDTO> skuMap = convertMap(skus, ProductSkuRespDTO::getId);
products.forEach(product -> {
if (!skuMap.containsKey(product.getSkuId())) {
throw exception(SKU_NOT_EXISTS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public CommonResult<Boolean> updateBrokerageEnabled(@Valid @RequestBody Brokerag
@PreAuthorize("@ss.hasPermission('trade:brokerage-user:query')")
public CommonResult<BrokerageUserRespVO> getBrokerageUser(@RequestParam("id") Long id) {
BrokerageUserDO brokerageUser = brokerageUserService.getBrokerageUser(id);
// TODO @疯狂:是不是搞成一个统一的 convert?
BrokerageUserRespVO respVO = BrokerageUserConvert.INSTANCE.convert(brokerageUser);
return success(BrokerageUserConvert.INSTANCE.copyTo(memberUserApi.getUser(id), respVO));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ public PageResult<AppBrokerageUserChildSummaryRespVO> getBrokerageUserChildSumma
return PageResult.empty();
}
// 1.2 根据昵称过滤下级用户
Map<Long, MemberUserRespDTO> userMap = convertMapByFilter(memberUserApi.getUserList(childIds),
List<MemberUserRespDTO> users = memberUserApi.getUserList(childIds);
Map<Long, MemberUserRespDTO> userMap = convertMapByFilter(users,
user -> StrUtil.contains(user.getNickname(), pageReqVO.getNickname()),
MemberUserRespDTO::getId);
if (CollUtil.isEmpty(userMap)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public interface MemberUserApi {
* @return 会员用户 Map
*/
default Map<Long, MemberUserRespDTO> getUserMap(Collection<Long> ids) {
return convertMap(getUserList(ids), MemberUserRespDTO::getId);
List<MemberUserRespDTO> list = getUserList(ids);
return convertMap(list, MemberUserRespDTO::getId);
}

/**
Expand Down

0 comments on commit 7bff98b

Please sign in to comment.