📄 userrole.cs
字号:
namespace PowerEasy.UserManage
{
using PowerEasy.Common;
using PowerEasy.IDal.UserManage;
using PowerEasy.Model.UserManage;
using System;
using System.Collections.Generic;
public sealed class UserRole
{
private static readonly IUserRole dal = DataAccess.CreateRoles();
private static char[] split = new char[] { ',' };
private UserRole()
{
}
public static bool Add(RoleInfo roleInfo)
{
HtmlEncode(roleInfo);
return dal.Add(roleInfo);
}
public static bool Delete(int roleId)
{
if (roleId <= 0)
{
return false;
}
DeleteRoleRelation(roleId);
return dal.Delete(roleId);
}
private static void DeleteRoleRelation(int roleId)
{
dal.DeleteFieldPermissionFromRoles(roleId, 0, null);
dal.DeleteNodePermissionFromRoles(roleId, -2);
dal.DeletePermissionFromRoles(roleId);
dal.DeleteSpecialPermissionFromRoles(roleId, 0);
}
public static RoleInfo GetRoleInfoByRoleId(int roleId)
{
return GetRoleInfoByRoleId(roleId, true);
}
public static RoleInfo GetRoleInfoByRoleId(int roleId, bool isDecode)
{
RoleInfo roleInfoById = dal.GetRoleInfoById(roleId);
if (isDecode)
{
HtmlDecode(roleInfoById);
}
return roleInfoById;
}
public static IList<RoleInfo> GetRoleList()
{
return GetRoleListFromDAL(0, 0);
}
public static IList<RoleInfo> GetRoleList(int startRowIndexId, int maxNumberRows)
{
IList<RoleInfo> roleListFromDAL = GetRoleListFromDAL(startRowIndexId, maxNumberRows);
RoleInfo item = new RoleInfo();
item.RoleId = 0;
item.RoleName = "超级管理员";
item.Description = "超级管理员";
roleListFromDAL.Add(item);
return roleListFromDAL;
}
public static IList<RoleInfo> GetRoleListByRoleId(int adminId)
{
return dal.GetRoleListByRoleId(adminId);
}
private static IList<RoleInfo> GetRoleListFromDAL(int startRowIndexId, int maxNumberRows)
{
return dal.GetRoleList(startRowIndexId, maxNumberRows);
}
public static IList<RoleInfo> GetRoleListNotInRole(int adminId)
{
return dal.GetRoleListNotInRole(adminId);
}
public static int GetTotalOfRoles()
{
return (dal.GetTotalOfRoles() + 1);
}
private static void HtmlDecode(RoleInfo roleInfo)
{
roleInfo.RoleName = DataSecurity.HtmlDecode(roleInfo.RoleName);
roleInfo.Description = DataSecurity.HtmlDecode(roleInfo.Description);
}
private static void HtmlEncode(RoleInfo roleInfo)
{
roleInfo.RoleName = DataSecurity.HtmlEncode(roleInfo.RoleName);
roleInfo.Description = DataSecurity.HtmlEncode(roleInfo.Description);
}
public static bool IsExist(string roleName)
{
roleName = DataSecurity.HtmlEncode(roleName);
return dal.IsExist(roleName);
}
public static bool Update(RoleInfo roleInfo)
{
HtmlEncode(roleInfo);
return dal.Update(roleInfo);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -