币种枚举

2024年7月29日 15:15:01
This commit is contained in:
xiang2lin 2024-07-29 15:15:03 +08:00
parent e6239e89bc
commit 7f9a513305
1 changed files with 51 additions and 0 deletions

View File

@ -0,0 +1,51 @@
package com.hzya.frame.ningboBankTreasury.enums;
/**
* @Description 币种枚举
* @Author xiangerlin
* @Date 2024/7/24 17:07
**/
public enum CurrencyEnum {
人民币("01","人民币"),
美元("02","美元"),
澳元("03","澳元"),
欧元("04","欧元"),
日元("05","日元"),
英镑("06","英镑"),
港币("07","港币"),
新加坡元("08","新加坡元"),
加拿大元("09","加拿大元"),
瑞士("10","瑞士"),
泰铢("23","泰铢"),
新台币("92","新台币"),
ALL("ALL","多币");
private final String name;
private final String code;
CurrencyEnum(String name, String code) {
this.name = name;
this.code = code;
}
public String getName() {
return name;
}
public String getCode() {
return code;
}
/**
* 根据code获取币种名字
* @param code
* @return
*/
public static String getNameByCode(String code){
for (CurrencyEnum currency : values()) {
if (currency.code.equals(code)) {
return currency.name;
}
}
return null; // 或者抛出异常表示找不到对应的币种
}
}