lcl 9 maanden geleden
bovenliggende
commit
3efe6ec880

+ 10 - 6
Controllers/Base/SysUserController.cs

@@ -13,6 +13,7 @@ using Middleware;
 using MiniExcelLibs;
 using Model;
 using Model.Base;
+using Model.Kxs;
 using Services;
 using Util;
 using Vo;
@@ -60,19 +61,22 @@ namespace Controllers
 
         [AllowAnonymous]
         [HttpGet("/feign/user/test")]
-        public async Task<SysUserVo> Test([FromQuery] long id)
+        public SysUserVo Test([FromQuery] long id)
         {
-            var info = UserService.GetFirst(m => m.userId == id).Adapt<SysUserVo>();
-            var dept = await SysDept.GetDeptInfo(info.deptId);
-            info.deptInfo = dept;
+            var info = UserService.Queryable()
+                .Includes(m => m.deptJoin)
+                .CrossQuery(typeof(Users), "kxs")
+                .Includes(m => m.user)
+                .First(m => m.userId == id)
+                .Adapt<SysUserVo>() ?? new SysUserVo();
             return info;
         }
 
         [AllowAnonymous]
         [HttpGet("/feign/user/testlist")]
-        public async Task<PagedInfo<SysUserVo>> TestList()
+        public PagedInfo<SysUserVo> TestList()
         {
-            var response = await UserService.TestList(SysDept);
+            var response = UserService.TestList(SysDept);
             return response;
         }
 

+ 21 - 0
Model/Base/SysUser.cs

@@ -1,4 +1,7 @@
+using Mapster;
 using MiniExcelLibs.Attributes;
+using Model.Kxs;
+using Vo;
 
 namespace Model
 {
@@ -179,6 +182,24 @@ namespace Model
         [SugarColumn(IsIgnore = true)]
         public List<SysPost> PostList { get; set; }
 
+        [SugarColumn(IsIgnore = true)]
+        public DeptFeignVo deptInfo 
+        { 
+            get
+            {
+                return deptJoin.Adapt<DeptFeignVo>();
+            }
+        }
+
+        [SugarColumn(IsIgnore = true)]
+        [Navigate(NavigateType.OneToOne, nameof(deptId))]
+        public SysDept deptJoin { get; set; }
+
+        
+        [SugarColumn(IsIgnore = true)]
+        [Navigate(NavigateType.OneToOne, nameof(deptId))]
+        public Users user { get; set; }
+
 
         public bool IsAdmin()
         {

+ 28 - 0
Model/Database/Kxs/Users.cs

@@ -0,0 +1,28 @@
+using Mapster;
+using MiniExcelLibs.Attributes;
+using Vo;
+
+namespace Model.Kxs
+{
+    /// <summary>
+    /// 用户表 sys_user
+    /// </summary>
+    [SugarTable("Users", "创客")]
+    [Tenant("kxs")]
+    public class Users
+    {
+        /// <summary>
+        /// 用户ID
+        /// </summary>
+        [SugarColumn(ColumnDescription = "ID", IsPrimaryKey = true, IsIdentity = true, ColumnName = "Id")]
+        public int id { get; set; }
+
+
+        [SugarColumn(ColumnDescription = "创客编号", ColumnName = "MakerCode")]
+        public string makerCode { get; set; }
+
+
+        [SugarColumn(ColumnDescription = "创客姓名", ColumnName = "RealName")]
+        public string realName { get; set; }
+    }
+}

+ 3 - 0
Model/Vo/Base/SysUserVo.cs

@@ -1,3 +1,5 @@
+using Model.Kxs;
+
 namespace Vo
 {
     public class SysUserVo
@@ -6,5 +8,6 @@ namespace Vo
         public long deptId { get; set; }
         public string username { get; set; }
         public DeptFeignVo deptInfo { get; set; }
+        public Users user { get; set; }
     }
 }

+ 1 - 1
Services/Base/IService/ISysUserService.cs

@@ -85,6 +85,6 @@ namespace Services
         void UpdateLoginInfo(string userIP, long userId);
 
 
-        Task<PagedInfo<SysUserVo>> TestList(SysDeptFeign SysDept);
+        PagedInfo<SysUserVo> TestList(SysDeptFeign SysDept);
     }
 }

+ 6 - 6
Services/Base/SysUserService.cs

@@ -8,6 +8,7 @@ using Infrastructure;
 using IPTools.Core;
 using Model;
 using Model.Base;
+using Model.Kxs;
 using Repository;
 using Service;
 using System.Collections;
@@ -330,19 +331,18 @@ namespace Services
         {
         }
 
-        public async Task<PagedInfo<SysUserVo>> TestList(SysDeptFeign SysDept)
+        public PagedInfo<SysUserVo> TestList(SysDeptFeign SysDept)
         {
             //开始拼装查询条件
             var predicate = Expressionable.Create<SysUser>();
             var response = Queryable()
                 .Where(predicate.ToExpression())
+                .Select(m => m)
                 .OrderByDescending(m => m.userId)
+                .Includes(m => m.deptJoin)
+                .CrossQuery(typeof(Users), "kxs")
+                .Includes(m => m.user)
                 .ToPage<SysUser, SysUserVo>(new PagerInfo());
-            foreach(SysUserVo sub in response.Records)
-            {
-                var dept = await SysDept.GetDeptInfo(sub.deptId);
-                sub.deptInfo = dept;
-            }
             return response;
         }
     }

+ 6 - 0
appsettings.Development.json

@@ -18,6 +18,12 @@
       "DbType": 0,
       "ConfigId": "0",
       "IsAutoCloseConnection": true
+    },
+    {
+      "Conn": "server=47.108.62.166;port=3306;user=root;password=HDlNs1ZpG5iR9D9I;database=KxsMainServer;charset=utf8;",
+      "DbType": 0,
+      "ConfigId": "kxs",
+      "IsAutoCloseConnection": true
     }
   ],
   "RedisServer": {