admin vor 1 Jahr
Ursprung
Commit
8258dfa4f1

+ 64 - 5
src/Hotline.Api/Controllers/PbxController.cs

@@ -1003,8 +1003,7 @@ namespace Hotline.Api.Controllers
         /// </summary>
         /// <param name="dto"></param>
         /// <returns></returns>
-        //[Permission(EPermission.QueryTels)]
-        [AllowAnonymous]
+        [Permission(EPermission.QueryTels)]
         [HttpGet("query-tel-list")]
         public async Task<PagedDto<TelListPageDto>> QueryTelList([FromQuery]QueryTelListDto dto)
         {
@@ -1016,18 +1015,78 @@ namespace Hotline.Api.Controllers
                 var telGroup = _wexTelGroupRepository.Queryable().ToList();
 
                 var list = (from a in telList
-                            join b in telGroup on a.TelNo equals b.TelNo
+                            join b in telGroup on a.TelNo equals b.TelNo into output
+                            from j in output.DefaultIfEmpty()
                             select new TelListPageDto
                             {
-                                Id = b.Id,
+                                Id = (j==null ? "": j.Id),
                                 TelNo = a.TelNo,
-                                GroupName = b.GroupName
+                                GroupName = (j==null ? "": j.GroupName)
                             }).ToList();
                 return new PagedDto<TelListPageDto>(count, list);
             }
             return new PagedDto<TelListPageDto>(0, null);
         }
 
+        /// <summary>
+        /// 新增分机关联分机组
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [AllowAnonymous]
+        [Permission(EPermission.AddTelGroup)]
+        [HttpGet("add-wextelgroup")]
+        public async Task AddWexTelGroup([FromBody]AddWexTelGroupDto dto)
+        {
+            var telGroup = new WexTelGroup();
+            telGroup.TelNo = dto.TelNo;
+            telGroup.GroupId = dto.GroupId;
+            telGroup.GroupName = dto.GroupName;
+            telGroup.ZuoGroupName = dto.ZuoGroupName;
+            await _wexTelGroupRepository.AddAsync(telGroup, HttpContext.RequestAborted);
+        }
+
+        /// <summary>
+        /// 修改分机关联分机组
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [Permission(EPermission.UpdateTelGroup)]
+        [HttpGet("update-wextelgroup")]
+        public async Task UpdateWexTelGroup([FromBody]UpdateWexTelGroupDto dto)
+        {
+            var telGroup =await _wexTelGroupRepository.GetAsync(dto.Id, HttpContext.RequestAborted);
+            if (telGroup is null)
+            {
+                throw UserFriendlyException.SameMessage("未找到对应数据,无法修改");
+            }
+            if (dto.GroupId == 0)
+            {
+                await _wexTelGroupRepository.RemoveAsync(dto.Id, false, HttpContext.RequestAborted);
+            }
+            else
+            {
+                telGroup.GroupId = dto.GroupId;
+                telGroup.GroupName = dto.GroupName;
+                telGroup.ZuoGroupName = dto.ZuoGroupName;
+                await _wexTelGroupRepository.UpdateAsync(telGroup);
+            }
+        }
+
+        /// <summary>
+        /// 分机组列表
+        /// </summary>
+        /// <returns></returns>
+        [Permission(EPermission.QueryTelGroups)]
+        [HttpGet("telgroup-list")]
+        public async Task<List<WexTelGroupDto>> TelGroupList()
+        {
+            var rsp = await _wexClient.QueryGroupAsync(new QueryGroupRequest() { }, HttpContext.RequestAborted);
+            var groupList = rsp.Data;
+            var list = _mapper.Map<List<WexTelGroupDto>>(groupList);
+            return list;
+        }
+
         #endregion
     }
 }

+ 14 - 0
src/Hotline.Repository.SqlSugar/CallCenter/WexTelGroupRepository.cs

@@ -0,0 +1,14 @@
+using Hotline.CallCenter.Tels;
+using Hotline.Repository.SqlSugar.DataPermissions;
+using SqlSugar;
+using XF.Domain.Dependency;
+
+namespace Hotline.Repository.SqlSugar.CallCenter
+{
+    public class WexTelGroupRepository : BaseRepository<WexTelGroup>, IWexTelGroupRepository, IScopeDependency
+    {
+        public WexTelGroupRepository(ISugarUnitOfWork<HotlineDbContext> uow, IDataPermissionFilterBuilder dataPermissionFilterBuilder) : base(uow, dataPermissionFilterBuilder)
+        {
+        }
+    }
+}

+ 38 - 0
src/Hotline.Share/Dtos/CallCenter/TelGroupDto.cs

@@ -1,4 +1,5 @@
 using Hotline.Share.Enums.CallCenter;
+using Hotline.Share.Requests;
 using XF.Utility.EnumExtensions;
 
 namespace Hotline.Share.Dtos.CallCenter
@@ -52,4 +53,41 @@ namespace Hotline.Share.Dtos.CallCenter
     {
         public string Id { get; set; }
     }
+
+    public record class QueryTelListDto : PagedRequest
+    {
+
+    }
+
+    public record class TelListPageDto
+    {
+        public string Id { get; set; }
+        public string TelNo { get; set; }
+        public string GroupName { get; set; }
+        public int GroupId { get; set; }
+        public string ZuoGroupName { get; set; }
+    }
+
+
+    public record AddWexTelGroupDto
+    {
+        public string TelNo { get; set; }
+        public int GroupId { get; set; }
+        public string GroupName { get; set; }
+        public string ZuoGroupName { get; set; }
+    }
+
+    public record UpdateWexTelGroupDto:AddWexTelGroupDto
+    {
+        public string Id { get; set; }
+    }
+
+    public record WexTelGroupDto
+    {
+        public int GroupId { get; set; }
+
+        public string GroupName { get; set; }
+
+        public string ZuoGroupName { get; set; }
+    }
 }

+ 0 - 13
src/Hotline.Share/Dtos/Trunk/TrunkDto.cs

@@ -35,17 +35,4 @@ namespace Hotline.Share.Dtos.Trunk
         public string Id { get; set; }
     }
 
-    public record class QueryTelListDto:PagedRequest
-    {
-
-    }
-
-    public record class TelListPageDto
-    {
-        public string Id { get; set; }
-
-        public string TelNo { get; set; }
-
-        public string GroupName { get; set; }
-    }
 }

+ 1 - 1
src/Hotline/CallCenter/Tels/WexTelGroup.cs

@@ -12,7 +12,7 @@ namespace Hotline.CallCenter.Tels
         /// <summary>
         /// 分机组ID
         /// </summary>
-        public string GroupId { get; set; }
+        public int GroupId { get; set; }
 
         /// <summary>
         /// 分机组名称