package com.vctgo.file.enums;

import lombok.AllArgsConstructor;

import java.util.Arrays;
import java.util.Optional;

/**
 * 用户对文件操作项
 *
 * @author vctgo
 */
@AllArgsConstructor
public enum UserFileOperateEnum {
    /**
     * 查看、上传、下载、移动、重命名、删除
     */
    VIEW("1", "查看"),
    UPLOAD("2", "上传"),
    DOWNLOAD("3", "下载"),
    MOVE("4", "移动"),
    RENAME("5", "重命名"),
    DELETE("6", "删除");

    private final String code;
    private final String info;

    public String getCode() {
        return code;
    }

    public String getInfo() {
        return info;
    }

    public static String getInfoByCode(String code) {
        Optional<UserFileOperateEnum> userFileOperateEnumOptional = Arrays.stream(values()).filter(value -> value.code.equals(code)).findFirst();
        return userFileOperateEnumOptional.isPresent() ? userFileOperateEnumOptional.get().info : "";
    }
}
