Commit c701c5ab by Lizh

对比老接口的返回结果,调整新接口返回结构

parent 05642cf7
...@@ -2,6 +2,7 @@ package com.jomalls.custom.app.aspect; ...@@ -2,6 +2,7 @@ package com.jomalls.custom.app.aspect;
import com.jomalls.custom.app.annotation.RequiresPermissions; import com.jomalls.custom.app.annotation.RequiresPermissions;
import com.jomalls.custom.app.annotation.RequiresRoles; import com.jomalls.custom.app.annotation.RequiresRoles;
import com.jomalls.custom.app.constant.Constants;
import com.jomalls.custom.enums.CodeEnum; import com.jomalls.custom.enums.CodeEnum;
import com.jomalls.custom.app.exception.ServiceException; import com.jomalls.custom.app.exception.ServiceException;
import com.jomalls.custom.app.service.PermissionService; import com.jomalls.custom.app.service.PermissionService;
...@@ -64,7 +65,7 @@ public class PermissionAspect { ...@@ -64,7 +65,7 @@ public class PermissionAspect {
boolean hasPermission; boolean hasPermission;
if (mode == RequiresPermissions.RequireMode.ALL) { if (mode == RequiresPermissions.RequireMode.ALL) {
String[] permissions = permission.split(","); String[] permissions = permission.split(Constants.COMMA);
hasPermission = true; hasPermission = true;
for (String p : permissions) { for (String p : permissions) {
if (!permissionService.hasPermi(p.trim())) { if (!permissionService.hasPermi(p.trim())) {
...@@ -103,7 +104,7 @@ public class PermissionAspect { ...@@ -103,7 +104,7 @@ public class PermissionAspect {
boolean hasRole; boolean hasRole;
if (mode == RequiresPermissions.RequireMode.ALL) { if (mode == RequiresPermissions.RequireMode.ALL) {
// 必须拥有所有角色 // 必须拥有所有角色
String[] roleArray = roles.split(","); String[] roleArray = roles.split(Constants.COMMA);
hasRole = true; hasRole = true;
for (String r : roleArray) { for (String r : roleArray) {
if (!permissionService.hasRole(r.trim())) { if (!permissionService.hasRole(r.trim())) {
......
...@@ -11,4 +11,13 @@ public class Constants { ...@@ -11,4 +11,13 @@ public class Constants {
* map初始化大小 * map初始化大小
*/ */
public static final int DEFAULT_INITIAL_CAPACITY = 1 << 4; public static final int DEFAULT_INITIAL_CAPACITY = 1 << 4;
/** 并行查询超时时间(秒) */
public static final long QUERY_TIMEOUT_SECONDS = 30;
/** 默认编码 */
public static final String DEFAULT_CHARSET = "UTF-8";
/** 逗号 */
public static final String COMMA = ",";
} }
package com.jomalls.custom.app.dto; package com.jomalls.custom.app.dto;
import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.JsonSetter;
import com.jomalls.custom.app.constant.Constants;
import com.jomalls.custom.page.PageRequest; import com.jomalls.custom.page.PageRequest;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.*; import jakarta.validation.constraints.*;
...@@ -147,9 +148,9 @@ public class CustomProductInfoQuerySnakeDTO extends PageRequest { ...@@ -147,9 +148,9 @@ public class CustomProductInfoQuerySnakeDTO extends PageRequest {
/** 兼容逗号分隔多值与单值 */ /** 兼容逗号分隔多值与单值 */
@JsonSetter("status") @JsonSetter("status")
public void setStatusValue(Object value) { public void setStatusValue(Object value) {
if (value instanceof String s && s.contains(",")) { if (value instanceof String s && s.contains(Constants.COMMA)) {
try { try {
this.statusList = Arrays.stream(s.split(",")) this.statusList = Arrays.stream(s.split(Constants.COMMA))
.map(String::trim).filter(v -> !v.isEmpty()) .map(String::trim).filter(v -> !v.isEmpty())
.map(Integer::parseInt).collect(Collectors.toList()); .map(Integer::parseInt).collect(Collectors.toList());
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
......
package com.jomalls.custom.app.service; package com.jomalls.custom.app.service;
import com.jomalls.custom.app.vo.CustomProductFactoryPriceRelSnakeVO; import com.jomalls.custom.app.vo.*;
import com.jomalls.custom.app.vo.CustomProductInfoPageSnakeVO;
import com.jomalls.custom.app.vo.CustomProductInfoSnakeVO;
import com.jomalls.custom.app.vo.CustomProductItemSnakeVO;
import com.jomalls.custom.dal.entity.DbDiyUserEntity; import com.jomalls.custom.dal.entity.DbDiyUserEntity;
import java.util.List; import java.util.List;
......
package com.jomalls.custom.app.service.impl; package com.jomalls.custom.app.service.impl;
import com.jomalls.custom.app.constant.Constants;
import com.jomalls.custom.app.dto.UpdateSalesPriceSnakeDTO; import com.jomalls.custom.app.dto.UpdateSalesPriceSnakeDTO;
import com.jomalls.custom.app.exception.ServiceException; import com.jomalls.custom.app.exception.ServiceException;
import com.jomalls.custom.app.service.CustomProductItemService; import com.jomalls.custom.app.service.CustomProductItemService;
import com.jomalls.custom.app.service.DiyUserService; import com.jomalls.custom.app.service.DiyUserService;
import com.jomalls.custom.app.utils.BeanMapper; import com.jomalls.custom.app.utils.BeanMapper;
import com.jomalls.custom.app.vo.CustomProductFactoryPriceRelSnakeVO; import com.jomalls.custom.app.vo.*;
import com.jomalls.custom.app.vo.CustomProductInfoSnakeVO;
import com.jomalls.custom.app.vo.CustomProductItemSnakeVO;
import com.jomalls.custom.dal.entity.*; import com.jomalls.custom.dal.entity.*;
import com.jomalls.custom.domain.service.*; import com.jomalls.custom.domain.service.*;
import com.jomalls.custom.security.SecurityUtils; import com.jomalls.custom.security.SecurityUtils;
...@@ -20,7 +19,6 @@ import org.springframework.util.CollectionUtils; ...@@ -20,7 +19,6 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -301,7 +299,7 @@ public class CustomProductItemServiceImpl implements CustomProductItemService { ...@@ -301,7 +299,7 @@ public class CustomProductItemServiceImpl implements CustomProductItemService {
diyUserService.setProductItemExternalPrice(user, vo, factoryPriceVOList, productInfoVO); diyUserService.setProductItemExternalPrice(user, vo, factoryPriceVOList, productInfoVO);
} }
vo.setCustomProductInfo(productInfoVO); vo.setCustomProductInfo(BeanMapper.mapper().convert(productInfoVO, BasicCustomProductInfoSnakeModel.class));
vo.setFactoryPriceList(factoryPriceVOList); vo.setFactoryPriceList(factoryPriceVOList);
return vo; return vo;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
...@@ -350,7 +348,7 @@ public class CustomProductItemServiceImpl implements CustomProductItemService { ...@@ -350,7 +348,7 @@ public class CustomProductItemServiceImpl implements CustomProductItemService {
private CustomProductInfoSnakeVO buildProductInfoVO(CustomProductInfoEntity entity) { private CustomProductInfoSnakeVO buildProductInfoVO(CustomProductInfoEntity entity) {
CustomProductInfoSnakeVO vo = BeanMapper.snakeCase().convert(entity, CustomProductInfoSnakeVO.class); CustomProductInfoSnakeVO vo = BeanMapper.snakeCase().convert(entity, CustomProductInfoSnakeVO.class);
if (StringUtils.hasText(vo.getColor_images())) { if (StringUtils.hasText(vo.getColor_images())) {
vo.setColorImageList(Arrays.asList(vo.getColor_images().split(","))); vo.setColorImageList(Arrays.asList(vo.getColor_images().split(Constants.COMMA)));
} }
vo.setProductList(null); vo.setProductList(null);
return vo; return vo;
......
package com.jomalls.custom.app.service.impl; package com.jomalls.custom.app.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jomalls.custom.app.exception.ServiceException;
import com.jomalls.custom.app.service.DiyUserService; import com.jomalls.custom.app.service.DiyUserService;
import com.jomalls.custom.app.utils.BeanMapper;
import com.jomalls.custom.app.vo.*; import com.jomalls.custom.app.vo.*;
import com.jomalls.custom.dal.entity.DbDiyEntity;
import com.jomalls.custom.dal.entity.DbDiyUserEntity; import com.jomalls.custom.dal.entity.DbDiyUserEntity;
import com.jomalls.custom.domain.service.DbDiyUserDomainService; import com.jomalls.custom.domain.service.DbDiyUserDomainService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
...@@ -17,7 +12,6 @@ import org.springframework.stereotype.Service; ...@@ -17,7 +12,6 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* DIY 用户服务实现 * DIY 用户服务实现
...@@ -75,7 +69,7 @@ public class DiyUserServiceImpl implements DiyUserService { ...@@ -75,7 +69,7 @@ public class DiyUserServiceImpl implements DiyUserService {
// 子项的 sales_price(对齐 TS:328-332) // 子项的 sales_price(对齐 TS:328-332)
if (vo.getProductList() != null) { if (vo.getProductList() != null) {
for (CustomProductItemSnakeVO item : vo.getProductList()) { for (BasicCustomProductItemSnakeModel item : vo.getProductList()) {
if (item.getSales_price() != null) { if (item.getSales_price() != null) {
item.setSales_price(item.getSales_price().multiply(discountRate).setScale(2, RoundingMode.HALF_UP)); item.setSales_price(item.getSales_price().multiply(discountRate).setScale(2, RoundingMode.HALF_UP));
} }
......
package com.jomalls.custom.app.service.impl; package com.jomalls.custom.app.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jomalls.custom.app.constant.Constants;
import com.jomalls.custom.app.exception.ServiceException; import com.jomalls.custom.app.exception.ServiceException;
import com.jomalls.custom.app.service.ProductTemplateInfoService; import com.jomalls.custom.app.service.ProductTemplateInfoService;
import com.jomalls.custom.app.utils.BeanMapper; import com.jomalls.custom.app.utils.BeanMapper;
...@@ -13,6 +14,7 @@ import com.jomalls.custom.integrate.model.PropertyValueModel; ...@@ -13,6 +14,7 @@ import com.jomalls.custom.integrate.model.PropertyValueModel;
import com.jomalls.custom.integrate.service.SaasAdminService; import com.jomalls.custom.integrate.service.SaasAdminService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -36,9 +38,6 @@ import java.util.stream.Collectors; ...@@ -36,9 +38,6 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor @RequiredArgsConstructor
public class ProductTemplateInfoServiceImpl implements ProductTemplateInfoService { public class ProductTemplateInfoServiceImpl implements ProductTemplateInfoService {
/** 并行查询超时时间(秒) */
private static final long QUERY_TIMEOUT_SECONDS = 30;
private final ProductTemplateInfoDomainService productTemplateInfoDomainService; private final ProductTemplateInfoDomainService productTemplateInfoDomainService;
private final ProductTemplateItemDomainService productTemplateItemDomainService; private final ProductTemplateItemDomainService productTemplateItemDomainService;
private final ProductTemplateRemarkDomainService productTemplateRemarkDomainService; private final ProductTemplateRemarkDomainService productTemplateRemarkDomainService;
...@@ -49,7 +48,7 @@ public class ProductTemplateInfoServiceImpl implements ProductTemplateInfoServic ...@@ -49,7 +48,7 @@ public class ProductTemplateInfoServiceImpl implements ProductTemplateInfoServic
private final SaasAdminService saasAdminService; private final SaasAdminService saasAdminService;
private final ThreadPoolExecutor threadPoolExecutor; private final ThreadPoolExecutor threadPoolExecutor;
// ==================== getByIdOrSku ==================== private static final String UNDER_LINE = "_";
@Override @Override
public ProductTemplateInfoSnakeVO getByIdOrSku(Integer id, String sku) { public ProductTemplateInfoSnakeVO getByIdOrSku(Integer id, String sku) {
...@@ -76,7 +75,7 @@ public class ProductTemplateInfoServiceImpl implements ProductTemplateInfoServic ...@@ -76,7 +75,7 @@ public class ProductTemplateInfoServiceImpl implements ProductTemplateInfoServic
// 3. 等待所有并行查询完成 // 3. 等待所有并行查询完成
CompletableFuture.allOf(itemsFuture, remarkFuture, propertiesFuture, specsFuture) CompletableFuture.allOf(itemsFuture, remarkFuture, propertiesFuture, specsFuture)
.orTimeout(QUERY_TIMEOUT_SECONDS, TimeUnit.SECONDS) .orTimeout(Constants.QUERY_TIMEOUT_SECONDS, TimeUnit.SECONDS)
.join(); .join();
List<ProductTemplateItemEntity> items = itemsFuture.join(); List<ProductTemplateItemEntity> items = itemsFuture.join();
...@@ -85,7 +84,7 @@ public class ProductTemplateInfoServiceImpl implements ProductTemplateInfoServic ...@@ -85,7 +84,7 @@ public class ProductTemplateInfoServiceImpl implements ProductTemplateInfoServic
List<ProductTemplateItemSpecEntity> specs = specsFuture.join(); List<ProductTemplateItemSpecEntity> specs = specsFuture.join();
// 4. Items 按 sort 排序 // 4. Items 按 sort 排序
if (items != null) { if (CollectionUtils.isNotEmpty(items)) {
items.sort(Comparator.comparing(ProductTemplateItemEntity::getSort, items.sort(Comparator.comparing(ProductTemplateItemEntity::getSort,
Comparator.nullsLast(Comparator.naturalOrder()))); Comparator.nullsLast(Comparator.naturalOrder())));
} }
...@@ -96,7 +95,7 @@ public class ProductTemplateInfoServiceImpl implements ProductTemplateInfoServic ...@@ -96,7 +95,7 @@ public class ProductTemplateInfoServiceImpl implements ProductTemplateInfoServic
// 6. 计算字段 // 6. 计算字段
// colorImageList: 由 color_images 逗号分割 // colorImageList: 由 color_images 逗号分割
if (StringUtils.isNotBlank(entity.getColorImages())) { if (StringUtils.isNotBlank(entity.getColorImages())) {
vo.setColorImageList(Arrays.asList(entity.getColorImages().split(","))); vo.setColorImageList(Arrays.asList(entity.getColorImages().split(Constants.COMMA)));
} else { } else {
vo.setColorImageList(Collections.emptyList()); vo.setColorImageList(Collections.emptyList());
} }
...@@ -107,10 +106,10 @@ public class ProductTemplateInfoServiceImpl implements ProductTemplateInfoServic ...@@ -107,10 +106,10 @@ public class ProductTemplateInfoServiceImpl implements ProductTemplateInfoServic
} }
// 7. 转换关联数据 // 7. 转换关联数据
if (items != null) { if (CollectionUtils.isNotEmpty(items)) {
vo.setProductList(BeanMapper.snakeCase().convertList(items, ProductTemplateItemSnakeVO.class)); vo.setProductList(BeanMapper.snakeCase().convertList(items, ProductTemplateItemSnakeVO.class));
} }
if (properties != null) { if (CollectionUtils.isNotEmpty(properties)) {
vo.setProperties(BeanMapper.snakeCase().convertList(properties, ProductTemplateInfoPropertySnakeVO.class)); vo.setProperties(BeanMapper.snakeCase().convertList(properties, ProductTemplateInfoPropertySnakeVO.class));
} }
...@@ -118,15 +117,13 @@ public class ProductTemplateInfoServiceImpl implements ProductTemplateInfoServic ...@@ -118,15 +117,13 @@ public class ProductTemplateInfoServiceImpl implements ProductTemplateInfoServic
resolveProperties(properties, vo); resolveProperties(properties, vo);
// 9. 规格去重(按 face_id + "_" + size) // 9. 规格去重(按 face_id + "_" + size)
if (specs != null && !specs.isEmpty()) { if (CollectionUtils.isNotEmpty(specs)) {
vo.setSpecList(buildSpecList(specs)); vo.setSpecList(buildSpecList(specs));
} }
return vo; return vo;
} }
// ==================== bindDetail ====================
@Override @Override
public BindDetailVO bindDetail(Integer id, String sku) { public BindDetailVO bindDetail(Integer id, String sku) {
// 1. 校验参数并查询主实体 // 1. 校验参数并查询主实体
...@@ -148,7 +145,7 @@ public class ProductTemplateInfoServiceImpl implements ProductTemplateInfoServic ...@@ -148,7 +145,7 @@ public class ProductTemplateInfoServiceImpl implements ProductTemplateInfoServic
.supplyAsync(() -> customProductItemDomainService.selectByProductId(productId), threadPoolExecutor); .supplyAsync(() -> customProductItemDomainService.selectByProductId(productId), threadPoolExecutor);
CompletableFuture.allOf(templateItemsFuture, productInfoFuture, productItemsFuture) CompletableFuture.allOf(templateItemsFuture, productInfoFuture, productItemsFuture)
.orTimeout(QUERY_TIMEOUT_SECONDS, TimeUnit.SECONDS) .orTimeout(Constants.QUERY_TIMEOUT_SECONDS, TimeUnit.SECONDS)
.join(); .join();
List<ProductTemplateItemEntity> templateItems = templateItemsFuture.join(); List<ProductTemplateItemEntity> templateItems = templateItemsFuture.join();
...@@ -160,7 +157,7 @@ public class ProductTemplateInfoServiceImpl implements ProductTemplateInfoServic ...@@ -160,7 +157,7 @@ public class ProductTemplateInfoServiceImpl implements ProductTemplateInfoServic
// 5. 构建商品明细 Map(key = id) // 5. 构建商品明细 Map(key = id)
Map<Integer, CustomProductItemEntity> productItemMap; Map<Integer, CustomProductItemEntity> productItemMap;
if (productItems != null && !productItems.isEmpty()) { if (CollectionUtils.isNotEmpty(productItems)) {
productItemMap = productItems.stream() productItemMap = productItems.stream()
.collect(Collectors.toMap(CustomProductItemEntity::getId, item -> item, (a, b) -> a)); .collect(Collectors.toMap(CustomProductItemEntity::getId, item -> item, (a, b) -> a));
} else { } else {
...@@ -168,14 +165,14 @@ public class ProductTemplateInfoServiceImpl implements ProductTemplateInfoServic ...@@ -168,14 +165,14 @@ public class ProductTemplateInfoServiceImpl implements ProductTemplateInfoServic
} }
// 6. 模板明细按 sort 排序 // 6. 模板明细按 sort 排序
if (templateItems != null) { if (CollectionUtils.isNotEmpty(templateItems)) {
templateItems.sort(Comparator.comparing(ProductTemplateItemEntity::getSort, templateItems.sort(Comparator.comparing(ProductTemplateItemEntity::getSort,
Comparator.nullsLast(Comparator.naturalOrder()))); Comparator.nullsLast(Comparator.naturalOrder())));
} }
// 7. 构建关联列表 // 7. 构建关联列表
List<ProductTemplateAssSnakeVO> assList = new ArrayList<>(); List<ProductTemplateAssSnakeVO> assList = new ArrayList<>();
if (templateItems != null) { if (CollectionUtils.isNotEmpty(templateItems)) {
for (ProductTemplateItemEntity templateItem : templateItems) { for (ProductTemplateItemEntity templateItem : templateItems) {
ProductTemplateAssSnakeVO assVO = ProductTemplateAssSnakeVO.builder() ProductTemplateAssSnakeVO assVO = ProductTemplateAssSnakeVO.builder()
.template_item_id(templateItem.getId()) .template_item_id(templateItem.getId())
...@@ -206,8 +203,6 @@ public class ProductTemplateInfoServiceImpl implements ProductTemplateInfoServic ...@@ -206,8 +203,6 @@ public class ProductTemplateInfoServiceImpl implements ProductTemplateInfoServic
.build(); .build();
} }
// ==================== 私有方法 ====================
/** /**
* 校验 id/sku 参数并查询主实体 * 校验 id/sku 参数并查询主实体
* *
...@@ -238,7 +233,7 @@ public class ProductTemplateInfoServiceImpl implements ProductTemplateInfoServic ...@@ -238,7 +233,7 @@ public class ProductTemplateInfoServiceImpl implements ProductTemplateInfoServic
* @param vo 目标 VO(结果写入 skuProperties / normalProperties) * @param vo 目标 VO(结果写入 skuProperties / normalProperties)
*/ */
private void resolveProperties(List<ProductTemplateInfoPropertyEntity> properties, ProductTemplateInfoSnakeVO vo) { private void resolveProperties(List<ProductTemplateInfoPropertyEntity> properties, ProductTemplateInfoSnakeVO vo) {
if (properties == null || properties.isEmpty()) { if (CollectionUtils.isNotEmpty(properties)) {
vo.setSkuProperties(Collections.emptyList()); vo.setSkuProperties(Collections.emptyList());
vo.setNormalProperties(Collections.emptyList()); vo.setNormalProperties(Collections.emptyList());
return; return;
...@@ -250,9 +245,9 @@ public class ProductTemplateInfoServiceImpl implements ProductTemplateInfoServic ...@@ -250,9 +245,9 @@ public class ProductTemplateInfoServiceImpl implements ProductTemplateInfoServic
.filter(Objects::nonNull) .filter(Objects::nonNull)
.map(String::valueOf) .map(String::valueOf)
.distinct() .distinct()
.collect(Collectors.joining(",")); .collect(Collectors.joining(Constants.COMMA));
if (propIds.isEmpty()) { if (StringUtils.isBlank(propIds)) {
vo.setSkuProperties(Collections.emptyList()); vo.setSkuProperties(Collections.emptyList());
vo.setNormalProperties(Collections.emptyList()); vo.setNormalProperties(Collections.emptyList());
return; return;
...@@ -260,7 +255,7 @@ public class ProductTemplateInfoServiceImpl implements ProductTemplateInfoServic ...@@ -260,7 +255,7 @@ public class ProductTemplateInfoServiceImpl implements ProductTemplateInfoServic
// 调用 baseProperty API 获取属性详情(复用 SaasAdminService) // 调用 baseProperty API 获取属性详情(复用 SaasAdminService)
List<PropertyModel> allProperties = saasAdminService.getPropertyByIds(propIds); List<PropertyModel> allProperties = saasAdminService.getPropertyByIds(propIds);
if (allProperties == null || allProperties.isEmpty()) { if (CollectionUtils.isNotEmpty(allProperties)) {
vo.setSkuProperties(Collections.emptyList()); vo.setSkuProperties(Collections.emptyList());
vo.setNormalProperties(Collections.emptyList()); vo.setNormalProperties(Collections.emptyList());
return; return;
...@@ -306,7 +301,7 @@ public class ProductTemplateInfoServiceImpl implements ProductTemplateInfoServic ...@@ -306,7 +301,7 @@ public class ProductTemplateInfoServiceImpl implements ProductTemplateInfoServic
private List<ProductTemplateItemSpecSnakeVO> buildSpecList(List<ProductTemplateItemSpecEntity> specs) { private List<ProductTemplateItemSpecSnakeVO> buildSpecList(List<ProductTemplateItemSpecEntity> specs) {
Map<String, ProductTemplateItemSpecEntity> uniqueMap = new LinkedHashMap<>(); Map<String, ProductTemplateItemSpecEntity> uniqueMap = new LinkedHashMap<>();
for (ProductTemplateItemSpecEntity spec : specs) { for (ProductTemplateItemSpecEntity spec : specs) {
String key = spec.getFaceId() + "_" + spec.getSize(); String key = spec.getFaceId() + UNDER_LINE + spec.getSize();
uniqueMap.putIfAbsent(key, spec); uniqueMap.putIfAbsent(key, spec);
} }
return uniqueMap.values().stream() return uniqueMap.values().stream()
......
...@@ -127,34 +127,6 @@ public class BasicCustomProductInfoSnakeModel { ...@@ -127,34 +127,6 @@ public class BasicCustomProductInfoSnakeModel {
@Schema(description = "默认模SKU") @Schema(description = "默认模SKU")
private String diy_sku; private String diy_sku;
@Schema(description = "普通图片列表(type=0)")
private List<CustomProductImageSnakeVO> imageList;
@Schema(description = "商品描述")
private ProductRemarkSnakeVO productRemark;
@Schema(description = "商品中文描述")
private ProductRemarkSnakeVO productCnRemark;
@Schema(description = "工厂价格关联列表")
private List<CustomProductFactoryPriceRelSnakeVO> factoryPriceList;
@Schema(description = "尺码图片列表(type=1)")
private List<CustomProductImageSnakeVO> sizeList;
@Schema(description = "DIY 用户 ID 列表")
private List<Integer> diyUserIds;
@Schema(description = "工艺 ID 列表")
private List<String> craftIds;
@Schema(description = "工厂 ID 列表")
private List<Integer> factoryIds;
@Schema(description = "仓库 ID 列表")
private List<Integer> warehouseIds;
@Schema(description = "英文备注内容") @Schema(description = "英文备注内容")
private String remark; private String remark;
......
package com.jomalls.custom.app.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* Model
*
* @author Lizh
* @date 2026-06-03 11:57:04
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Schema(description = "VO")
public class BasicCustomProductItemSnakeModel implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
*
*/
@Schema(description = "")
private Integer id;
/**
* 商品ID
*/
@Schema(description = "商品ID")
private Integer product_id;
/**
* sku
*/
@Schema(description = "sku")
private String sku;
/**
* sku商品名称
*/
@Schema(description = "sku商品名称")
private String sku_name;
/**
* 货号
*/
@Schema(description = "货号")
private String product_no;
/**
* 封面图
*/
@Schema(description = "封面图")
private String image;
/**
* 图片集
*/
@Schema(description = "图片集")
private String image_ary;
/**
* 属性分类ID1
*/
@Schema(description = "属性分类ID1")
private Integer property_cate_id1;
/**
* 属性分类ID2
*/
@Schema(description = "属性分类ID2")
private Integer property_cate_id2;
/**
* 属性分类ID3
*/
@Schema(description = "属性分类ID3")
private Integer property_cate_id3;
/**
*
*/
@Schema(description = "")
private Integer property1_id;
/**
*
*/
@Schema(description = "")
private Integer property2_id;
/**
*
*/
@Schema(description = "")
private Integer property3_id;
/**
* 属性编码1
*/
@Schema(description = "属性编码1")
private String property_code1;
/**
* 属性编码2
*/
@Schema(description = "属性编码2")
private String property_code2;
/**
*
*/
@Schema(description = "")
private String property_code3;
/**
* 属性名称1
*/
@Schema(description = "属性名称1")
private String option_enname1;
/**
* 属性名称2
*/
@Schema(description = "属性名称2")
private String option_enname2;
/**
*
*/
@Schema(description = "")
private String option_enname3;
/**
*
*/
@Schema(description = "")
private String custom_value1;
/**
*
*/
@Schema(description = "")
private String custom_value2;
/**
*
*/
@Schema(description = "")
private String custom_value3;
/**
* 工厂价
*/
@Schema(description = "工厂价")
private BigDecimal factory_price;
/**
* 销售价
*/
@Schema(description = "销售价")
private BigDecimal sales_price;
/**
* sku克重
*/
@Schema(description = "sku克重")
private BigDecimal sku_weight;
/**
* 印花类型 0满印 1局部印
*/
@Schema(description = "印花类型 0满印 1局部印")
private Integer print_type;
/**
* 1正常码 2大码
*/
@Schema(description = "1正常码 2大码")
private Integer size_type;
/**
* 排序
*/
@Schema(description = "排序")
private Integer sort;
/**
* 创建时间
*/
@Schema(description = "创建时间")
private Date create_time;
}
...@@ -67,5 +67,5 @@ public class CraftCenterSnakeVO implements Serializable { ...@@ -67,5 +67,5 @@ public class CraftCenterSnakeVO implements Serializable {
private Date update_time; private Date update_time;
@Schema(description = "工艺与商品的关联数据(对齐 TS CustomProductCraftRel)") @Schema(description = "工艺与商品的关联数据(对齐 TS CustomProductCraftRel)")
private CustomProductCraftRelSnakeVO customProductCraftRel; private CustomProductCraftRelSnakeVO CustomProductCraftRel;
} }
...@@ -23,8 +23,35 @@ import java.util.List; ...@@ -23,8 +23,35 @@ import java.util.List;
@Schema(description = "商品完整详情") @Schema(description = "商品完整详情")
public class CustomProductInfoSnakeVO extends BasicCustomProductInfoSnakeModel implements Serializable { public class CustomProductInfoSnakeVO extends BasicCustomProductInfoSnakeModel implements Serializable {
@Schema(description = "仓库 ID 列表")
private List<Integer> warehouseIds;
@Schema(description = "工艺 ID 列表")
private List<String> craftIds;
@Schema(description = "尺码图片列表(type=1)")
private List<CustomProductImageSnakeVO> sizeList;
@Schema(description = "商品描述")
private ProductRemarkSnakeVO productRemark;
@Schema(description = "商品中文描述")
private ProductRemarkSnakeVO productCnRemark;
@Schema(description = "普通图片列表(type=0)")
private List<CustomProductImageSnakeVO> imageList;
@Schema(description = "DIY 用户 ID 列表")
private List<Integer> diyUserIds;
@Schema(description = "工厂 ID 列表")
private List<Integer> factoryIds;
@Schema(description = "工厂价格关联列表")
private List<CustomProductFactoryPriceRelSnakeVO> factoryPriceList;
@Schema(description = "SKU 子项列表") @Schema(description = "SKU 子项列表")
private List<CustomProductItemSnakeVO> productList; private List<BasicCustomProductItemSnakeModel> productList;
@Schema(description = "普通属性列表") @Schema(description = "普通属性列表")
private List<CustomProductInfoPropertySnakeVO> properties; private List<CustomProductInfoPropertySnakeVO> properties;
......
package com.jomalls.custom.app.vo; package com.jomalls.custom.app.vo;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor; import lombok.*;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
...@@ -23,172 +16,8 @@ import java.util.List; ...@@ -23,172 +16,8 @@ import java.util.List;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@Schema(description = "VO") @Schema(description = "VO")
public class CustomProductItemSnakeVO implements Serializable { @EqualsAndHashCode(callSuper = true)
@Serial public class CustomProductItemSnakeVO extends BasicCustomProductItemSnakeModel {
private static final long serialVersionUID = 1L;
/**
*
*/
@Schema(description = "")
private Integer id;
/**
* 商品ID
*/
@Schema(description = "商品ID")
private Integer product_id;
/**
* sku
*/
@Schema(description = "sku")
private String sku;
/**
* sku商品名称
*/
@Schema(description = "sku商品名称")
private String sku_name;
/**
* 货号
*/
@Schema(description = "货号")
private String product_no;
/**
* 封面图
*/
@Schema(description = "封面图")
private String image;
/**
* 图片集
*/
@Schema(description = "图片集")
private String image_ary;
/**
* 属性分类ID1
*/
@Schema(description = "属性分类ID1")
private Integer property_cate_id1;
/**
* 属性分类ID2
*/
@Schema(description = "属性分类ID2")
private Integer property_cate_id2;
/**
* 属性分类ID3
*/
@Schema(description = "属性分类ID3")
private Integer property_cate_id3;
/**
*
*/
@Schema(description = "")
private Integer property1_id;
/**
*
*/
@Schema(description = "")
private Integer property2_id;
/**
*
*/
@Schema(description = "")
private Integer property3_id;
/**
* 属性编码1
*/
@Schema(description = "属性编码1")
private String property_code1;
/**
* 属性编码2
*/
@Schema(description = "属性编码2")
private String property_code2;
/**
*
*/
@Schema(description = "")
private String property_code3;
/**
* 属性名称1
*/
@Schema(description = "属性名称1")
private String option_enname1;
/**
* 属性名称2
*/
@Schema(description = "属性名称2")
private String option_enname2;
/**
*
*/
@Schema(description = "")
private String option_enname3;
/**
*
*/
@Schema(description = "")
private String custom_value1;
/**
*
*/
@Schema(description = "")
private String custom_value2;
/**
*
*/
@Schema(description = "")
private String custom_value3;
/**
* 工厂价
*/
@Schema(description = "工厂价")
private BigDecimal factory_price;
/**
* 销售价
*/
@Schema(description = "销售价")
private BigDecimal sales_price;
/**
* sku克重
*/
@Schema(description = "sku克重")
private BigDecimal sku_weight;
/**
* 印花类型 0满印 1局部印
*/
@Schema(description = "印花类型 0满印 1局部印")
private Integer print_type;
/**
* 1正常码 2大码
*/
@Schema(description = "1正常码 2大码")
private Integer size_type;
/** /**
* 关联商品信息的工厂ID(仅 getBySkus 接口填充,非表字段) * 关联商品信息的工厂ID(仅 getBySkus 接口填充,非表字段)
*/ */
...@@ -202,22 +31,10 @@ public class CustomProductItemSnakeVO implements Serializable { ...@@ -202,22 +31,10 @@ public class CustomProductItemSnakeVO implements Serializable {
private String factory_code; private String factory_code;
/** /**
* 排序
*/
@Schema(description = "排序")
private Integer sort;
/**
* 创建时间
*/
@Schema(description = "创建时间")
private Date create_time;
/**
* 关联商品信息(仅 getBySkus 接口填充,对齐 TS include CustomProductInfo) * 关联商品信息(仅 getBySkus 接口填充,对齐 TS include CustomProductInfo)
*/ */
@Schema(description = "关联商品信息") @Schema(description = "关联商品信息")
private CustomProductInfoSnakeVO customProductInfo; private BasicCustomProductInfoSnakeModel customProductInfo;
/** /**
* 工厂价格列表(仅 getBySkus 接口填充,对齐 TS include CustomProductFactoryPriceRel) * 工厂价格列表(仅 getBySkus 接口填充,对齐 TS include CustomProductFactoryPriceRel)
......
...@@ -233,6 +233,6 @@ public class CustomWarehouseInfoSnakeVO implements Serializable { ...@@ -233,6 +233,6 @@ public class CustomWarehouseInfoSnakeVO implements Serializable {
private String company_name_cn; private String company_name_cn;
@Schema(description = "仓库与商品的关联数据(对齐 TS CustomProductWarehouseRel)") @Schema(description = "仓库与商品的关联数据(对齐 TS CustomProductWarehouseRel)")
private CustomProductWarehouseRelSnakeVO customProductWarehouseRel; private CustomProductWarehouseRelSnakeVO CustomProductWarehouseRel;
} }
package com.jomalls.custom.webapp.controller; package com.jomalls.custom.webapp.controller;
import com.jomalls.custom.app.constant.Constants;
import com.jomalls.custom.app.dto.UpdateSalesPriceSnakeDTO; import com.jomalls.custom.app.dto.UpdateSalesPriceSnakeDTO;
import com.jomalls.custom.app.service.CustomProductItemService; import com.jomalls.custom.app.service.CustomProductItemService;
import com.jomalls.custom.app.vo.CustomProductItemSnakeVO; import com.jomalls.custom.app.vo.CustomProductItemSnakeVO;
...@@ -74,7 +75,7 @@ public class CustomProductItemController { ...@@ -74,7 +75,7 @@ public class CustomProductItemController {
public List<CustomProductItemSnakeVO> getBySkus( public List<CustomProductItemSnakeVO> getBySkus(
@Parameter(description = "SKU列表(逗号分隔)", required = true) @RequestParam("skus") String skus, @Parameter(description = "SKU列表(逗号分隔)", required = true) @RequestParam("skus") String skus,
@Parameter(description = "用户namespace(可选)") @RequestParam(value = "namespace", required = false) String namespace) { @Parameter(description = "用户namespace(可选)") @RequestParam(value = "namespace", required = false) String namespace) {
List<String> skuList = Arrays.asList(skus.split(",")); List<String> skuList = Arrays.asList(skus.split(Constants.COMMA));
return customProductItemService.getBySkus(skuList, namespace); return customProductItemService.getBySkus(skuList, namespace);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment