80 lines
2.4 KiB
Java
80 lines
2.4 KiB
Java
package mjkf.xinke.main.model.vo;
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import com.jgy.xxs.core.http.exp.NcHttpException;
|
|
import io.swagger.annotations.ApiModelProperty;
|
|
import lombok.Data;
|
|
import mjkf.xinke.main.constant.HttpErrorResponseEnum;
|
|
|
|
@Data
|
|
public class MaterialCreateRequest {
|
|
|
|
@ApiModelProperty("分类1")
|
|
private String category1;
|
|
|
|
@ApiModelProperty("分类2")
|
|
private String category2;
|
|
|
|
@ApiModelProperty("分类3")
|
|
private String category3;
|
|
|
|
@ApiModelProperty("分类4")
|
|
private String category4;
|
|
|
|
@ApiModelProperty("名称")
|
|
private String name;
|
|
|
|
@ApiModelProperty("单位")
|
|
private String unit;
|
|
|
|
@ApiModelProperty("规格")
|
|
private String spec;
|
|
|
|
@ApiModelProperty("税率")
|
|
private Integer tax;
|
|
|
|
@ApiModelProperty("类型")
|
|
private Integer type;
|
|
|
|
public void check() throws Exception {
|
|
if (ObjectUtil.isEmpty(category1) || category1.chars().count() != 2) {
|
|
throw new NcHttpException(HttpErrorResponseEnum.MATERIAL_CATEGORY_INVALID);
|
|
}
|
|
if (ObjectUtil.isEmpty(category2) || category2.chars().count() != 2) {
|
|
throw new NcHttpException(HttpErrorResponseEnum.MATERIAL_CATEGORY_INVALID);
|
|
}
|
|
if (ObjectUtil.isEmpty(category3) || category3.chars().count() != 3) {
|
|
throw new NcHttpException(HttpErrorResponseEnum.MATERIAL_CATEGORY_INVALID);
|
|
}
|
|
if (ObjectUtil.isNotEmpty(category4) && category4.chars().count() != 3) {
|
|
throw new NcHttpException(HttpErrorResponseEnum.MATERIAL_CATEGORY_INVALID);
|
|
}
|
|
if (ObjectUtil.isEmpty(spec)) {
|
|
throw new NcHttpException(HttpErrorResponseEnum.MATERIAL_CATEGORY_INVALID);
|
|
}
|
|
if (ObjectUtil.isEmpty(tax)) {
|
|
throw new NcHttpException(HttpErrorResponseEnum.MATERIAL_CATEGORY_INVALID);
|
|
}
|
|
if (ObjectUtil.isEmpty(type)) {
|
|
throw new NcHttpException(HttpErrorResponseEnum.MATERIAL_CATEGORY_INVALID);
|
|
}
|
|
}
|
|
|
|
public String buildId() {
|
|
var id = category1 + category2 + category3;
|
|
if (ObjectUtil.isNotEmpty(category4)) {
|
|
id = id + category4;
|
|
}
|
|
return id;
|
|
}
|
|
|
|
public String buildParentId() {
|
|
if (ObjectUtil.isNotEmpty(category4)) {
|
|
return category1 + category2 + category3;
|
|
} else {
|
|
return category1 + category2;
|
|
}
|
|
}
|
|
|
|
}
|