liyong
3 天以前 d62a74c14a4002c0f401c94976fba8cc77cda6e1
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
package cn.iocoder.yudao.module.system.enums.storage;
 
import lombok.AllArgsConstructor;
import lombok.Getter;
 
/**
 * 文件用途枚举
 * 用于区分同一条业务记录下不同用途的附件
 */
@Getter
@AllArgsConstructor
public enum StorageApplicationTypeEnum {
 
    FILE("file", "通用文件"),
    IMAGE("image", "图片"),
    AVATAR("avatar", "头像");
 
    private final String type;
    private final String description;
 
    /**
     * 根据 type 值获取对应的枚举实例
     */
    public static StorageApplicationTypeEnum getByType(String type) {
        for (StorageApplicationTypeEnum enumValue : StorageApplicationTypeEnum.values()) {
            if (enumValue.getType().equals(type)) {
                return enumValue;
            }
        }
        throw new IllegalArgumentException("无效的文件用途类型: " + type);
    }
 
}