Browse Source

Merge branch 'feature/task_245_rest' into dev

qinchaoyue 2 months ago
parent
commit
517b3caad7

+ 11 - 2
src/Hotline.Api/Controllers/CallController.cs

@@ -128,8 +128,17 @@ namespace Hotline.Api.Controllers
         /// <param name="dto"></param>
         /// <returns></returns>
         [HttpGet("calls-fixed")]
-        public Task<IReadOnlyList<CallNativeDto>> QueryCallsFixed([FromQuery] QueryCallsFixedDto dto)
-            => _callApplication.QueryCallsFixedAsync(dto, HttpContext.RequestAborted);
+        public async Task<List<CallNativeDto>> QueryCallsFixed([FromQuery] QueryCallsFixedDto dto)
+            => await _callApplication.QueryCallsFixedAsync(dto, HttpContext.RequestAborted).ToPageListWithoutTotalAsync(dto, HttpContext.RequestAborted);
+
+        /// <summary>
+        /// 查询通话记录(固定数据量)
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpGet("calls-fixed/count")]
+        public async Task<int> QueryCallsFixedCount([FromQuery] QueryCallsFixedDto dto)
+            => await _callApplication.QueryCallsFixedAsync(dto, HttpContext.RequestAborted).CountAsync(HttpContext.RequestAborted);
 
         /// <summary>
         /// 查询通话记录

+ 6 - 8
src/Hotline.Application/CallCenter/DefaultCallApplication.cs

@@ -236,7 +236,7 @@ public abstract class DefaultCallApplication : ICallApplication
     /// <summary>
     /// 定量查询通话记录
     /// </summary>
-    public virtual async Task<IReadOnlyList<CallNativeDto>> QueryCallsFixedAsync(QueryCallsFixedDto dto, CancellationToken cancellationToken)
+    public virtual ISugarQueryable<CallNativeDto> QueryCallsFixedAsync(QueryCallsFixedDto dto, CancellationToken cancellationToken)
     {
         var query = _callNativeRepository.Queryable(includeDeleted: true)
             .LeftJoin<Order>((d, o) => d.Id == o.CallId)
@@ -265,7 +265,7 @@ public abstract class DefaultCallApplication : ICallApplication
 
         if (dto.Type == 2)
         {
-            var items = await query.Select((d, o, v) => new CallNativeDto
+            return query.Select((d, o, v) => new CallNativeDto
             {
                 OrderId = v.OrderId,
                 OrderNo = v.Order.No,
@@ -273,11 +273,9 @@ public abstract class DefaultCallApplication : ICallApplication
                 CallState = d.CallState,
                 IsVisit = !SqlFunc.IsNullOrEmpty(v.Id),
                 IsOrder = !SqlFunc.IsNullOrEmpty(o.Id),
-            }, true)
-                .ToFixedListAsync(dto, cancellationToken);
-            return items;
+            }, true);
         }
-        return await query.Select((d, o, v) => new CallNativeDto
+        return query.Select((d, o, v) => new CallNativeDto
         {
             OrderId = o.Id,
             OrderNo = o.No,
@@ -285,8 +283,8 @@ public abstract class DefaultCallApplication : ICallApplication
             Title = o.Title,
             IsVisit = !SqlFunc.IsNullOrEmpty(v.Id),
             IsOrder = !SqlFunc.IsNullOrEmpty(o.Id),
-        }, true)
-        .ToFixedListAsync(dto, cancellationToken);
+        }, true);
+
     }
 
     /// <summary>

+ 1 - 1
src/Hotline.Application/CallCenter/ICallApplication.cs

@@ -67,7 +67,7 @@ namespace Hotline.Application.CallCenter
         /// <summary>
         /// 定量查询通话记录
         /// </summary>
-        Task<IReadOnlyList<CallNativeDto>> QueryCallsFixedAsync(QueryCallsFixedDto dto, CancellationToken cancellationToken);
+        ISugarQueryable<CallNativeDto> QueryCallsFixedAsync(QueryCallsFixedDto dto, CancellationToken cancellationToken);
 
         /// <summary>
         /// 查询分机操作记录(定量)

+ 2 - 1
src/Hotline.Share/Dtos/CallCenter/QueryCallsFixedDto.cs

@@ -4,11 +4,12 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using Hotline.Share.Enums.CallCenter;
+using Hotline.Share.Requests;
 using Hotline.Share.Tools;
 
 namespace Hotline.Share.Dtos.CallCenter
 {
-    public class QueryCallsFixedDto : QueryFixedDto
+    public record QueryCallsFixedDto : PagedRequest
     {
         public string? OrderNo { get; set; }
 

+ 0 - 9
src/Hotline/CallCenter/Tels/CallTelDomain/QueryTelRequest.cs

@@ -34,20 +34,11 @@ public class QueryBlacklistRequest
 }
 public class QueryBlacklistResponse
 {
-    [JsonPropertyName("uuid")]
     public string Id { get; set; }
-
-    [JsonPropertyName("user_uuid")]
     public string UserId { get; set; }
-
-    [JsonPropertyName("created_at")]
     public string CreationTime { get; set; }
-
     public string Phone { get; set; }
-
-    [JsonPropertyName("special_flag")]
     public int SpecialFlag { get; set; }
-
     public int? Priority { get; set; }
 }
 

+ 0 - 11
src/Hotline/CallCenter/Tels/CallTelDomain/QueryTelResponse.cs

@@ -9,29 +9,18 @@ using System.Threading.Tasks;
 namespace Hotline.CallCenter.Tels.CallTelDomain;
 public class QueryTelResponse
 {
-    [JsonPropertyName("uuid")]
     public string Id { get; set; }
     public string Name { get; set; }
-    [JsonPropertyName("nbr")]
     public string TelNo { get; set; }
     public string Description { get; set; }
-
     public string Password { get; set; }
-
-    [JsonPropertyName("queue_id")]
     public string QueueId { get; set; }
-
 }
 
 public class QueryTelStateResponse
 {
-    [JsonPropertyName("count")]
     public string Count { get; set; }
-
-    [JsonPropertyName("agents")]
     public List<Agent>? AgentList { get; set; }
-
-    [JsonPropertyName("agent")]
     public List<Agent>? Agents { get; set; }
 }
 

+ 1 - 1
src/Tr.Sdk/CallTelClient.cs

@@ -30,7 +30,7 @@ public class CallTelClient : ICallTelClient
     public async Task<List<QueryBlacklistResponse>> QueryBlacklistAsync(QueryBlacklistRequest request, CancellationToken token)
     {
         var result = await _trClient.QueryBlacklistAsync(request.Adapt<Blacklist.QueryBlacklistRequest>(), token);
-        return request.Adapt<List<QueryBlacklistResponse>>();
+        return result.Adapt<List<QueryBlacklistResponse>>();
     }
 
     public async Task<List<QueryTelResponse>> QueryTelsAsync(QueryTelRequest request, CancellationToken cancellationToken)