package com.yuchen.saas.manage.system.api.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * 功能相关
 */
@Getter
@AllArgsConstructor
public class NestFeatureEnum {
    @Getter
    @AllArgsConstructor
    public enum TypeEnum {
        BUSINESS("1", "业务功能"),
        COMMON("2", "通用功能"),
        DEFAULT("3", "默认功能"),
        PLATFORM("4", "平台管理"),
        ;

        private final String code;
        private final String desc;

        public static String getDescByCode(Integer code) {
            if (Objects.isNull(code)) {
                return null;
            }
            NestFeatureEnum.TypeEnum[] enumArray = NestFeatureEnum.TypeEnum.values();
            for (NestFeatureEnum.TypeEnum e : enumArray) {
                if (e.getCode().equals(code)) {
                    return e.getDesc();
                }
            }
            return "";
        }

    }
    @Getter
    @AllArgsConstructor
    public enum UserTypeEnum {
        ENABLE(1, "管理员"),
        DISABLE(2, "员工")
        ;

        private final int code;
        private final String desc;

        public static String getDescByCode(Integer code) {
            if (Objects.isNull(code)) {
                return null;
            }
            NestFeatureEnum.StatusEnum[] enumArray = NestFeatureEnum.StatusEnum.values();
            for (NestFeatureEnum.StatusEnum e : enumArray) {
                if (e.getCode() == code) {
                    return e.getDesc();
                }
            }
            return "";
        }
    }


    @Getter
    @AllArgsConstructor
    public enum StatusEnum {
        ENABLE(1, "启用"),
        DISABLE(2, "禁用")
        ;

        private final int code;
        private final String desc;

        public static String getDescByCode(Integer code) {
            if (Objects.isNull(code)) {
                return null;
            }
            NestFeatureEnum.StatusEnum[] enumArray = NestFeatureEnum.StatusEnum.values();
            for (NestFeatureEnum.StatusEnum e : enumArray) {
                if (e.getCode() == code) {
                    return e.getDesc();
                }
            }
            return "";
        }
    }
    @Getter
    @AllArgsConstructor
    public enum UsingEnum {
        CUSTOM(1, "平台客户"),
        ORGANIZATION(2, "平台组织"),
        ;

        private final Integer code;
        private final String desc;

        public static String getDescByCode(String code) {
            if (Objects.isNull(code)) {
                return null;
            }
            NestFeatureEnum.UsingEnum[] enumArray = NestFeatureEnum.UsingEnum.values();
            for (NestFeatureEnum.UsingEnum e : enumArray) {
                if (e.getCode().equals(code) ) {
                    return e.getDesc();
                }
            }
            return "";
        }
    }


}