package com.njcn.rdms.module.system.enums.permission;

import com.njcn.rdms.framework.common.util.object.ObjectUtils;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum RoleCodeEnum {

    SUPER_ADMIN("super_admin", "超级管理员"),
    CRM_ADMIN("crm_admin", "CRM 管理员"),

    // 对象域内置角色：被业务代码硬编码引用（按 code 查 system_role），改 code 或删除会让对应业务功能炸
    PRODUCT_MANAGER("product_manager", "产品经理"),
    PRODUCT_CREATOR("product_creator", "产品创建者"),
    PRODUCT_WATCHER("product_watcher", "产品关心人"),
    IMPLICIT_OBSERVER_PRODUCT("implicit_observer_product", "产品隐式观察者"),
    PROJECT_MANAGER("project_manager", "项目经理"),
    PROJECT_CREATOR("project_creator", "项目创建者"),
    PROJECT_WATCHER("project_watcher", "项目关心人"),
    IMPLICIT_OBSERVER_PROJECT("implicit_observer_project", "项目隐式观察者"),
    VISITOR("visitor", "游客");

    private final String code;
    private final String name;

    public static boolean isSuperAdmin(String code) {
        return ObjectUtils.equalsAny(code, SUPER_ADMIN.getCode());
    }

    public static boolean isBuiltIn(String code) {
        return ObjectUtils.equalsAny(code,
                SUPER_ADMIN.getCode(), CRM_ADMIN.getCode(),
                PRODUCT_MANAGER.getCode(), PRODUCT_CREATOR.getCode(),
                PRODUCT_WATCHER.getCode(), IMPLICIT_OBSERVER_PRODUCT.getCode(),
                PROJECT_MANAGER.getCode(), PROJECT_CREATOR.getCode(),
                PROJECT_WATCHER.getCode(), IMPLICIT_OBSERVER_PROJECT.getCode(),
                VISITOR.getCode());
    }

}
