mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.panzhihua.common.enums;
 
import lombok.Getter;
 
/**
 * 性别枚举
 *
 * @author huanghongfa
 */
@Getter
public enum PopulSexEnum {
    nan(1, "男"), nv(2, "女"), weizhi(3, "未知");
 
    private final Integer code;
    private final String name;
 
    PopulSexEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }
 
    public static int getCodeByName(String name) {
        for (PopulSexEnum item : PopulSexEnum.values()) {
            if (item.name.equals(name)) {
                return item.getCode();
            }
        }
        return 3;
    }
 
    public static String getCnDescByName(Integer code) {
        for (PopulSexEnum item : PopulSexEnum.values()) {
            if (item.code.equals(code)) {
                return item.getName();
            }
        }
        return "未知";
    }
 
}