From 3ec65a96dd073e598e58c12fb0b5af31e38bc20e Mon Sep 17 00:00:00 2001
From: zs <zhousong@weben-smart.com>
Date: 周三, 14 5月 2025 14:48:51 +0800
Subject: [PATCH] Merge branch 'master' of http://222.71.245.114:9086/r/HIA24016N_PipeLineDemo

---
 PipeLineLems/server/src/CMS.Plugin.PipeLineLems.EntityFrameworkCore/Repositories/EfCoreWorkPlanRepository.cs |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 52 insertions(+), 0 deletions(-)

diff --git a/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.EntityFrameworkCore/Repositories/EfCoreWorkPlanRepository.cs b/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.EntityFrameworkCore/Repositories/EfCoreWorkPlanRepository.cs
index caade5e..bc81213 100644
--- a/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.EntityFrameworkCore/Repositories/EfCoreWorkPlanRepository.cs
+++ b/PipeLineLems/server/src/CMS.Plugin.PipeLineLems.EntityFrameworkCore/Repositories/EfCoreWorkPlanRepository.cs
@@ -4,6 +4,7 @@
 using Microsoft.EntityFrameworkCore;
 using System.Linq.Dynamic.Core;
 using System.Linq.Expressions;
+using Volo.Abp;
 using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
 using Volo.Abp.EntityFrameworkCore;
 
@@ -127,4 +128,55 @@
         return (await GetQueryableAsync())
             .Where(x => !x.IsDeleted).IncludeDetails();
     }
+
+    /// <summary> 
+    /// 鏍规嵁鏉′欢鑾峰彇浣滀笟璁″垝琛ㄥ垪琛� 
+    /// </summary> 
+    /// <param name="whereConditions"></param> 
+    /// <param name="cancellationToken"></param> 
+    /// <returns></returns> 
+    public async Task<List<WorkPlan>> GetListByFilterAsync(Expression<Func<WorkPlan, 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<WorkPlan> GetSingleByFilterAsync(Expression<Func<WorkPlan, 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