/**
 * 参数权限枚举，定义参数操作的不同权限级别
 *
 * @version 1.0
 * @since 2025
 */
package com.xdap.self_development.domain.enums;

import lombok.Getter;

@Getter
public enum ParamPermissionEnum {

    /**
     * 查看
     */
    REVIEW(1, "查看"),
    /**
     * 编辑
     */
    EDITOR(2, "编辑");

    /**
     * 编码
     */
    private final Integer code;
    /**
     * 描述
     */
    private final String desc;

    ParamPermissionEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static ParamPermissionEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (ParamPermissionEnum status : values()) {
            if (status.code.equals(code)) {
                return status;
            }
        }
        return null;
    }

    public static ParamPermissionEnum getByDesc(String desc) {
        if (desc == null) {
            return null;
        }
        for (ParamPermissionEnum status : values()) {
            if (status.desc.equals(desc)) {
                return status;
            }
        }
        return null;
    }
}
