/// <summary> /// 后台权限验证 /// </summary> public static bool IsLoginPowerView(Dt_User user, string absolutePath) { try { if (user.role_type == 2 || absolutePath == "通用") { return(true); } if (user.role_type == 1 && user.role_id <= 0) { return(false); } var role = GetRole(user.role_id); if (role == null) { return(false); } int[] partnoArr = DateTableTool.DataTableToList <Dt_RoleMethod>(sql.RtDataTable("select * from Dt_RoleMethod where RoleId = {" + role.Id + "}")).Select(m => m.MethodId).ToArray(); var menu = DateTableTool.DataTalbeToEntity <Dt_Method>(sql.RtDataTable("select top 1 * from Dt_Method where Power='" + absolutePath + "'")); if (menu != null) { return(false); } return(true); } catch (Exception e) { Log.Error("检测权限状态,错误信息", e.Message); return(false); } }
/// <summary> /// 获取Method对象 /// </summary> /// <param name="id">ID</param> /// <returns></returns> public static Dt_Method GetMethod(long?id) { if (id != null) { return(DateTableTool.DataTalbeToEntity <Dt_Method>(sql.RtDataTable("select * from Dt_Method where Id=" + id))); } else { return(null); } }
/// <summary> /// 登录验证 /// </summary> public static Dt_User IsLoginAdmin(Object entity) { try { if (entity == null) { return(null); } Dt_User user = DateTableTool.DataTalbeToEntity <Dt_User>((DataTable)entity); RoleFuns.UpAdminLoginLog(user.username, DateTime.Now.AddMinutes(30)); return(user); } catch (Exception e) { Log.Error("检测登录状态,错误信息", e.Message); return(null); } }
/// <summary> /// 获取Role对象 /// </summary> /// <param name="id">ID</param> /// <returns></returns> public static Dt_Role GetRole(int id) { return(DateTableTool.DataTalbeToEntity <Dt_Role>(sql.RtDataTable("select * from Dt_Role where Id={" + id + "}"))); }