lihao 4 years ago
parent
commit
80f2a426b9

+ 5 - 1
gx_api/GxPress/Api/GxPress.Api/AppControllers/DepartmentController.cs

@@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Mvc;
 using GxPress.Service.Interface.Department;
 using System.Collections.Generic;
+using GxPress.Auth;
 
 namespace GxPress.Api.AppControllers
 {
@@ -16,10 +17,12 @@ namespace GxPress.Api.AppControllers
     {
         private readonly IDepartmentRepository _departmentRepository;
         private readonly IDepartmentService departmentService;
-        public DepartmentController(IDepartmentRepository departmentRepository, IDepartmentService departmentService)
+        private readonly ILoginContext _loginContext;
+        public DepartmentController(IDepartmentRepository departmentRepository, IDepartmentService departmentService, ILoginContext _loginContext)
         {
             _departmentRepository = departmentRepository;
             this.departmentService = departmentService;
+            this._loginContext = _loginContext;
         }
 
         /// <summary>
@@ -30,6 +33,7 @@ namespace GxPress.Api.AppControllers
         [HttpPost("user-list")]
         public async Task<DepartmentUserResult> GetDepartmentUserResult(DepartmentUserRequest request)
         {
+            request.UserId = _loginContext.AccountId;
             return await departmentService.GetDepartmentUserResultAsync(request);
         }
         [HttpGet("{userId}")]

+ 3 - 2
gx_api/GxPress/Api/GxPress.Api/WebControllers/UserController.cs

@@ -66,7 +66,7 @@ namespace GxPress.Api.WebControllers
         private readonly IMapper _mapper;
         public UserController(IUserRepository userRepository, IOptions<JwtOptions> jwtOptions,
             ILogger<UserController> logger, IDepartmentRepository departmentRepository, ILoginContext loginContext,
-            IUserService userService, IFileLibraryRepository fileLibraryRepository, IDistributedCache cache, IUserLoginRepository userLoginRepository, IAddressBookGroupRepository addressBookGroupRepository, IAddressBookGroupUserRepository _addressBookGroupUserRepository, IFeedbackRepository _feedbackRepository, IFriendsRepository friendsRepository, IDepartmentService departmentService, IUserMiddleService userMiddleService,IMapper _mapper)
+            IUserService userService, IFileLibraryRepository fileLibraryRepository, IDistributedCache cache, IUserLoginRepository userLoginRepository, IAddressBookGroupRepository addressBookGroupRepository, IAddressBookGroupUserRepository _addressBookGroupUserRepository, IFeedbackRepository _feedbackRepository, IFriendsRepository friendsRepository, IDepartmentService departmentService, IUserMiddleService userMiddleService, IMapper _mapper)
         {
             _userRepository = userRepository;
             _departmentRepository = departmentRepository;
@@ -83,7 +83,7 @@ namespace GxPress.Api.WebControllers
             this.friendsRepository = friendsRepository;
             this.departmentService = departmentService;
             this.userMiddleService = userMiddleService;
-            this._mapper=_mapper;
+            this._mapper = _mapper;
         }
         /// <summary>
         /// 登录
@@ -454,6 +454,7 @@ namespace GxPress.Api.WebControllers
         [HttpPost("user-list")]
         public async Task<DepartmentUserResult> GetDepartmentUserResult(DepartmentUserRequest request)
         {
+            request.UserId = _loginContext.AccountId;
             return await departmentService.GetDepartmentUserResultAsync(request);
         }
         /// <summary>

+ 5 - 0
gx_api/GxPress/Model/GxPress.Request/Department/DepartmentUserRequest.cs

@@ -15,6 +15,11 @@ namespace GxPress.Request.Department
         {
             UserIds = new List<int>();
         }
+        /// <summary>
+        /// 用户Id
+        /// </summary>
+        /// <value></value>
+        public int UserId { get; set; }
 
     }
     /// <summary>

+ 4 - 1
gx_api/GxPress/Repository/GxPress.Repository.Implement/DepartmentRepository.cs

@@ -222,6 +222,9 @@ namespace GxPress.Repository.Implement
             result.Departments = departments;
             //获取用户ID
             var departmentUsers = await departmentUserRepository.GetAllAsync<int>(Q.Where(nameof(Entity.DepartmentUser.DepartmentId), request.DepartmentId).Select(nameof(Entity.DepartmentUser.UserId)));
+            //判断是否包含该用户
+            if (!departmentUsers.Contains(request.UserId))
+                return result;
             var users = await _userRepository.GetAllAsync<UserInfoResult>(Q.WhereIn(nameof(User.Id), departmentUsers));
             result.Users = users.ToList();
             foreach (var item in result.Users)
@@ -458,7 +461,7 @@ namespace GxPress.Repository.Implement
                     Item = await GetDepartmentByPid(departmentId, new List<Entity.Department>(), allDepartment.ToList())
                 });
             }
-             if (departmentIds.Count() <= 2)
+            if (departmentIds.Count() <= 2)
                 departmentIdsList.AddRange(departmentIds);
             for (int i = 0; i < result.Result.Count; i++)
             {

+ 5 - 1
gx_api/GxPress/Repository/GxPress.Repository.Implement/RecordFolder/RecordFolderRepository.cs

@@ -34,7 +34,11 @@ namespace GxPress.Repository.Implement.RecordFolder
         /// <returns></returns>
         public async Task<Entity.RecordFolder.RecordFolder> GetAsync(int folderType, int userId)
         {
-            var recordFolder = await _repository.GetAsync(Q.Where(nameof(Entity.RecordFolder.RecordFolder.UserId), userId).Where(nameof(Entity.RecordFolder.RecordFolder.FolderType), folderType));
+            var query = Q.NewQuery();
+            query.Where(nameof(Entity.RecordFolder.RecordFolder.UserId), userId);
+            query.Where(nameof(Entity.RecordFolder.RecordFolder.FolderType), folderType);
+            query.OrderByDesc(nameof(Entity.RecordFolder.RecordFolder.CreatedDate));
+            var recordFolder = await _repository.GetAsync(query);
             if (recordFolder == null)
             {
                 recordFolder = new Entity.RecordFolder.RecordFolder();