枚举类型有利于标记数字和文字的转化
三个参数也可以
package com.houbank.bank.common.enums;
/**
* Created by Yh on 2017/3/17.
*/
public enum DictTypeEnum {
SEX("0","性别"),
MARRIAGE("1","婚姻状况"),
PURPOSE("2","贷款用途"),
EDUCATION("3","教育程度"),
LIVE("4","居住状况"),
RELRELATION("5","联系人关系"),
REPAYMENTMETHOD("6", "还款方式");
private String type;
private String name;
DictTypeEnum(String type, String name) {
this.type = type;
this.name = name;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public static DictTypeEnum getEnumByType(String type) {
for (DictTypeEnum bankTypeEnum : DictTypeEnum.values()) {
if (bankTypeEnum.getType().equals(type)) {
return bankTypeEnum;
}
}
return null;
}
}
使用:
/**
* 查询字典数据
* @param bankType
* @return
*/
public BankDictValBean queryDict(String bankType, InsureApplyCommRequest insureApplyCommRequest) {
BankDictValBean bankDictValBean = new BankDictValBean();
List
List
for (HbDict hbDict : hbDicts) {
if (DictTypeEnum.EDUCATION.getType().equals(hbDict.getDictType()) && insureApplyCommRequest.getEducation().equals(hbDict.getHbVal())) {
bankDictValBean.setEducation(hbDict.getBankVal());
}
if (DictTypeEnum.SEX.getType().equals(hbDict.getDictType()) && insureApplyCommRequest.getSex().equals(hbDict.getHbVal())) {
bankDictValBean.setSex(hbDict.getBankVal());
}
if (DictTypeEnum.PURPOSE.getType().equals(hbDict.getDictType()) && insureApplyCommRequest.getPurpose().equals(hbDict.getHbVal())) {
bankDictValBean.setPurpose(hbDict.getBankVal());
}
if (DictTypeEnum.MARRIAGE.getType().equals(hbDict.getDictType()) && insureApplyCommRequest.getMarriage().equals(hbDict.getHbVal())) {
bankDictValBean.setMarriage(hbDict.getBankVal());
}
if (DictTypeEnum.LIVE.getType().equals(hbDict.getDictType()) && insureApplyCommRequest.getLiveStatus().equals(hbDict.getHbVal())) {
bankDictValBean.setLive(hbDict.getBankVal());
}
for (RelarrayBean relarrayBean : relarrayBeans) {
if (DictTypeEnum.RELRELATION.getType().equals(hbDict.getDictType())
&& relarrayBean.getRelrelation().equals(hbDict.getHbVal())) {
relarrayBean.setRelrelation(hbDict.getBankVal());
break;
}
}
}
bankDictValBean.setRelrelations(relarrayBeans);
return bankDictValBean;
}