From be484c84a25d1f6c769e7b5e958048d745942e55 Mon Sep 17 00:00:00 2001 From: dengjunjie <dengjunjie@hnkhzn.com> Date: 星期二, 20 五月 2025 10:32:57 +0800 Subject: [PATCH] 优化出入库逻辑 --- 项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_UserService.cs | 62 +++++++++++++++++-------------- 1 files changed, 34 insertions(+), 28 deletions(-) diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_UserService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_UserService.cs" index 8bd4df9..4822cca 100644 --- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_UserService.cs" +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/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 @@ -113,8 +116,11 @@ #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 -- Gitblit v1.9.3