1
hutongqing
2025-01-11 9be8d6e3232971246ec6cb2acac1ad4d05798e9b
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_SystemService/Sys_UserService.cs
@@ -14,6 +14,11 @@
using SqlSugar;
using ICacheService = WIDESEA_Core.Caches.ICacheService;
using HslCommunication.WebSocket;
using System.Drawing.Drawing2D;
using System.Linq;
using MailKit.Search;
using OrderByType = SqlSugar.OrderByType;
using System.Drawing.Printing;
namespace WIDESEA_SystemService
{
@@ -22,14 +27,16 @@
        private readonly IUnitOfWorkManage _unitOfWorkManage;
        private readonly ICacheService _cacheService;
        private readonly ISys_MenuService _menuService;
        private readonly ISys_RoleService _roleService;
        public ISys_UserRepository Repository => BaseDal;
        public Sys_UserService(ISys_UserRepository repository, IUnitOfWorkManage unitOfWorkManage, ICacheService cacheService, ISys_MenuService menuService) : base(repository)
        public Sys_UserService(ISys_UserRepository repository, IUnitOfWorkManage unitOfWorkManage, ICacheService cacheService, ISys_MenuService menuService, ISys_RoleService roleService) : base(repository)
        {
            _unitOfWorkManage = unitOfWorkManage;
            _cacheService = cacheService;
            _menuService = menuService;
            _roleService = roleService;
        }
        public WebResponseContent Login(LoginInfo loginInfo)
@@ -75,7 +82,7 @@
                    _cacheService.AddOrUpdate(user.UserId.ToString(), token);
                    content = WebResponseContent.Instance.OK(data: new { token, userName = user.UserName, img = user.HeadImageUrl,trueNmae=user.UserTrueName });
                    content = WebResponseContent.Instance.OK(data: new { token, userName = user.UserName, img = user.HeadImageUrl, user.UserTrueName });
                }
                else
                {
@@ -103,6 +110,40 @@
            return base.UpdateData(saveModel);
        }
        public override PageGridData<Sys_User> GetPageData(PageDataOptions options)
        {
            int roleId = -1;
            //树形菜单传查询角色下所有用户
            if (options.Value != null)
            {
                roleId = options.Value.ObjToInt();
            }
            if (roleId <= 0)
            {
                if (App.User.IsHighestRole) return base.GetPageData(options);
                roleId = App.User.RoleId;
            }
            int totalCount = 0;
            List<int> roleIds = _roleService.GetAllChildrenRoleId(roleId).Where(x => x != roleId).ToList();
            ISugarQueryable<Sys_User> sugarQueryable = Db.Queryable<Sys_User>();
            ValidatePageOptions(options, TProperties, ref sugarQueryable);
            Dictionary<string, OrderByType> orderbyDic = options.GetPageDataSort(TProperties);
            List<OrderByModel> orderByModels = new List<OrderByModel>();
            foreach (var item in orderbyDic)
            {
                OrderByModel orderByModel = new OrderByModel()
                {
                    FieldName = item.Key,
                    OrderByType = item.Value
                };
                orderByModels.Add(orderByModel);
            }
            List<Sys_User> users = sugarQueryable.Where(x => roleIds.Contains(x.RoleId) || x.UserId == App.User.UserId).OrderBy(orderByModels).ToPageList(options.Page, options.Rows, ref totalCount);
            return new PageGridData<Sys_User> { Rows = users, Total = totalCount };
        }
        public override WebResponseContent AddData(SaveModel saveModel)
        {
            string pwd = "123456";