前台传入weightCode :1/2/3/4,获取不同的区间 0~1010~5050~100100~9999990~999999
public void setWeight(){ this.minWeight = FuelWeight.getFuelWeight(this.weightCode).minWeight; this.maxWeight = FuelWeight.getFuelWeight(this.weightCode).maxWeight; } enum FuelWeight{ weightCode_1(1,0,10), weightCode_2(2,10,50), weightCode_3(3,50,100), weightCode_4(4,100,999999), weightCode_5(5,0,999999); private Integer code; private Integer minWeight; private Integer maxWeight; FuelWeight(Integer code, Integer minWeight,Integer maxWeight) { this.code = code; this.minWeight = minWeight; this.maxWeight = maxWeight; } public static FuelWeight getFuelWeight(Integer code) { for (FuelWeight weight : FuelWeight.values()) { if (weight.code.equals(code)) return weight; } return weightCode_5; } }