增加商品sku参数空值判断

This commit is contained in:
paulGao 2022-08-19 17:46:12 +08:00
parent 9eba3287b2
commit cc95fa92e7
2 changed files with 7 additions and 0 deletions

View File

@ -79,6 +79,7 @@ public enum ResultCode {
MUST_HAVE_SALES_MODEL(11022, "销售模式为批发时必须要有批发规则!"), MUST_HAVE_SALES_MODEL(11022, "销售模式为批发时必须要有批发规则!"),
HAVE_INVALID_SALES_MODEL(11023, "批发规则存在小于等于0的无效数据"), HAVE_INVALID_SALES_MODEL(11023, "批发规则存在小于等于0的无效数据"),
MUST_HAVE_GOODS_SKU_VALUE(11024, "规格值不能为空!"),
GOODS_PARAMS_ERROR(11013, "商品参数错误,刷新后重试"), GOODS_PARAMS_ERROR(11013, "商品参数错误,刷新后重试"),
PHYSICAL_GOODS_NEED_TEMP(11014, "实物商品需选择配送模板"), PHYSICAL_GOODS_NEED_TEMP(11014, "实物商品需选择配送模板"),

View File

@ -194,6 +194,12 @@ public class Goods extends BaseEntity {
if (!sku.containsKey("quantity") || StringUtil.isEmpty(sku.get("quantity").toString()) || Convert.toInt(sku.get("quantity").toString()) < 0) { if (!sku.containsKey("quantity") || StringUtil.isEmpty(sku.get("quantity").toString()) || Convert.toInt(sku.get("quantity").toString()) < 0) {
throw new ServiceException(ResultCode.GOODS_SKU_QUANTITY_ERROR); throw new ServiceException(ResultCode.GOODS_SKU_QUANTITY_ERROR);
} }
sku.values().forEach(i -> {
if (CharSequenceUtil.isBlank(i.toString())) {
throw new ServiceException(ResultCode.MUST_HAVE_GOODS_SKU_VALUE);
}
});
} }
} }