bool HasPermission(string UserId, string Key, PermissionType Type = PermissionType.Menu) { log.Info("ProtalHasPermission", UserId, Key, Type); if (UserId.IsEmpty()) { return(false); } if (Key.IsEmpty()) { return(true); } if (UserId.ToInt() < 0) { return(true); } switch (Type) { case PermissionType.Menu: { ICache wc = new WebCache(); return(wc.Simple($"Permission_{Type.ToString()}_{UserId}", () => _db.ExecuteTable($@"SELECT A.MENUID FROM USERMODULE A,MENU B where A.MENUID = B.ID and exists(select 1 from USER_ROLE A1, ROLE_MENU B1,USERMODULE C1 where A1.USERID= '{UserId}' and A1.ROLEID = B1.ROLEID and B1.MENUID=C1.MENUID and C1.MENUID = A.MENUID )") .ToList <string>().ToArray()) .Contains(Type.ToString() + Key)); } default: { throw new Exception("未知的权限类型"); } } }
bool HasPermission(string UserId, string Key, PermissionType Type = PermissionType.Menu) { log.Info("ERPHasPermission", UserId, Key, Type); if (UserId.IsEmpty()) { return(false); } if (Key.IsEmpty()) { return(true); } if (UserId.ToInt() < 0) { return(true); } switch (Type) { case PermissionType.Menu: { ICache wc = new WebCache(); return(wc.Simple($"Permission_{Type.ToString()}_{UserId}", () => service.GetPermissionByUserId(UserId)) .Contains(Key)); } default: { throw new Exception("未知的权限类型"); } } }
public string[] GetPermissionByUserId(string userid) { return(LogRun(() => { ICache wc = new WebCache(); return wc.Simple($"GetPermissionByUserId{userid}", () => service.HomeService.GetPermissionByUserId(userid)); }, "GetPermissionByUserId", userid)); //return service.HomeService.GetPermissionByUserId(userid); }
public User GetUserById(string id) { return(LogRun(() => { //return service.HomeService.GetUserById(id); ICache wc = new WebCache(); return wc.Simple($"GetUserById{id}", () => service.HomeService.GetUserById(id)); }, "GetUserById", id)); //return service.HomeService.GetUserById(id); }); }