Browse Source

specialists-tree

xf 2 months ago
parent
commit
4667c96894

+ 9 - 1
src/Hotline.Api/Controllers/EnterprisesController.cs

@@ -98,11 +98,19 @@ namespace Hotline.Api.Controllers
         /// </summary>
         /// <returns></returns>
         [HttpGet("specialists-tree")]
-        public Task<List<EnterpriseSpecialist>> QuerySpecialists()
+        public Task<List<EnterpriseSpecialistDto>> QuerySpecialists()
         {
             return _enterpriseSpecialistRepository.Queryable()
                 .Includes(d => d.User, s => s.Account)
                 .OrderBy(d => d.Id)
+                .Select(d=>new EnterpriseSpecialistDto
+                {
+                    Id = d.Id,
+                    ParentId = d.ParentId,
+                    Name = d.User.Name,
+                    UserName = d.User.Account.UserName,
+                    PhoneNo = d.User.PhoneNo,
+                })
                 .ToTreeAsync(d => d.Children, it => it.ParentId, null);
         }
 

+ 10 - 0
src/Hotline.Share/Dtos/Enterprise/EnterpriseSpecialistDto.cs

@@ -0,0 +1,10 @@
+using Hotline.Share.Dtos.Users;
+
+namespace Hotline.Share.Dtos.Enterprise;
+
+public record EnterpriseSpecialistDto : UserDto
+{
+    public string? ParentId { get; set; }
+    
+    public List<EnterpriseSpecialistDto> Children { get; set; }
+}