xiangpei
2024-12-12 2330e34c1d0f8a3c58a729eaee8e9987f612d83d
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
package com.ycl.common.enums.business;
 
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;
 
/**
 * 项目状态枚举
 *
 * @author:flq
 * @date:2024/11/27 18:21
 */
@Getter
public enum ProjectStatusEnum {
    PENDDING("pendding", "未开工"),
    WORKING("working","已开工"),
    FINISH("finish","已竣工"),
    STOP("stop", "暂停");
 
    @EnumValue // 标明该字段存入数据库
    private final String type;
 
    @JsonValue // 标明在转JSON时使用该字段
    private final String desc;
 
    ProjectStatusEnum(String type, String desc) {
        this.type = type;
        this.desc = desc;
    }
 
    public static String getDescByType(String type) {
        for (ProjectStatusEnum status : ProjectStatusEnum.values()) {
            if (status.type.equals(type)) {
                return status.desc;
            }
        }
        return null; // 如果没有找到对应的类型,可以返回 null 或者抛出异常
    }
}