1
dengjunjie
2025-05-08 092971a8ba7848f024427694c642959d0fbc8599
ÏîÄ¿´úÂë/WCS/WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_UserService.cs
@@ -22,39 +22,41 @@
    {
        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();
@@ -78,6 +80,7 @@
                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