57 lines
2.0 KiB
C#
57 lines
2.0 KiB
C#
using BaseOUDAL;
|
|
|
|
namespace YLErp.Modules.SystemModule
|
|
{
|
|
//自ylerpweb项目移入
|
|
|
|
public class RoleRight
|
|
{
|
|
public static List<RoleFunction> Roles = new List<RoleFunction>();
|
|
|
|
public static bool GetRoleFunction(int? roleId, string fName)
|
|
{
|
|
using (var db = new ErpBaseContext())
|
|
{
|
|
Roles = (from o in db.RoleFunctions join p in db.Functions on o.FunctionId equals p.Id where o.RoleId == roleId && p.Name == fName select o).ToList();
|
|
if (Roles != null && Roles.Count > 0)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public static List<SystemUser> GetSystemUserByFunction(string fName, bool checkStatus = true)
|
|
{
|
|
var users = new List<SystemUser>();
|
|
using (var db = new ErpBaseContext())
|
|
{
|
|
if (string.IsNullOrEmpty(fName))
|
|
{
|
|
users = db.SystemUsers.Where(a=>a.State==0 || !checkStatus).AsQueryable().ToList();
|
|
}
|
|
else
|
|
{
|
|
users = (from a in db.SystemUsers join b in db.RoleUsers on a.Id equals b.UserId join o in db.RoleFunctions on b.RoleId equals o.RoleId join p in db.Functions on o.FunctionId equals p.Id where p.Name == fName && (a.State != 1 || !checkStatus) select a).Distinct().ToList();
|
|
}
|
|
return users;
|
|
}
|
|
}
|
|
|
|
public static bool GetRoleFunctionByRoles(List<int> roleIds, string fName)
|
|
{
|
|
using (var db = new ErpBaseContext())
|
|
{
|
|
foreach (var ids in roleIds)
|
|
{
|
|
Roles = (from o in db.RoleFunctions join p in db.Functions on o.FunctionId equals p.Id where o.RoleId == ids && p.Name == fName select o).ToList();
|
|
}
|
|
}
|
|
if (Roles != null && Roles.Count > 0)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
} |