ProductCategoryEnum
1 public enum ProductCategoryStateEnum { 2 SUCCESS(1, "创建成功"), INNER_ERROR(-1001, "操作失败"), EMPTY_LIST(-1002, "添加数少于1"); 3 4 private int state; 5 6 private String stateInfo; 7 8 private ProductCategoryStateEnum(int state, String stateInfo) { 9 this.state = state; 10 this.stateInfo = stateInfo; 11 } 12 13 public int getState() { 14 return state; 15 } 16 17 public String getStateInfo() { 18 return stateInfo; 19 } 20 21 public static ProductCategoryStateEnum stateOf(int index) { 22 for (ProductCategoryStateEnum state : values()) { 23 if (state.getState() == index) { 24 return state; 25 } 26 } 27 return null; 28 } 29 30 }
ProductCategoryExecution
1 public class ProductCategoryExecution { 2 // 结果状态 3 private int state; 4 5 // 状态标识 6 private String stateInfo; 7 8 // 操作的商铺类别 9 private List<ProductCategory> productCategoryList; 10 11 public ProductCategoryExecution() { 12 } 13 14 // 预约失败的构造器 15 public ProductCategoryExecution(ProductCategoryStateEnum stateEnum) { 16 this.state = stateEnum.getState(); 17 this.stateInfo = stateEnum.getStateInfo(); 18 } 19 20 // 预约成功的构造器 21 public ProductCategoryExecution(ProductCategoryStateEnum stateEnum, 22 List<ProductCategory> productCategoryList) { 23 this.state = stateEnum.getState(); 24 this.stateInfo = stateEnum.getStateInfo(); 25 this.productCategoryList = productCategoryList; 26 } 27 28 public int getState() { 29 return state; 30 } 31 32 public void setState(int state) { 33 this.state = state; 34 } 35 36 public String getStateInfo() { 37 return stateInfo; 38 } 39 40 public void setStateInfo(String stateInfo) { 41 this.stateInfo = stateInfo; 42 } 43 44 public List<ProductCategory> getProductCategoryList() { 45 return productCategoryList; 46 } 47 48 public void setProductCategoryList(List<ProductCategory> productCategoryList) { 49 this.productCategoryList = productCategoryList; 50 } 51 52 }
ProductCategoryException
1 public class ProductCategoryOperationException extends RuntimeException{ 2 3 /** 4 * 5 */ 6 private static final long serialVersionUID = -3594075878279352727L; 7 8 public ProductCategoryOperationException(String msg) { 9 super(msg); 10 } 11 }