我正在Spring Boot上创建项目。而且我对数据库中的实体的语言环境有疑问。例如: RUB-руб。 USD-доллары。 我正在用localecode创建枚举,但这是一个坏习惯。
这是我在Kotlin上的代码:
enum class ProfField(val localeCode: String) {
SALES("enum.prof.field.sales"),
PRODUCTION("enum.prof.field.production"),
WORKING_STAFF("enum.prof.field.working.staff"),
IT_TELECOM("enum.prof.field.it.telecom"),
CARIER_START("enum.prof.field.carier.start"),
BUILDING("enum.prof.field.building"),
ADMINISTARTION("enum.prof.field.administration"),
BANKS("enum.prof.field.banks"),
TRANSPORT("enum.prof.field.transport"),
BOOKKIPING("enum.prof.field.bookkiping"),
MARKETING("enum.prof.field.marketing"),
TOURISM("enum.prof.field.tourism"),
MEDICINE("enum.prof.field.medicine"),
COUNSELING("enum.prof.field.counseling"),
AUTO("enum.prof.field.auto"),
TOP_MANAGEMENT("enum.prof.field.top.management"),
HUMAN_RESOURCES("enum.prof.field.human.resources"),
SECURITY("enum.prof.field.security"),
PURCHASES("enum.prof.field.purchases"),
ART_AND_MEDIA("enum.prof.field.art.and.media"),
SCIENCE_AND_EDUCATION("enum.prof.field.science.and.education"),
JURISPRUDENCE("enum.prof.field.jurisprudence"),
INSTALLATION("enum.prof.field.installation"),
SPORT_AND_FITNESS("enum.prof.field.sport.and.fitness"),
INSUREANCE("enum.prof.field.insureance"),
HOME_STAFF("enum.prof.field.home.staff"),
CIVIL_SERVICE("enum.prof.field.civil.service"),
PRODUCTION_MINE("enum.prof.field.production.mine");
companion object {
fun getEnum(value: String): ProfField? {
for (enumObj in ProfField.values())
if (enumObj.name.equals(value, ignoreCase = true))
return enumObj
return null
}
}
}
我认为这很糟糕...请帮助。