package com.yunfeiyun.agmp.common.core.domain.entity;

import java.util.Set;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import com.yunfeiyun.agmp.common.constant.Constants;
import com.yunfeiyun.agmp.common.core.domain.BaseEntity;
import com.yunfeiyun.agmp.common.core.domain.model.IBaseRole;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.yunfeiyun.agmp.common.annotation.Excel;

/**
 * 角色表 SysRole
 * 
 * @author 杨晓辉
 */
public class SysRole extends BaseEntity implements IBaseRole
{
    private static final long serialVersionUID = 1L;

    /** 角色ID */
    @Excel(name = "角色序号")
    private String roleId;

    /** 角色名称 */
    @Excel(name = "角色名称")
    private String roleName;

    /** 角色权限 */
    @Excel(name = "角色权限")
    private String roleKey;

    /** 角色排序 */
    @Excel(name = "角色排序")
    private Integer roleSeq;

    /** 数据范围（1：所有数据权限；2：自定义数据权限；3：本部门数据权限；4：本部门及以下数据权限；5：仅本人数据权限） */
    @Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限,5=仅本人数据权限")
    private String roleDatascope;

    /** 菜单树选择项是否关联显示（ 0：父子不互相关联显示 1：父子互相关联显示） */
    private boolean roleMenucheckstrictly;

    /** 部门树选择项是否关联显示（0：父子不互相关联显示 1：父子互相关联显示 ） */
    private boolean roleDeptcheckstrictly;

    /** 角色状态（0正常 1停用） */
    @Excel(name = "角色状态")
    private String roleAvlstatus;

    /** 删除标志（0代表存在 2代表删除） */
    private String roleDelstatus;

    /** 用户是否存在此角色标识 默认不存在 */
    private boolean flag = false;

    /** 菜单组 */
    private String[] menuIds;

    /** 部门组（数据权限） */
    private String[] deptIds;

    /** 角色菜单权限 */
    private Set<String> permissions;


    /** 角色创建者 */
    @Excel(name = "角色创建者")
    private String roleCreator;

    /** 角色创建时间 */
    @Excel(name = "角色创建时间")
    private String roleCreateddate;

    /** 角色更新者 */
    @Excel(name = "角色更新者")
    private String roleModifier;

    /** 角色更新时间 */
    @Excel(name = "角色更新时间")
    private String roleModifieddate;

    /** 角色备注 */
    @Excel(name = "角色备注")
    private String roleRemark;


    public SysRole()
    {

    }

    public SysRole(String roleId)
    {
        this.roleId = roleId;
    }

    public String getRoleId()
    {
        return roleId;
    }

    public void setRoleId(String roleId)
    {
        this.roleId = roleId;
    }

    public boolean isAdmin()
    {
        return isAdmin(this.roleId);
    }

    public static boolean isAdmin(String roleId)
    {
        return roleId != null && Constants.ROLE_ADMIN_KEY.equals(roleId);
    }

    @NotBlank(message = "角色名称不能为空")
    @Size(min = 0, max = 30, message = "角色名称长度不能超过30个字符")
    public String getRoleName()
    {
        return roleName;
    }

    public void setRoleName(String roleName)
    {
        this.roleName = roleName;
    }

    @NotBlank(message = "权限字符不能为空")
    @Size(min = 0, max = 100, message = "权限字符长度不能超过100个字符")
    public String getRoleKey()
    {
        return roleKey;
    }

    public void setRoleKey(String roleKey)
    {
        this.roleKey = roleKey;
    }

    @NotNull(message = "显示顺序不能为空")
    public Integer getRoleSeq()
    {
        return roleSeq;
    }

    public void setRoleSeq(Integer roleSeq)
    {
        this.roleSeq = roleSeq;
    }

    public String getRoleDataScope()
    {
        return roleDatascope;
    }

    public void setRoleDataScope(String roleDatascope)
    {
        this.roleDatascope = roleDatascope;
    }

    public boolean isRoleMenuCheckStrictly()
    {
        return roleMenucheckstrictly;
    }

    public void setRoleMenuCheckStrictly(boolean roleMenucheckstrictly)
    {
        this.roleMenucheckstrictly = roleMenucheckstrictly;
    }

    public boolean isRoleDeptCheckStrictly()
    {
        return roleDeptcheckstrictly;
    }

    public void setRoleDeptCheckStrictly(boolean roleDeptcheckstrictly)
    {
        this.roleDeptcheckstrictly = roleDeptcheckstrictly;
    }

    public String getRoleAvlstatus()
    {
        return roleAvlstatus;
    }

    public void setRoleAvlstatus(String roleAvlstatus)
    {
        this.roleAvlstatus = roleAvlstatus;
    }

    public String getRoleDelstatus()
    {
        return roleDelstatus;
    }

    public void setRoleDelstatus(String roleDelstatus)
    {
        this.roleDelstatus = roleDelstatus;
    }

    public boolean isFlag()
    {
        return flag;
    }

    public void setFlag(boolean flag)
    {
        this.flag = flag;
    }

    public String[] getMenuIds()
    {
        return menuIds;
    }

    public void setMenuIds(String[] menuIds)
    {
        this.menuIds = menuIds;
    }

    public String[] getDeptIds()
    {
        return deptIds;
    }

    public void setDeptIds(String[] deptIds)
    {
        this.deptIds = deptIds;
    }

    public Set<String> getPermissions()
    {
        return permissions;
    }

    public void setPermissions(Set<String> permissions)
    {
        this.permissions = permissions;
    }


    public String getRoleCreator()
    {
        return roleCreator;
    }

    public void setRoleCreator(String roleCreator)
    {
        this.roleCreator = roleCreator;
    }

    public String getRoleCreateddate()
    {
        return roleCreateddate;
    }

    public void setRoleCreateddate(String roleCreateddate)
    {
        this.roleCreateddate = roleCreateddate;
    }

    public String getRoleModifier()
    {
        return roleModifier;
    }

    public void setRoleModifier(String roleModifier)
    {
        this.roleModifier = roleModifier;
    }

    public String getRoleModifieddate()
    {
        return roleModifieddate;
    }

    public void setRoleModifieddate(String roleModifieddate)
    {
        this.roleModifieddate = roleModifieddate;
    }

    public String getRoleRemark()
    {
        return roleRemark;
    }

    public void setRoleRemark(String roleRemark)
    {
        this.roleRemark = roleRemark;
    }




    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("roleId", getRoleId())
            .append("roleName", getRoleName())
            .append("roleKey", getRoleKey())
            .append("roleSeq", getRoleSeq())
            .append("roleDatascope", getRoleDataScope())
            .append("roleMenucheckstrictly", isRoleMenuCheckStrictly())
            .append("roleDeptcheckstrictly", isRoleDeptCheckStrictly())
            .append("roleAvlstatus", getRoleAvlstatus())
            .append("roleDelstatus", getRoleDelstatus())
            .append("roleCreator", getRoleCreator())
            .append("roleCreateddate", getRoleCreateddate())
            .append("roleModifier", getRoleModifier())
            .append("roleModifieddate", getRoleModifieddate())
            .append("roleRemark", getRoleRemark())
            .toString();
    }
}
