From 98ea0648f9373679de108ccbab5dcc97c2f0c67c Mon Sep 17 00:00:00 2001
From: zs <zhousong@weben-smart.com>
Date: 周五, 16 5月 2025 13:00:17 +0800
Subject: [PATCH] 叫料接口
---
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