From 252edd99e9094bc8cd1c08be71e6f93e49dfce94 Mon Sep 17 00:00:00 2001
From: schangxiang@126.com <schangxiang@126.com>
Date: 周五, 16 5月 2025 11:05:05 +0800
Subject: [PATCH] 2222

---
 PipeLineLems/server/src/CMS.Plugin.PipeLineLems.EntityFrameworkCore/Repositories/EfCoreCallMaterialOrderRepository.cs |   56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 54 insertions(+), 2 deletions(-)

diff --git a/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.EntityFrameworkCore/Repositories/EfCoreCallMaterialOrderRepository.cs b/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.EntityFrameworkCore/Repositories/EfCoreCallMaterialOrderRepository.cs
index 0a78686..da7e88a 100644
--- a/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.EntityFrameworkCore/Repositories/EfCoreCallMaterialOrderRepository.cs
+++ b/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.EntityFrameworkCore/Repositories/EfCoreCallMaterialOrderRepository.cs
@@ -3,7 +3,8 @@
 using CmsQueryExtensions.Extension; 
 using Microsoft.EntityFrameworkCore; 
 using System.Linq.Dynamic.Core; 
-using System.Linq.Expressions; 
+using System.Linq.Expressions;
+using Volo.Abp;
 using Volo.Abp.Domain.Repositories.EntityFrameworkCore; 
 using Volo.Abp.EntityFrameworkCore; 
  
@@ -118,5 +119,56 @@
     { 
         return (await GetQueryableAsync()) 
             .Where(x => !x.IsDeleted).IncludeDetails(); 
-    } 
+    }
+
+    /// <summary> 
+    /// 鏍规嵁鏉′欢鑾峰彇鍙枡鍗曡〃鍒楄〃 
+    /// </summary> 
+    /// <param name="whereConditions"></param> 
+    /// <param name="cancellationToken"></param> 
+    /// <returns></returns> 
+    public async Task<List<CallMaterialOrder>> GetListByFilterAsync(Expression<Func<CallMaterialOrder, bool>> whereConditions, CancellationToken cancellationToken = default)
+    {
+        return await (await GetDbSetAsync())
+            .IncludeDetails()
+            .WhereIf(whereConditions != null, whereConditions)
+            .Where(x => !x.IsDeleted)
+            .OrderByDescending(x => x.CreationTime)
+            .ToListAsync(GetCancellationToken(cancellationToken));
+    }
+
+    /// <summary> 
+    ///  鏍规嵁鏉′欢鑾峰彇鍗曚釜鍙枡鍗曡〃 
+    /// </summary> 
+    /// <param name="whereConditions"></param> 
+    /// <param name="isMultipleThrowException">鏄惁鏌ヨ鍑哄鏉″氨鎶ラ敊</param> 
+    /// <param name="cancellationToken"></param> 
+    /// <returns></returns> 
+    /// <exception cref="UserFriendlyException"></exception> 
+    public async Task<CallMaterialOrder> GetSingleByFilterAsync(Expression<Func<CallMaterialOrder, bool>> whereConditions, bool is鈥婱ultipleThrowException = false, CancellationToken cancellationToken = default)
+    {
+        if (is鈥婱ultipleThrowException)
+        {
+            var entitys = await (await GetDbSetAsync())
+                .IncludeDetails()
+                .WhereIf(whereConditions != null, whereConditions)
+                .Where(x => !x.IsDeleted)
+                .OrderByDescending(x => x.CreationTime)
+                .ToListAsync(GetCancellationToken(cancellationToken));
+            if (entitys?.Count > 1)
+            {
+                throw new UserFriendlyException("鏌ヨ鍒板鏉¤褰�");
+            }
+            return entitys?.FirstOrDefault();
+        }
+        else
+        {
+            return await (await GetDbSetAsync())
+                .IncludeDetails()
+                .WhereIf(whereConditions != null, whereConditions)
+                .Where(x => !x.IsDeleted)
+                .OrderByDescending(x => x.CreationTime)
+                .FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
+        }
+    }
 } 

--
Gitblit v1.9.3