商品草稿状态也要校验

This commit is contained in:
litianxiang
2026-05-07 14:11:18 +08:00
parent 08f5a482eb
commit daf4c30a91
3 changed files with 24 additions and 27 deletions

View File

@@ -51,7 +51,7 @@ public class ListingSaveDTO implements Serializable {
@Schema(description = "适用性别: male/female") @Schema(description = "适用性别: male/female")
private String designFor; private String designFor;
/** 商品分类列表: outwear/trousers/blouse/dress/skirt/accessories */ /** 商品分类列表: outwear/trousers/blouse/dress/skirt/others/tops/bottoms */
@Schema(description = "商品分类列表: outwear/trousers/blouse/dress/skirt/accessories") @Schema(description = "商品分类列表: outwear/trousers/blouse/dress/skirt/others/tops/bottoms")
private List<String> productCategory; private List<String> productCategory;
} }

View File

@@ -18,7 +18,7 @@ public enum ProductCategoryEnum {
DRESS("dress", "连衣裙"), DRESS("dress", "连衣裙"),
SKIRT("skirt", "半身裙"), SKIRT("skirt", "半身裙"),
OTHERS("others", "其他"), OTHERS("others", "其他"),
TOP("top", "上装"), TOP("tops", "上装"),
BOTTOMS("bottoms", "下装"); BOTTOMS("bottoms", "下装");
@JsonValue @JsonValue

View File

@@ -53,7 +53,6 @@ public class ListingServiceImpl extends ServiceImpl<ListingMapper, ListingEntity
entity.setSellerId(sellerId); entity.setSellerId(sellerId);
if (dto.getDesignFor() != null && DesignForEnum.of(dto.getDesignFor()) == null) { if (dto.getDesignFor() != null && DesignForEnum.of(dto.getDesignFor()) == null) {
throw new BusinessException("designFor 只能为 male/female"); throw new BusinessException("designFor 只能为 male/female");
} }
@@ -247,7 +246,6 @@ public class ListingServiceImpl extends ServiceImpl<ListingMapper, ListingEntity
* 当 status 为 1已发布检查必填字段 * 当 status 为 1已发布检查必填字段
*/ */
private void validateListingFields(ListingSaveDTO dto) { private void validateListingFields(ListingSaveDTO dto) {
if (dto.getStatus() != null && dto.getStatus() == 1) {
if (!StringUtils.hasText(dto.getTitle())) { if (!StringUtils.hasText(dto.getTitle())) {
throw new BusinessException("商品标题不能为空"); throw new BusinessException("商品标题不能为空");
} }
@@ -268,8 +266,7 @@ public class ListingServiceImpl extends ServiceImpl<ListingMapper, ListingEntity
} }
for (String category : dto.getProductCategory()) { for (String category : dto.getProductCategory()) {
if (ProductCategoryEnum.of(category) == null) { if (ProductCategoryEnum.of(category) == null) {
throw new BusinessException("商品分类只能为 outwear/trousers/blouse/dress/skirt/accessories"); throw new BusinessException("商品分类只能为 outwear/trousers/blouse/dress/skirt/others/tops/bottoms");
}
} }
} }
} }