package org.springblade.common.auth.support;

import lombok.Data;

import java.util.List;

/**
 * 登录人信息
 *
 * @author majunjie
 * @date 2019/5/10 15:25
 */
@Data
public class AdminUserDTO {

    /**
     * 账户名称
     */
    private String accountName;
    /**
     * 角色类型
     */
    private Integer roleTye;
    /**
     * 采购商id
     */
    private Long jifenBusinessId;
    /**
     * 渠道id
     */
    private Long jifenProductId;
    /**
     * 渠道id集合
     */
    private List<Long> channelIdList;
    /**
     * 供应商id
     */
    private Long goodsBusinessId;
    /**
     * 员工id
     */
    private Long staffId;
    /**
     * 员工任职记录
     */
    private List<StaffRecord> staffRecordList;

    @Data
    public static class StaffRecord {

        /**
         * 部门id
         */
        private Long departmentId;
        /**
         * 数据权限：0-仅自己 1-本部门 2-本部门及下级部门
         */
        private Integer dataSecurity;
    }

    public enum RoleType {
        ADMIN(1, "管理员"),
        STAFF(2, "公司员工"),
        JIFEN_BUSINESS(3, "采购商"),
        JIFEN_PRODUCT(4, "渠道"),
        GOODS_BUSINESS(5, "供应商"),
        ;

        /**
         * 类型
         */
        private int type;
        /**
         * 描述
         */
        private String remark;

        RoleType(int type, String remark) {
            this.type = type;
            this.remark = remark;
        }

        public static RoleType getEnum(Integer roleType) {
            if (roleType == null) {
                return null;
            }
            RoleType[] values = RoleType.values();
            for (RoleType value : values) {
                if (value.type == roleType) {
                    return value;
                }
            }
            return null;
        }

        public int getType() {
            return type;
        }

        public String getRemark() {
            return remark;
        }
    }

    public enum DataSecurityType {
        SELF(0, "仅自己"),
        DEPARTMENT(1, "本部门"),
        DEEP_DEPARTMENT(2, "本部门及下级部门"),
        ;

        /**
         * 类型
         */
        private int type;
        /**
         * 描述
         */
        private String remark;

        DataSecurityType(int type, String remark) {
            this.type = type;
            this.remark = remark;
        }

        public static DataSecurityType getEnum(Integer dataSecurityType) {
            if (dataSecurityType == null) {
                return null;
            }
            DataSecurityType[] values = DataSecurityType.values();
            for (DataSecurityType value : values) {
                if (value.type == dataSecurityType) {
                    return value;
                }
            }
            return null;
        }

        public int getType() {
            return type;
        }

        public String getRemark() {
            return remark;
        }
    }

}
