参数校验问题处理
This commit is contained in:
parent
50b52f07c6
commit
be1c9772ad
@ -87,7 +87,7 @@ public enum ResultCode {
|
||||
*/
|
||||
SPEC_SAVE_ERROR(13001, "规格修改失败"),
|
||||
SPEC_UPDATE_ERROR(13002, "规格修改失败"),
|
||||
SPEC_DELETE_ERROR(13003, "此规格已绑定分类不允许删除"),
|
||||
SPEC_DELETE_ERROR(13003, "分类已经绑定此规格,请先解除关联"),
|
||||
|
||||
/**
|
||||
* 品牌
|
||||
|
@ -9,6 +9,7 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
@ -66,17 +67,17 @@ public class Distribution extends BaseEntity {
|
||||
@ApiModelProperty(value = "分销员状态", required = true)
|
||||
private String distributionStatus;
|
||||
|
||||
@Size(min = 1, max = 200, message = "结算银行开户行名称长度为1-200位")
|
||||
@Length(min = 1, max = 200, message = "结算银行开户行名称长度为1-200位")
|
||||
@NotBlank(message = "结算银行开户行名称不能为空")
|
||||
@ApiModelProperty(value = "结算银行开户行名称")
|
||||
private String settlementBankAccountName;
|
||||
|
||||
@Size(min = 1, max = 200, message = "结算银行开户账号长度为1-200位")
|
||||
@Length(min = 1, max = 200, message = "结算银行开户账号长度为1-200位")
|
||||
@NotBlank(message = "结算银行开户账号不能为空")
|
||||
@ApiModelProperty(value = "结算银行开户账号")
|
||||
private String settlementBankAccountNum;
|
||||
|
||||
@Size(min = 1, max = 200, message = "结算银行开户支行名称长度为1-200位")
|
||||
@Length(min = 1, max = 200, message = "结算银行开户支行名称长度为1-200位")
|
||||
@NotBlank(message = "结算银行开户支行名称不能为空")
|
||||
@ApiModelProperty(value = "结算银行开户支行名称")
|
||||
private String settlementBankBranchName;
|
||||
|
@ -2,6 +2,7 @@ package cn.lili.modules.distribution.entity.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
@ -23,17 +24,17 @@ public class DistributionApplyDTO {
|
||||
@ApiModelProperty(value = "身份证号")
|
||||
private String idNumber;
|
||||
|
||||
@Size(min = 1, max = 200, message = "结算银行开户行名称长度为1-200位")
|
||||
@Length(min = 1, max = 200, message = "结算银行开户行名称长度为1-200位")
|
||||
@NotBlank(message = "结算银行开户行名称不能为空")
|
||||
@ApiModelProperty(value = "结算银行开户行名称")
|
||||
private String settlementBankAccountName;
|
||||
|
||||
@Size(min = 1, max = 200, message = "结算银行开户账号长度为1-200位")
|
||||
@Length(min = 1, max = 200, message = "结算银行开户账号长度为1-200位")
|
||||
@NotBlank(message = "结算银行开户账号不能为空")
|
||||
@ApiModelProperty(value = "结算银行开户账号")
|
||||
private String settlementBankAccountNum;
|
||||
|
||||
@Size(min = 1, max = 200, message = "结算银行开户支行名称长度为1-200位")
|
||||
@Length(min = 1, max = 200, message = "结算银行开户支行名称长度为1-200位")
|
||||
@NotBlank(message = "结算银行开户支行名称不能为空")
|
||||
@ApiModelProperty(value = "结算银行开户支行名称")
|
||||
private String settlementBankBranchName;
|
||||
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.Size;
|
||||
@ -24,12 +25,12 @@ public class Brand extends BaseEntity {
|
||||
private static final long serialVersionUID = -8236865838438521426L;
|
||||
|
||||
@NotEmpty(message = "品牌名称不能为空")
|
||||
@Size(max = 20, message = "品牌名称应该小于20长度字符")
|
||||
@Length(max = 20, message = "品牌名称应该小于20长度字符")
|
||||
@ApiModelProperty(value = "品牌名称", required = true)
|
||||
private String name;
|
||||
|
||||
@NotEmpty(message = "品牌图标不能为空")
|
||||
@Size(max = 255, message = "品牌图标地址长度超过255字符")
|
||||
@Length(max = 255, message = "品牌图标地址长度超过255字符")
|
||||
@ApiModelProperty(value = "品牌图标", required = true)
|
||||
private String logo;
|
||||
|
||||
|
@ -30,7 +30,7 @@ public class CategoryParameterGroup extends BaseEntity {
|
||||
*/
|
||||
@ApiModelProperty(value = "参数组名称", required = true)
|
||||
@NotEmpty(message = "参数组名称不能为空")
|
||||
@Length(max = 50, message = "参数组名称不能超过50字")
|
||||
@Length(max = 20, message = "参数组名称不能超过20字")
|
||||
private String groupName;
|
||||
/**
|
||||
* 关联分类id
|
||||
|
@ -7,6 +7,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
/**
|
||||
* 商品计量单位
|
||||
@ -20,6 +21,7 @@ import javax.validation.constraints.NotEmpty;
|
||||
public class GoodsUnit extends BaseEntity {
|
||||
|
||||
@NotEmpty(message = "计量单位名称不能为空")
|
||||
@Size(max = 5, message = "计量单位长度最大为5")
|
||||
@ApiModelProperty(value = "计量单位名称")
|
||||
private String name;
|
||||
}
|
||||
|
@ -26,17 +26,17 @@ import javax.validation.constraints.NotNull;
|
||||
public class Parameters extends BaseIdEntity {
|
||||
|
||||
|
||||
|
||||
private static final long serialVersionUID = -566510714456317006L;
|
||||
|
||||
@ApiModelProperty(value = "参数名称", required = true)
|
||||
@NotEmpty(message = "参数名称必填")
|
||||
@Length(max = 50, message = "参数名称不能超过50字")
|
||||
@Length(max = 5, message = "参数名称不能超过5字")
|
||||
private String paramName;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "选择值")
|
||||
@NotEmpty(message = "参数选项值必填")
|
||||
@Length(max = 255, message = "参数选项过长,请简略")
|
||||
private String options;
|
||||
|
||||
@ApiModelProperty(value = "是否可索引,0 不显示 1 显示", required = true)
|
||||
@ -59,6 +59,8 @@ public class Parameters extends BaseIdEntity {
|
||||
private String categoryId;
|
||||
|
||||
@ApiModelProperty(value = "排序", hidden = true)
|
||||
@NotNull(message = "请输入排序值")
|
||||
@Max(value = 9999, message = "排序值不能大于9999")
|
||||
private Integer sort;
|
||||
|
||||
}
|
@ -6,8 +6,10 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
/**
|
||||
* 商品规格项
|
||||
@ -26,6 +28,7 @@ public class Specification extends BaseIdEntity {
|
||||
* 规格名称
|
||||
*/
|
||||
@NotEmpty(message = "规格名称不能为空")
|
||||
@Size(max = 20, message = "规格名称不能超过20个字符")
|
||||
@ApiModelProperty(value = "规格名称", required = true)
|
||||
private String specName;
|
||||
|
||||
@ -43,6 +46,7 @@ public class Specification extends BaseIdEntity {
|
||||
*/
|
||||
@TableField(value = "spec_value")
|
||||
@ApiModelProperty(value = "规格值名字, 《,》分割")
|
||||
@Length(max = 255, message = "长度超出限制")
|
||||
private String specValue;
|
||||
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.lili.modules.goods.serviceimpl;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.modules.goods.entity.dos.Category;
|
||||
@ -38,7 +39,6 @@ public class SpecificationServiceImpl extends ServiceImpl<SpecificationMapper, S
|
||||
private CategoryServiceImpl categoryService;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean deleteSpecification(List<String> ids) {
|
||||
for (String id : ids) {
|
||||
@ -49,16 +49,8 @@ public class SpecificationServiceImpl extends ServiceImpl<SpecificationMapper, S
|
||||
list.forEach(item -> {
|
||||
categoryIds.add(item.getCategoryId());
|
||||
});
|
||||
//返回包含分类的信息
|
||||
LambdaQueryWrapper<Category> queryWrapper = new LambdaQueryWrapper();
|
||||
queryWrapper.in(Category::getId, categoryIds);
|
||||
List<Category> categories = categoryService.list(queryWrapper);
|
||||
StringBuffer stringBuffer = new StringBuffer("包含的分类有-");
|
||||
categories.stream().forEach(item -> {
|
||||
stringBuffer.append(item.getName());
|
||||
stringBuffer.append(",");
|
||||
});
|
||||
throw new ServiceException(ResultCode.SPEC_DELETE_ERROR, stringBuffer.toString());
|
||||
throw new ServiceException(ResultCode.SPEC_DELETE_ERROR,
|
||||
JSONUtil.toJsonStr(categoryService.getCategoryNameByIds(categoryIds)));
|
||||
}
|
||||
//删除规格
|
||||
this.removeById(id);
|
||||
|
@ -2,6 +2,7 @@ package cn.lili.modules.store.entity.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
@ -15,22 +16,22 @@ import javax.validation.constraints.Size;
|
||||
@Data
|
||||
public class StoreBankDTO {
|
||||
|
||||
@Size(min = 1, max = 200)
|
||||
@Length(min = 1, max = 200)
|
||||
@NotBlank(message = "结算银行开户行名称不能为空")
|
||||
@ApiModelProperty(value = "结算银行开户行名称")
|
||||
private String settlementBankAccountName;
|
||||
|
||||
@Size(min = 1, max = 200)
|
||||
@Length(min = 1, max = 200)
|
||||
@NotBlank(message = "结算银行开户账号不能为空")
|
||||
@ApiModelProperty(value = "结算银行开户账号")
|
||||
private String settlementBankAccountNum;
|
||||
|
||||
@Size(min = 1, max = 200)
|
||||
@Length(min = 1, max = 200)
|
||||
@NotBlank(message = "结算银行开户支行名称不能为空")
|
||||
@ApiModelProperty(value = "结算银行开户支行名称")
|
||||
private String settlementBankBranchName;
|
||||
|
||||
@Size(min = 1, max = 50)
|
||||
@Length(min = 1, max = 50)
|
||||
@NotBlank(message = "结算银行支行联行号不能为空")
|
||||
@ApiModelProperty(value = "结算银行支行联行号")
|
||||
private String settlementBankJointName;
|
||||
|
@ -16,6 +16,7 @@ import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@ -51,14 +52,14 @@ public class SpecificationManagerController {
|
||||
|
||||
@PostMapping
|
||||
@ApiOperation(value = "保存规格")
|
||||
public ResultMessage<Object> save(Specification specification) {
|
||||
public ResultMessage<Object> save(@Valid Specification specification) {
|
||||
specificationService.save(specification);
|
||||
return ResultUtil.success();
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
@ApiOperation(value = "更改规格")
|
||||
public ResultMessage<Object> update(Specification specification, @PathVariable String id) {
|
||||
public ResultMessage<Object> update(@Valid Specification specification, @PathVariable String id) {
|
||||
specification.setId(id);
|
||||
specificationService.saveOrUpdate(specification);
|
||||
return ResultUtil.success();
|
||||
|
Loading…
x
Reference in New Issue
Block a user