2 3 import java.util.ArrayList; 4 import java.util.HashMap; 5 import java.util.List; 6 7 /** 8 * 类: LeaveType 9 * 描述: 请假类型枚举 11 * 时间: 2016-10-18 下午4:02:12 12 */ 13 public enum LeaveType { 14 /**事假*/ 15 thing(1, "事假","事"), 16 /**病假*/ 17 disease(2, "病假","病"), 18 /**婚假*/ 19 marry(3, "婚假","婚"), 20 /**产假*/ 21 pregnancy(4, "产假","产"), 22 /**丧假*/ 23 funeral(5, "丧假","丧"), 24 /**探亲假*/ 25 relative(6, "探亲假","探"), 26 /**公休假*/ 27 publicHoliday(7, "公休假","公"), 28 /**年假*/ 29 annualLeave(8, "年假","年"), 30 /**工伤假*/ 31 workInjury(9, "工伤假","伤"); 32 33 /** code */ 34 private Integer code; 35 /** 显示标签 */ 36 private String name; 37 /**排班时显示*/ 38 private String view; 39 /** 40 * 构造器 41 */ 42 LeaveType(Integer code, String name,String view){ 43 this.code = code; 44 this.name = name; 45 this.view = view; 46 } 47 /** 48 * 获取code的name文本 49 * @param code 50 * @return 51 */ 52 public static String getNameByCode (Integer code){ 53 for (LeaveType enuma : LeaveType.values()){ 54 if (enuma.getCode().equals(code)){ 55 return enuma.getName(); 56 } 57 } 58 return "未知枚举项"; 59 } 60 /** 61 * 获取code的view文本 62 * @param code 63 * @return 64 */ 65 public static String getViewByCode (Integer code){ 66 for (LeaveType enuma : LeaveType.values()){ 67 if (enuma.getCode().equals(code)){ 68 return enuma.getView(); 69 } 70 } 71 return "未知枚举项"; 72 } 73 74 /** 75 * 生成值集合给前端 76 * @param code 77 * @return 78 */ 79 public static List> getValueList (){ 80 List > list=new ArrayList >(); 81 for (LeaveType enuma : LeaveType.values()){ 82 HashMap map=new HashMap (); 83 map.put("code", enuma.getCode()); 84 map.put("name", enuma.getName()); 85 list.add(map); 86 } 87 return list; 88 } 89 public Integer getCode() { 90 return code; 91 } 92 public void setCode(Integer code) { 93 this.code = code; 94 } 95 public String getName() { 96 return name; 97 } 98 public void setName(String name) { 99 this.name = name;100 }101 public String getView() {102 return view;103 }104 public void setView(String view) {105 this.view = view;106 }107 108 }