dss hace 2 años
padre
commit
2ede409b53

+ 1 - 1
src/CallCenter.Application/Handlers/FlowControl/ByeVisitorAndExtNotificationHandler.cs

@@ -52,7 +52,7 @@ namespace CallCenter.Application.Handlers
                 _callCacheManager.RemoveCallCache(model.Id);
 
                 //查询应答分机分机号
-                var callDetailAnswer = await _callDetailRepository.GetAsync(x => x.CallId == model.Id && x.EventName == "ANSWER");
+                var callDetailAnswer = await _callDetailRepository.GetAsync(x => x.CallId == model.Id && x.EventName == "ANSWER", true, d => d.CreationTime);
                 if (callDetailAnswer != null)
                 {
                     //调用业务通知 通知前端

+ 13 - 0
src/CallCenter.Repository.SqlSugar/BaseRepository.cs

@@ -104,6 +104,19 @@ namespace CallCenter.Repository.SqlSugar
             return await Db.Queryable<TEntity>().FirstAsync(predicate);
         }
 
+        public async Task<TEntity?> GetAsync(Expression<Func<TEntity, bool>> predicate,bool isDesc, Expression<Func<TEntity, object>> orderby, CancellationToken cancellationToken = default)
+        {
+            if (isDesc)
+            {
+                return await Db.Queryable<TEntity>().OrderBy(orderby, OrderByType.Desc).FirstAsync(predicate);
+            }
+            else
+            {
+                return await Db.Queryable<TEntity>().OrderBy(orderby,OrderByType.Asc).FirstAsync(predicate);
+            }
+        }
+
+
         public async Task<List<TEntity>> QueryAsync(Expression<Func<TEntity, bool>>? predicate = null, params (bool isWhere, Expression<Func<TEntity, bool>> expression)[] whereIfs)
         {
             var query = Db.Queryable<TEntity>().Where(predicate ??= d => true);

+ 2 - 0
src/XF.Domain.Repository/IRepositoryWithTKey.cs

@@ -24,6 +24,8 @@ namespace XF.Domain.Repository
         Task<TEntity?> GetAsync(TKey id, CancellationToken cancellationToken = default);
         Task<TEntity?> GetAsync(Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken = default);
 
+        Task<TEntity?> GetAsync(Expression<Func<TEntity, bool>> predicate,bool isDesc, Expression<Func<TEntity, object>> orderBy, CancellationToken cancellationToken = default);
+
         Task<List<TEntity>> QueryAsync(
             Expression<Func<TEntity, bool>>? predicate = null,
             params (bool isWhere, Expression<Func<TEntity, bool>> expression)[] whereIfs);