package com.qmth.teachcloud.common.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.qmth.teachcloud.common.base.BaseEntity;
import com.qmth.teachcloud.common.enums.RoleSourceEnum;
import com.qmth.teachcloud.common.enums.RoleTypeEnum;
import io.swagger.annotations.ApiModelProperty;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import java.io.Serializable;

/**
 * <p>
 * 角色表
 * </p>
 *
 * @author xf
 * @since 2021-03-23
 */
@TableName("sys_role")
public class SysRole extends BaseEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "学校id")
    @JsonSerialize(using = ToStringSerializer.class)
    @TableField("school_id")
    private Long schoolId;

    @ApiModelProperty(value = "机构id")
    @JsonSerialize(using = ToStringSerializer.class)
    @TableField("org_id")
    private Long orgId;

    /**
     * 角色名称
     */
    @NotBlank(message = "角色名称不能为空")
    private String name;

    /**
     * 是否启用
     */
    @ApiModelProperty(value = "是否启用，0：停用，1：启用")
    private Boolean enable;

    @ApiModelProperty(value = "角色类别，ADMIN：超级管理员，SCHOOL_ADMIN：学校管理员：EXAM_TEACHER：考务老师，QUESTION_TEACHER：命题老师，CUSTOMER：客服人员，PRINTER：印刷人员，CUSTOM：自定义")
    @TableField(value = "type")
    private RoleTypeEnum type;

    @JsonSerialize(using = ToStringSerializer.class)
    @TableField(exist = false)
    @NotEmpty(message = "权限集合不能为空")
    private Long[] privilegeIds;

    @ApiModelProperty(value = "是否系统内置角色，1：是，0：不是")
    private Boolean defaultRole;

    @ApiModelProperty(value = "角色来源")
    private RoleSourceEnum source;

    public RoleSourceEnum getSource() {
        return source;
    }

    public void setSource(RoleSourceEnum source) {
        this.source = source;
    }

    public Boolean getDefaultRole() {
        return defaultRole;
    }

    public void setDefaultRole(Boolean defaultRole) {
        this.defaultRole = defaultRole;
    }

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public Long getOrgId() {
        return orgId;
    }

    public void setOrgId(Long orgId) {
        this.orgId = orgId;
    }

    public Long getSchoolId() {
        return schoolId;
    }

    public void setSchoolId(Long schoolId) {
        this.schoolId = schoolId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Boolean getEnable() {
        return enable;
    }

    public void setEnable(Boolean enable) {
        this.enable = enable;
    }

    public RoleTypeEnum getType() {
        return type;
    }

    public void setType(RoleTypeEnum type) {
        this.type = type;
    }

    public Long[] getPrivilegeIds() {
        return privilegeIds;
    }

    public void setPrivilegeIds(Long[] privilegeIds) {
        this.privilegeIds = privilegeIds;
    }

}
