增加枚举参数互相转换方法
parent
c37f9e7256
commit
92ade8267a
|
@ -33,4 +33,30 @@ public enum SysPayType {
|
|||
.map(SysPayType::getCode)
|
||||
.anyMatch(c -> c.equals(code));
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数转换,从支付方式编码转换为支付方式名称
|
||||
* @param code 支付方式编码
|
||||
* @return 支付方式名称
|
||||
*/
|
||||
public static String getInfoByCode(String code){
|
||||
return Arrays.stream(values())
|
||||
.filter(c -> c.getCode().equals(code))
|
||||
.findFirst()
|
||||
.map(SysPayType::getInfo)
|
||||
.orElse("-");
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数转换,从支付方式名称转换为支付方式编码
|
||||
* @param info 支付方式名称
|
||||
* @return 支付方式编码
|
||||
*/
|
||||
public static String getCodeByInfo(String info){
|
||||
return Arrays.stream(values())
|
||||
.filter(c -> c.getInfo().equals(info))
|
||||
.findFirst()
|
||||
.map(SysPayType::getCode)
|
||||
.orElse("-");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue