Selaa lähdekoodia

新增UserInfo,UserRepository,GetUserList
新增ResponseEntities 接受多表联查文件夹

leiy 2 vuotta sitten
vanhempi
commit
237e046d6b

+ 5 - 5
OASystem/OASystem.Api/Controllers/AuthController.cs

@@ -45,7 +45,7 @@ namespace OASystem.API.Controllers
             var userData = _loginRep.Login(_loginRep, dto);
             if (userData.Result.Code != 0)
             {
-                if (userData.Result.Code != 0) { return Ok(JsonView(false, userData.Result.Message)); }
+                if (userData.Result.Code != 0) { return Ok(JsonView(false, userData.Result.Msg)); }
 
                 return Ok(JsonView(false, "暂无该员工信息!"));
             }
@@ -98,12 +98,12 @@ namespace OASystem.API.Controllers
             var userData = _loginRep.Register(_loginRep, dto);
             if (userData.Result.Code != 0)
             {
-                if (userData.Result.Code != 0) { return Ok(JsonView(false, userData.Result.Message)); }
+                if (userData.Result.Code != 0) { return Ok(JsonView(false, userData.Result.Msg)); }
 
                 return Ok(JsonView(false, "注册失败!"));
             }
 
-            return Ok(new { Code = 0, Msg = userData.Result.Message });
+            return Ok(new { Code = 0, Msg = userData.Result.Msg });
         }
 
         /// <summary>
@@ -123,12 +123,12 @@ namespace OASystem.API.Controllers
             if (_UpdateState)
             {
                 result.Code = 0;
-                result.Message = "申请成功!人事主管审核后且信息部经理分配了登录账号,可登录OA!";
+                result.Msg = "申请成功!人事主管审核后且信息部经理分配了登录账号,可登录OA!";
             }
             else
             {
                 result.Code = -2;
-                result.Message = "用户修改失败!";
+                result.Msg = "用户修改失败!";
             }
 
 

+ 25 - 4
OASystem/OASystem.Api/Controllers/SystemController.cs

@@ -2,7 +2,9 @@
 using MySqlX.XDevAPI.Common;
 using OASystem.Domain.Dtos;
 using OASystem.Domain.Entities.System;
+using OASystem.Domain.ResponseEntities.System;
 using OASystem.Domain.ViewModels.System;
+using OASystem.Infrastructure.Repositories.Login;
 using OASystem.Infrastructure.Repositories.System;
 
 namespace OASystem.API.Controllers
@@ -10,19 +12,38 @@ namespace OASystem.API.Controllers
     /// <summary>
     /// 系统设置
     /// </summary>
-    [Route("[controller]/[action]")]
+    [Route("api/[controller]/[action]")]
     public class SystemController : ControllerBase
     {
-        readonly Sys_DepartmentRepository _sysDepRep;
-        readonly IMapper _mapper;
+        private readonly Sys_DepartmentRepository _sysDepRep;
+        private readonly UsersRepository _userRep;
+        private readonly IMapper _mapper;
 
-        public SystemController(Sys_DepartmentRepository sysDepRep, IMapper mapper)
+        public SystemController(Sys_DepartmentRepository sysDepRep, IMapper mapper, UsersRepository userRep)
         {
             _sysDepRep = sysDepRep;
+            _userRep = userRep;
             _mapper = mapper;
         }
 
+        #region user 操作
 
+        [Authorize]
+        [HttpGet]
+        [ProducesResponseType(typeof(LoginView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> GetUserList()
+        {
+           var userList = _userRep.GetUserList(_userRep);
+            
+            if (userList.Result.Code != 0)
+            {
+                return Ok(JsonView(false, userList.Result.Msg));
+            }
+            
+            return Ok(JsonView(userList.Result.Data));
+        }
+
+        #endregion
         //[Authorize]
         [HttpPost]
         [ProducesResponseType(typeof(LoginView), StatusCodes.Status200OK)]

+ 32 - 0
OASystem/OASystem.Domain/ResponseEntities/System/UserInfo.cs

@@ -0,0 +1,32 @@
+using OASystem.Domain.Entities.System;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.ResponseEntities.System
+{
+    /// <summary>
+    /// 用户表
+    /// 数据库查询接受实体类
+    /// </summary>
+    public class UserInfo: Sys_Users
+    {
+        /// <summary>
+        /// 公司名称
+        /// </summary>
+        public string? CompanyName { get; set; }
+
+        /// <summary>
+        /// 部门名称
+        /// </summary>
+        public string? DepName { get; set; }
+
+        /// <summary>
+        /// 岗位名称
+        /// </summary>
+        public string? JobName { get; set; }
+
+    }
+}

+ 1 - 1
OASystem/OASystem.Domain/Result.cs

@@ -9,7 +9,7 @@ namespace OASystem.Domain
     public class Result
     {
         public int Code { get; set; } = -1;
-        public string Message { get; set; } = "未知错误";
+        public string Msg { get; set; } = "未知错误";
         public dynamic Data { get; set; } = null;
     }
 }

+ 4 - 4
OASystem/OASystem.Infrastructure/Repositories/Login/LoginRepository.cs

@@ -27,12 +27,12 @@ namespace OASystem.Infrastructure.Repositories.Login
             if (_entity == null)
             {
                 result.Code = -2;
-                result.Message = "暂无该账号信息!";
+                result.Msg = "暂无该账号信息!";
 
                 return result;
             }
             result.Code = 0;
-            result.Message = "登录成功!";
+            result.Msg = "登录成功!";
             result.Data = _entity;
             return result;
 
@@ -86,12 +86,12 @@ namespace OASystem.Infrastructure.Repositories.Login
             if (_AddId < 0)
             {
                 result.Code = -2;
-                result.Message = "用户添加失败!";
+                result.Msg = "用户添加失败!";
 
                 return result;
             }
             result.Code = 0;
-            result.Message = "申请成功!人事主管审核后且信息部经理分配了登录账号,可登录OA!";
+            result.Msg = "申请成功!人事主管审核后且信息部经理分配了登录账号,可登录OA!";
             return result;
         }
 

+ 69 - 0
OASystem/OASystem.Infrastructure/Repositories/System/UsersRepository.cs

@@ -0,0 +1,69 @@
+using OASystem.Domain;
+using OASystem.Domain.Dtos.UserDto;
+using OASystem.Domain.Entities.System;
+using OASystem.Domain.ResponseEntities.System;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Infrastructure.Repositories.System
+{
+    public class UsersRepository : BaseRepository<UserInfo, JsonView>
+    {
+        public UsersRepository(SqlSugarClient sqlSugar) : base(sqlSugar)
+        {
+        }
+
+        /// <summary>
+        /// 用户查询列表
+        /// </summary>
+        /// <param name="_userRep"></param>
+        /// <returns></returns>
+        public async Task<Result> GetUserList(UsersRepository _userRep)
+        {
+            Result result = new Result();
+            string userSqlWhere = string.Format(@"Select sjp.JobName,sd.DepName,sc.CompanyName,su.* From Sys_Users su 
+                                                  Inner Join Sys_Company sc On su.CompanyId = sc.Id
+                                                  Inner Join Sys_Department sd On su.DepId = sd.Id
+                                                  Inner Join Sys_JobPost sjp On su.JobPostId = sjp.Id ");
+            List<UserInfo> _userList = await _userRep.GetListBySqlWithNolockAsync(userSqlWhere);
+            if (_userList.Count < 1)
+            {
+                result.Code = -2;
+                result.Msg = "暂无员工信息!";
+
+                return result;
+            }
+
+            List<dynamic> reultUserList = new List<dynamic>();
+            foreach (UserInfo user in _userList)
+            {
+                var data = new
+                {
+                    Number = user.Number,
+                    UserId = user.Id,
+                    CnName = user.CnName,
+                    CompanyId = user.CompanyId,
+                    CompanyName = user.CompanyName,
+                    DepId = user.DepId,
+                    DepName = user.DepName,
+                    //JobPostId = user.JobPostId,
+                    //JobName = user.JobName,
+                    Ext = user.Ext,
+                    Phone = user.Phone,
+                    UrgentPhone = user.UrgentPhone,
+                    Email = user.Email
+                };
+                reultUserList.Add(data);
+            }
+
+            result.Code = 0;
+            result.Msg = "成功!";
+            result.Data = reultUserList;
+            return result;
+
+        }
+    }
+}