package com.qmth.teachcloud.common.enums;

import io.swagger.annotations.ApiModelProperty;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Description: 角色数据权限类型
 * @Author: CaoZixuan
 * @Date: 2022-12-06
 */
public enum DataPermissionTypeEnum {
    SELF("本人数据", 1),
    SELF_COURSE("本人课程数据", 2),
    SELF_ORG("本部门数据", 3),
    SELF_ORG_BELOW("本部门及下级部门数据", 4),
    ALL("全部数据", 5);

    @ApiModelProperty("描述")
    private final String desc;

    @ApiModelProperty("范围大小权重")
    private final int weight;

    DataPermissionTypeEnum(String desc, int weight) {
        this.desc = desc;
        this.weight = weight;
    }

    public String getDesc() {
        return desc;
    }

    public int getWeight() {
        return weight;
    }

    public static List<EnumResult> listTypes() {
        List<EnumResult> list = new ArrayList<EnumResult>();
        for (DataPermissionTypeEnum value : DataPermissionTypeEnum.values()) {
            EnumResult result = new EnumResult();
            result.setName(value.name());
            result.setOrdinal(value.ordinal());
            result.setCode(null);
            result.setDesc(value.getDesc());
            list.add(result);
        }
        return list;
    }
}
