| | |
| | | { |
| | | private readonly IUnitOfWorkManage _unitOfWorkManage; |
| | | private readonly ICacheService _cacheService; |
| | | private readonly ISys_MenuService _menuService; |
| | | private readonly ISys_RoleService _sys_RoleService; |
| | | public Sys_UserService(ISys_UserRepository repository, IUnitOfWorkManage unitOfWorkManage, ICacheService cacheService, ISys_RoleService sys_RoleService) : base(repository) |
| | | public Sys_UserService(ISys_UserRepository repository, IUnitOfWorkManage unitOfWorkManage, ICacheService cacheService, ISys_RoleService sys_RoleService, ISys_MenuService menuService) : base(repository) |
| | | { |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _cacheService = cacheService; |
| | | _sys_RoleService = sys_RoleService; |
| | | _menuService = menuService; |
| | | } |
| | | public override PageGridData<Sys_User> GetPageData(PageDataOptions options) |
| | | { |
| | | var roleIds = _sys_RoleService.GetAllChildren(App.User.RoleId).Select(x => x.Id); |
| | | PageGridData<Sys_User> pageGridData = new PageGridData<Sys_User>(); |
| | | //æ å½¢èåä¼ æ¥è¯¢è§è²ä¸ææç¨æ· |
| | | if (App.User.IsSuperAdmin) |
| | | { |
| | | var GridData = base.GetPageData(options); |
| | | pageGridData = new PageGridData<Sys_User>() |
| | | { |
| | | Rows = options.Order?.ToLower() == "asc" ? GridData.Rows.OrderBy(x => x.Role_Id).ToList() : GridData.Rows, |
| | | Total = GridData.Total |
| | | }; |
| | | return pageGridData; |
| | | } |
| | | string where = ValidatePageOptions(options); |
| | | var a = BaseDal.Db.Queryable<Sys_User>().Where(x => roleIds.Contains(x.Role_Id)).Where(where); |
| | | int total = 0; |
| | | pageGridData = new PageGridData<Sys_User>() |
| | | { |
| | | Rows = BaseDal.Db.Queryable<Sys_User>().Where(x => roleIds.Contains(x.Role_Id)).Where(where).ToPageList(options.Page, options.Rows), |
| | | Total = total |
| | | }; |
| | | //public override PageGridData<Sys_User> GetPageData(PageDataOptions options) |
| | | //{ |
| | | // var roleIds = _sys_RoleService.GetAllChildren(App.User.RoleId).Select(x => x.Id); |
| | | // PageGridData<Sys_User> pageGridData = new PageGridData<Sys_User>(); |
| | | // //æ å½¢èåä¼ æ¥è¯¢è§è²ä¸ææç¨æ· |
| | | // if (App.User.IsSuperAdmin) |
| | | // { |
| | | // var GridData = base.GetPageData(options); |
| | | // pageGridData = new PageGridData<Sys_User>() |
| | | // { |
| | | // Rows = options.Order?.ToLower() == "asc" ? GridData.Rows.OrderBy(x => x.Role_Id).ToList() : GridData.Rows, |
| | | // Total = GridData.Total |
| | | // }; |
| | | // return pageGridData; |
| | | // } |
| | | // string where = ValidatePageOptions(options); |
| | | // var a = BaseDal.Db.Queryable<Sys_User>().Where(x => roleIds.Contains(x.Role_Id)).Where(where); |
| | | // int total = 0; |
| | | // pageGridData = new PageGridData<Sys_User>() |
| | | // { |
| | | // Rows = BaseDal.Db.Queryable<Sys_User>().Where(x => roleIds.Contains(x.Role_Id)).Where(where).ToPageList(options.Page, options.Rows), |
| | | // Total = total |
| | | // }; |
| | | |
| | | return pageGridData; |
| | | } |
| | | // return pageGridData; |
| | | //} |
| | | public WebResponseContent Login(LoginInfo loginInfo) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | |
| | | UserInfo user = BaseDal.GetUserInfo(loginInfo.UserName, loginInfo.Password); |
| | | if (user != null) |
| | | { |
| | | object obj = _menuService.GetMenuActionList(user.RoleId); |
| | | #region 夿å½åç¨æ·æ¯å¦å¯ç¨ |
| | | if (BaseDal.QueryFirst(x => x.User_Id == user.UserId, s => s.Enable) != 1) throw new Exception($"è´¦å·{user.UserName}ç¦æ¢ä½¿ç¨,请è系管çå"); |
| | | #endregion |
| | |
| | | |
| | | #region åªè½ä¿®æ¹æ¯å½åç¨æ·è§è²ç级ä½çç¨æ· |
| | | int userId = saveModel.MainData[nameof(Sys_User.User_Id).FirstLetterToLower()].ObjToInt(); |
| | | var roleId = BaseDal.QueryFirst(x => x.User_Id == userId, s => s.Role_Id); |
| | | if (User.Role_Id > roleId || User.Role_Id == roleId && User.User_Id != userId) return WebResponseContent.Instance.Error("ææ ä¿®æ¹æé"); |
| | | int RoleId = saveModel.MainData[nameof(Sys_User.Role_Id).FirstLetterToLower()].ObjToInt(); |
| | | var user = BaseDal.QueryFirst(x => x.User_Id == userId); |
| | | if (User.User_Id == user.User_Id && User.Role_Id != RoleId) return WebResponseContent.Instance.Error("ä¸å¯ä¿®æ¹èªå·±çè§è²"); |
| | | if (User.User_Id != user.User_Id && User.Role_Id >= RoleId) return WebResponseContent.Instance.Error("æéç级ä¸è¶³"); |
| | | if (User.Role_Id > user.Role_Id || User.Role_Id == user.Role_Id && User.User_Id != userId) return WebResponseContent.Instance.Error("ææ ä¿®æ¹æé"); |
| | | //if (User.User_Id != userId) return WebResponseContent.Instance.Error("ææ ä¿®æ¹æé");åªéå½åç¨æ·ä¿®æ¹ |
| | | #endregion |
| | | |