枚举实例
package achievements.domain.assessResult; //登录渠道处理为人管渠道 public enum CateToChannel { Agent("1","01","x险"), Group("2","02","x险"), Bank("4","03","x保"), Interact("6","04","x动"), Renewal("5","05","x期"), Telesales("C","0C","x销"); private final String cate;//登录返回的渠道代码 private final String channel;//人管系统的渠道代码 private final String cename;//渠道名字 private CateToChannel( String cate,String channel,String cename){ this.cate=cate; this.channel=channel; this.cename=cename; } public String getCate() { return cate; } public String getChannel() { return channel; } public String getCename() { return cename; } public static CateToChannel getByCate(String cate) { for(CateToChannel typeEnum : CateToChannel.values()) { if(typeEnum.cate == cate) { return typeEnum; } } throw new IllegalArgumentException("No element matches " + cate); } }
@ResponseBody @Transactional public ServiceResult getSalaryDetails(@RequestBody SalarySelect salarySelect){ ServiceResult result=new ServiceResult(); try{ salarySelect.setChannelId(CateToChannel.getByCate(salarySelect.getChannelId()).getChannel()); result.setData(salaryMapper.selectSalaryDetails(salarySelect)); }catch(Exception e){ result.setSuccess(false); result.getMessage().add("查询薪资详情失败"); return result; } result.setSuccess(true); return result; }