Commit bf1549497559d89a02a788e4e5b7063ba5b93da4

Authored by dadiyang
1 parent 8e43004c

fix(product):SKU 价格字段补 @Min(0) 后端防线,拒绝负价格写入

商品/SKU 允许填负价格并保存成功(A19):ProductSkuSaveReqVO 的
price/marketPrice/costPrice/firstBrokeragePrice/secondBrokeragePrice
均无下限校验,管理端前端 el-input-number min=0 恰好掩盖后端缺口,
绕过前端(直接接口/H5/第三方)即可写入负价。

给五个价格字段补 @Min(0),后端校验层统一拒绝非正价格(SPU 创建/
更新经 skus 的 @Valid 级联一并生效)。
yudao-module-mall/yudao-module-product/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSkuSaveReqVO.java
1 1 package cn.iocoder.yudao.module.product.controller.admin.spu.vo;
2 2  
3 3 import io.swagger.v3.oas.annotations.media.Schema;
  4 +import jakarta.validation.constraints.Min;
4 5 import jakarta.validation.constraints.NotEmpty;
5 6 import jakarta.validation.constraints.NotNull;
6 7 import lombok.*;
... ... @@ -17,12 +18,15 @@ public class ProductSkuSaveReqVO {
17 18  
18 19 @Schema(description = "销售价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1999")
19 20 @NotNull(message = "销售价格,单位:分不能为空")
  21 + @Min(value = 0, message = "销售价格,单位:分不能小于 0")
20 22 private Integer price;
21 23  
22 24 @Schema(description = "市场价", example = "2999")
  25 + @Min(value = 0, message = "市场价不能小于 0")
23 26 private Integer marketPrice;
24 27  
25 28 @Schema(description = "成本价", example = "19")
  29 + @Min(value = 0, message = "成本价不能小于 0")
26 30 private Integer costPrice;
27 31  
28 32 @Schema(description = "条形码", example = "15156165456")
... ... @@ -43,9 +47,11 @@ public class ProductSkuSaveReqVO {
43 47 private Double volume;
44 48  
45 49 @Schema(description = "一级分销的佣金,单位:分", example = "199")
  50 + @Min(value = 0, message = "一级分销的佣金,单位:分不能小于 0")
46 51 private Integer firstBrokeragePrice;
47 52  
48 53 @Schema(description = "二级分销的佣金,单位:分", example = "19")
  54 + @Min(value = 0, message = "二级分销的佣金,单位:分不能小于 0")
49 55 private Integer secondBrokeragePrice;
50 56  
51 57 @Schema(description = "属性数组")
... ...