李昊 vor 4 Jahren
Ursprung
Commit
40db25e83c

+ 7 - 1
gx_api/GxPress/Api/GxPress.Api/AdminControllers/AdminController.cs

@@ -123,7 +123,13 @@ namespace GxPress.Api.AdminControllers
         [HttpPost("page")]
         public async Task<PagedList<AdminPageResult>> GetPagedList([FromBody] AdminPageSearchRequest request)
         {
-            return await _adminRepository.GetPagedList(request);
+            var result = await _adminRepository.GetPagedList(request);
+            foreach (var item in result.Items)
+            {
+                //获取菜单
+                item.MenuInResult = await roleService.GetMenusAllAsync(item.RoleId);
+            }
+            return result;
         }
 
         /// <summary>

+ 13 - 0
gx_api/GxPress/Model/GxPress.Entity/Admin.cs

@@ -1,3 +1,4 @@
+using System;
 using Datory.Annotations;
 
 namespace GxPress.Entity
@@ -64,5 +65,17 @@ namespace GxPress.Entity
         /// <value></value>
         [DataColumn]
         public int RoleId { get; set; }
+        /// <summary>
+        /// 登陆ID
+        /// </summary>
+        /// <value></value>
+        [DataColumn]
+        public int Ip { get; set; }
+        /// <summary>
+        /// 登陆时间
+        /// </summary>
+        /// <value></value>
+        [DataColumn]
+        public DateTime LoginTime { get; set; }
     }
 }

+ 11 - 0
gx_api/GxPress/Model/GxPress.Request/Admin/AdminSignInRequest.cs

@@ -26,5 +26,16 @@ namespace GxPress.Request.Admin
         /// 验证码唯一标识
         /// </summary>
         public Guid Guid { get; set; }
+
+        /// <summary>
+        /// 登陆ID
+        /// </summary>
+        /// <value></value>
+        public int Ip { get; set; }
+        /// <summary>
+        /// 登陆时间
+        /// </summary>
+        /// <value></value>
+        public DateTime LoginTime { get; set; }
     }
 }

+ 13 - 0
gx_api/GxPress/Model/GxPress.Request/Admin/AdminSignUpRequest.cs

@@ -1,3 +1,5 @@
+using System;
+
 namespace GxPress.Request.Admin
 {
     /// <summary>
@@ -43,5 +45,16 @@ namespace GxPress.Request.Admin
         /// </summary>
         /// <value></value>
         public int RoleId { get; set; }
+
+         /// <summary>
+        /// 登陆ID
+        /// </summary>
+        /// <value></value>
+        public int Ip { get; set; }
+        /// <summary>
+        /// 登陆时间
+        /// </summary>
+        /// <value></value>
+        public DateTime LoginTime { get; set; }
     }
 }

+ 24 - 1
gx_api/GxPress/Model/GxPress.Result/Admin/AdminPageResult.cs

@@ -1,4 +1,6 @@
 using System;
+using System.Collections.Generic;
+using GxPress.Result.SystemRole;
 
 namespace GxPress.Result.Admin
 {
@@ -38,10 +40,31 @@ namespace GxPress.Result.Admin
         /// </summary>
 
         public string Sex { get; set; }
+        /// <summary>
+        /// 角色ID
+        /// </summary>
+        /// <value></value>
+        public int RoleId { get; set; }
 
         /// <summary>
         /// 创建时间
         /// </summary>
-        public DateTime ? CreatedDate { get; set; }
+        public DateTime? CreatedDate { get; set; }
+        /// <summary>
+        /// 菜单
+        /// </summary>
+        /// <value></value>
+        public List<MenuInResult> MenuInResult { get; set; }
+
+        /// <summary>
+        /// 登陆ID
+        /// </summary>
+        /// <value></value>
+        public int Ip { get; set; }
+        /// <summary>
+        /// 登陆时间
+        /// </summary>
+        /// <value></value>
+        public DateTime LoginTime { get; set; }
     }
 }

+ 5 - 1
gx_api/GxPress/Repository/GxPress.Repository.Implement/AdminRepository.cs

@@ -113,9 +113,12 @@ namespace GxPress.Repository.Implement
 
             var admin = await GetByAccountAsync(request.Account);
             if (admin == null) throw new BusinessException("不存在该账号");
-
             var pwd = EncryptProvider.Md5($"{request.Password}{request.Account}");
             if (admin.Password != pwd) throw new BusinessException("密码错误");
+            //修改IP
+            admin.Ip = request.Ip;
+            admin.LoginTime = DateTime.Now;
+            await _repository.UpdateAsync(admin);
             //新增获取菜单数据
             var result = new AdminSignInResult { AdminId = admin.Id, RoleId = admin.RoleId, Menus = StringUtils.StringCollectionToStringList(admin.Menus).ToList(), Name = admin.Name };
             return result;
@@ -171,6 +174,7 @@ namespace GxPress.Repository.Implement
             };
             var list = await GetPageListAsync(request.Page, request.PerPage);
             var items = list.Select(user => _mapper.Map<AdminPageResult>(user)).ToList();
+
             pagedList.Items = items;
             return pagedList;
         }