shop--9.商品--辅助工具
ProductStateEnum
public enum ProductStateEnum { SUCCESS(1, "插入成功"), INNER_ERROR(-1001, "操作失败"); private int state; private String stateInfo; ProductStateEnum(int state, String stateInfo) { this.state = state; this.stateInfo = stateInfo; } public int getState() { return state; } public String getStateInfo() { return stateInfo; } }
ProductOperationException
public class ProductOperationException extends RuntimeException { private static final long serialVersionUID = -6851228251862891341L; public ProductOperationException(String message) { super( message ); } }
ProductExecution
public class ProductExecution { private int state; private String stateInfo; private int count; private Product product; private List<Product> productList; public ProductExecution(){ } //操作失败的构造器 public ProductExecution(ProductStateEnum productStateEnum) { this.state = productStateEnum.getState(); this.stateInfo = productStateEnum.getStateInfo(); } //操作成功的构造器1 单个商品 public ProductExecution(ProductStateEnum productStateEnum, Product product){ this.state = productStateEnum.getState(); this.stateInfo = productStateEnum.getStateInfo(); this.product = product; } //操作成功的构造器2 多个商品 public ProductExecution(ProductStateEnum productStateEnum, List<Product> productList){ this.state = productStateEnum.getState(); this.stateInfo = productStateEnum.getStateInfo(); this.productList = productList; } public int getState() { return state; } public void setState(int state) { this.state = state; } public String getStateInfo() { return stateInfo; } public void setStateInfo(String stateInfo) { this.stateInfo = stateInfo; } public int getCount() { return count; } public void setCount(int count) { this.count = count; } public Product getProduct() { return product; } public void setProduct(Product product) { this.product = product; } public List<Product> getProductList() { return productList; } public void setProductList(List<Product> productList) { this.productList = productList; } }