From 1cda9317f0b2164c54efedbc731a960bc1a48da7 Mon Sep 17 00:00:00 2001
From: schangxiang@126.com <schangxiang@126.com>
Date: 周二, 20 5月 2025 15:24:25 +0800
Subject: [PATCH] 111
---
Weben_CMS专用代码生成器/Code/Templete/AppService/AppService模板.txt | 289 +++++++++++++++++++++++++++++++++++----------------------
1 files changed, 179 insertions(+), 110 deletions(-)
diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/AppService/AppService\346\250\241\346\235\277.txt" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/AppService/AppService\346\250\241\346\235\277.txt"
index 271647a..789e804 100644
--- "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/AppService/AppService\346\250\241\346\235\277.txt"
+++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/AppService/AppService\346\250\241\346\235\277.txt"
@@ -1,47 +1,46 @@
-using CMS.Plugin.$NameSpacePath$.Application.Contracts.Dtos.$EntityName$;
+锘縰sing CMS.Plugin.$NameSpacePath$.Application.Contracts.Dtos.$EntityName$;
using CMS.Plugin.$NameSpacePath$.Application.Contracts.Services;
using CMS.Plugin.$NameSpacePath$.Domain.Shared;
-using CMS.Plugin.$NameSpacePath$.Domain.Shared.Util;
-using CMS.Plugin.$NameSpacePath$.Domain.Shared.$EntityName$;
using CMS.Plugin.$NameSpacePath$.Domain.$EntityName$;
+using CmsQueryExtensions;
+using CmsQueryExtensions.Entitys;
using CmsQueryExtensions.Extension;
using System.Linq.Expressions;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Data;
using Volo.Abp.ObjectExtending;
-using Volo.Abp.ObjectMapping;
namespace CMS.Plugin.$NameSpacePath$.Application.Implements;
/// <summary>
-/// $ChinaComment$应用服务
+/// $ChinaComment$搴旂敤鏈嶅姟
/// </summary>
public class $EntityName$AppService : CMSPluginAppService, I$EntityName$AppService
{
- private readonly I$EntityName$Repository $EntityInstanceName$Repository;
+ private readonly I$EntityName$Repository _$EntityInstanceName$Repository;
/// <summary>
/// Initializes a new instance of the <see cref="$EntityName$AppService"/> class.
/// </summary>
/// <param name="$EntityName$Repository">The task job repository.</param>
- public $EntityName$AppService(I$EntityName$Repository _$EntityName$Repository)
+ public $EntityName$AppService(I$EntityName$Repository $EntityInstanceName$Repository)
{
- $EntityInstanceName$Repository = _$EntityName$Repository;
+ _$EntityInstanceName$Repository = $EntityInstanceName$Repository;
}
/// <summary>
- /// 获取指定$ChinaComment$
+ /// 鑾峰彇鎸囧畾$ChinaComment$
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public virtual async Task<$EntityName$Dto> GetAsync(Guid id)
{
- return ObjectMapper.Map<$EntityName$, $EntityName$Dto>(await $EntityInstanceName$Repository.GetAsync(id));
+ return ObjectMapper.Map<$EntityName$, $EntityName$Dto>(await _$EntityInstanceName$Repository.GetAsync(id));
}
/// <summary>
- /// 分页获取$ChinaComment$
+ /// 鍒嗛〉鑾峰彇$ChinaComment$
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
@@ -54,36 +53,36 @@
input.Sorting = nameof($EntityName$.Sort);
}
- #region 动态构造查询条件
+ #region 鍔ㄦ�佹瀯閫犳煡璇㈡潯浠�
- //动态构造查询条件
+ //鍔ㄦ�佹瀯閫犳煡璇㈡潯浠�
var whereConditions = DynamicGetQueryParams(input);
#endregion
- var count = await $EntityInstanceName$Repository.GetCountAsync(whereConditions);
- var list = await $EntityInstanceName$Repository.GetListAsync(whereConditions, input.Sorting, input.MaxResultCount, input.SkipCount);
+ var count = await _$EntityInstanceName$Repository.GetCountAsync(whereConditions);
+ var list = await _$EntityInstanceName$Repository.GetListAsync(whereConditions, input.Sorting, input.MaxResultCount, input.SkipCount);
return new PagedResultDto<$EntityName$Dto>(count, ObjectMapper.Map<List<$EntityName$>, List<$EntityName$Dto>>(list));
}
/// <summary>
- /// 动态构造查询条件
+ /// 鍔ㄦ�佹瀯閫犳煡璇㈡潯浠�
/// </summary>
- /// <param name="input">输入参数</param>
+ /// <param name="input">杈撳叆鍙傛暟</param>
/// <returns></returns>
private FunReturnResultModel<Expression<Func<$EntityName$, bool>>> DynamicGetQueryParams(Get$EntityName$Input input)
{
- //动态构造查询条件
+ //鍔ㄦ�佹瀯閫犳煡璇㈡潯浠�
var whereConditions = WhereConditionsExtensions.GetWhereConditions<$EntityName$, Get$EntityName$Input>(input);
if (!whereConditions.IsSuccess)
{
- throw new Exception("动态构造查询条件失败:" + whereConditions.ErrMsg);
+ throw new Exception("鍔ㄦ�佹瀯閫犳煡璇㈡潯浠跺け璐�:" + whereConditions.ErrMsg);
}
- //也可再次自定义构建查询条件
+ //涔熷彲鍐嶆鑷畾涔夋瀯寤烘煡璇㈡潯浠�
Expression<Func<$EntityName$, bool>> extendExpression = a => a.IsDeleted == false;
- // 使用 System.Linq.PredicateBuilder 的 And
+ // 浣跨敤 System.Linq.PredicateBuilder 鐨� And
var pres = (System.Linq.Expressions.Expression<Func<$EntityName$, bool>>)(whereConditions.data);
whereConditions.data = System.Linq.PredicateBuilder.And(pres, extendExpression);
@@ -91,7 +90,7 @@
}
/// <summary>
- /// 新建$ChinaComment$
+ /// 鏂板缓$ChinaComment$
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
@@ -100,31 +99,32 @@
{
await CheckCreateOrUpdateDtoAsync(input);
- var exist = await $EntityInstanceName$Repository.NameExistAsync(input.MaterialCode);
+ var exist = await _$EntityInstanceName$Repository.NameExistAsync(input.$ValidateRepeatName$);
if (exist)
{
- throw new UserFriendlyException(L[CMSPluginDomainErrorCodes.NameAlreadyExists, input.MaterialCode]);
+ throw new UserFriendlyException(L[CMSPluginDomainErrorCodes.NameAlreadyExists, input.$ValidateRepeatName$]);
}
- var maxSort = await $EntityInstanceName$Repository.GetMaxSortAsync();
+ var maxSort = await _$EntityInstanceName$Repository.GetMaxSortAsync();
var sort = input.Sort ?? maxSort;
var insertObj = ObjectMapper.Map<$EntityName$CreateDto, $EntityName$>(input);
insertObj.Sort = sort;
input.MapExtraPropertiesTo(insertObj, MappingPropertyDefinitionChecks.None);
- await $EntityInstanceName$Repository.InsertAsync(insertObj);
+ insertObj.CreatorName = input.CreatorName;//鍒涘缓浜�
+ await _$EntityInstanceName$Repository.InsertAsync(insertObj);
- if (input.Sort.HasValue && insertObj.Sort != maxSort)
- {
- await AdjustSortAsync(insertObj.Id, insertObj.Sort);
- }
+ //if (input.Sort.HasValue && insertObj.Sort != maxSort)
+ //{
+ // await AdjustSortAsync(insertObj.Id, insertObj.Sort);
+ //}
return ObjectMapper.Map<$EntityName$, $EntityName$Dto>(insertObj);
}
/// <summary>
- /// 更新$ChinaComment$
+ /// 鏇存柊$ChinaComment$
/// </summary>
/// <param name="id"></param>
/// <param name="input"></param>
@@ -134,44 +134,47 @@
{
await CheckCreateOrUpdateDtoAsync(input);
- var updateObj = await $EntityInstanceName$Repository.GetAsync(id);
- var exist = await $EntityInstanceName$Repository.NameExistAsync(input.MaterialCode, updateObj.Id);
+ var updateObj = await _$EntityInstanceName$Repository.GetAsync(id);
+ var exist = await _$EntityInstanceName$Repository.NameExistAsync(input.$ValidateRepeatName$, updateObj.Id);
if (exist)
{
- throw new UserFriendlyException(L[CMSPluginDomainErrorCodes.NameAlreadyExists, input.MaterialCode]);
+ throw new UserFriendlyException(L[CMSPluginDomainErrorCodes.NameAlreadyExists, input.$ValidateRepeatName$]);
}
updateObj.SetConcurrencyStampIfNotNull(input.ConcurrencyStamp);
input.MapExtraPropertiesTo(updateObj, MappingPropertyDefinitionChecks.None);
- $UpdateAttributes$
+ // 鎵归噺璧嬪�兼墍鏈夊彲鏄犲皠瀛楁锛堥�氳繃鍖垮悕瀵硅薄锛�
+ updateObj = ObjectMapper.Map(input, updateObj); // 绛夋晥浜庢墜鍔ㄨ祴鍊兼墍鏈夊尮閰嶅瓧娈�
- await $EntityInstanceName$Repository.UpdateAsync(updateObj);
+ updateObj.LastModifierName = input.LastModifierName;//淇敼浜�
+
+ await _$EntityInstanceName$Repository.UpdateAsync(updateObj);
return ObjectMapper.Map<$EntityName$, $EntityName$Dto>(updateObj);
}
/// <summary>
- /// 克隆$ChinaComment$
+ /// 鍏嬮殕$ChinaComment$
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
- public async Task<List<$EntityName$Dto>> CloneAsync(IEnumerable<Guid> ids)
+ public async Task<List<$EntityName$Dto>> CloneAsync(IEnumerable<Guid> ids, MyCurrentUser myCurrentUser)
{
//var $EntityInstanceName$s = new List<$EntityName$>();
//if (ids != null)
//{
- // var sort = await $EntityInstanceName$Repository.GetMaxSortAsync();
+ // var sort = await _$EntityInstanceName$Repository.GetMaxSortAsync();
// foreach (var id in ids)
// {
- // var $EntityName$ = await $EntityInstanceName$Repository.FindAsync(id);
+ // var $EntityName$ = await _$EntityInstanceName$Repository.FindAsync(id);
// if ($EntityName$ != null)
// {
// var name = $EntityName$.Name + $EntityName$Consts.CloneTag;
// var notExist = false;
// while (!notExist)
// {
- // var exist = await $EntityInstanceName$Repository.NameExistAsync(name);
+ // var exist = await _$EntityInstanceName$Repository.NameExistAsync(name);
// if (exist || $EntityInstanceName$s.Any(x => x.Name == name))
// {
// name += $EntityName$Consts.CloneTag;
@@ -181,7 +184,7 @@
// notExist = true;
// }
- // //$EntityName$ = await $EntityInstanceName$Repository.InsertAsync($EntityName$.Clone(GuidGenerator.Create(), name, sort++));
+ // //$EntityName$ = await _$EntityInstanceName$Repository.InsertAsync($EntityName$.Clone(GuidGenerator.Create(), name, sort++));
// $EntityInstanceName$s.Add($EntityName$);
// }
// }
@@ -192,21 +195,21 @@
}
/// <summary>
- /// 删除单个$ChinaComment$
+ /// 鍒犻櫎鍗曚釜$ChinaComment$
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public virtual Task DeleteAsync(Guid id)
{
- return $EntityInstanceName$Repository.DeleteAsync(id);
+ return _$EntityInstanceName$Repository.DeleteAsync(id);
}
/// <summary>
- /// 删除多个$ChinaComment$
+ /// 鍒犻櫎澶氫釜$ChinaComment$
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
- public async Task DeleteManyAsync(IEnumerable<Guid> ids)
+ public async Task DeleteManyAsync(IEnumerable<Guid> ids, MyCurrentUser myCurrentUser)
{
foreach (var id in ids)
{
@@ -214,15 +217,37 @@
}
}
+ /// <summary>
+ /// 鐗╃悊鍒犻櫎$ChinaComment$
+ /// </summary>
+ /// <param name="id">涓婚敭ID</param>
+ /// <param name="cancellationToken"></param>
+ /// <returns></returns>
+ public virtual async Task DeletePermanentlyAsync(Guid id, MyCurrentUser myCurrentUser, CancellationToken cancellationToken = default)
+ {
+ _$EntityInstanceName$Repository.DeletePermanentlyAsync(id);
+ }
+
/// <summary>
- /// 调整排序$ChinaComment$
+ /// 鎵归噺鐗╃悊鍒犻櫎$ChinaComment$锛堢洿鎺ュ垹闄わ紝涓嶈蒋鍒犻櫎锛�
+ /// </summary>
+ /// <param name="ids">瑕佸垹闄ょ殑涓婚敭ID鍒楄〃</param>
+ /// <param name="cancellationToken"></param>
+ /// <returns></returns>
+ public virtual async Task BatchDeletePermanentlyAsync(IEnumerable<Guid> ids, MyCurrentUser myCurrentUser, CancellationToken cancellationToken = default)
+ {
+ _$EntityInstanceName$Repository.BatchDeletePermanentlyAsync(ids);
+ }
+
+ /// <summary>
+ /// 璋冩暣鎺掑簭$ChinaComment$
/// </summary>
/// <param name="id"></param>
/// <param name="sort"></param>
/// <returns></returns>
public virtual async Task AdjustSortAsync(Guid id, int sort)
{
- var list = await $EntityInstanceName$Repository.GetListAsync(null, nameof($EntityName$.Sort));
+ var list = await _$EntityInstanceName$Repository.GetListAsync(null, nameof($EntityName$.Sort));
if (list != null && list.Any())
{
var initSort = 1;
@@ -249,33 +274,33 @@
}
}
- await $EntityInstanceName$Repository.UpdateManyAsync(list);
+ await _$EntityInstanceName$Repository.UpdateManyAsync(list);
}
/// <summary>
- /// 导入$ChinaComment$
+ /// 瀵煎叆$ChinaComment$
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="UserFriendlyException"></exception>
- public async Task ImportAsync($EntityName$sImportModel input)
+ public async Task ImportAsync($EntityName$sImportModel input, MyCurrentUser myCurrentUser)
{
Check.NotNull(input, nameof(input));
var $EntityInstanceName$CreateDtos = new List<(int RowIndex, $EntityName$CreateDto Item)>();
- var $EntityInstanceName$UpdateDtos = new List<(int RowIndex, Guid Id, $EntityName$UpdateDto Item)>();
+ var $EntityInstanceName$UpdateDtos = new List<(int RowIndex, Guid Id, $EntityName$ Item)>();
var importItems = input.$EntityName$s;
if (importItems != null && importItems.Any())
{
- #region 导入校验
+ #region 瀵煎叆鏍¢獙
- // 判断名称是否重复,并输出第几行重复
- var duplicate$EntityName$s = importItems.GroupBy(x => x.MaterialCode).Where(x => x.Count() > 1).ToList();
+ // 鍒ゆ柇鍚嶇О鏄惁閲嶅锛屽苟杈撳嚭绗嚑琛岄噸澶�
+ var duplicate$EntityName$s = importItems.GroupBy(x => x.$ValidateRepeatName$).Where(x => x.Count() > 1).ToList();
if (duplicate$EntityName$s?.Any() == true)
{
- var duplicate$EntityName$Msgs = duplicate$EntityName$s.Select(x => $"第 {string.Join(",", x.Select(x => x.RowIndex))} 行:{x.Key} 名称重复");
- var errorMsg = $"导入失败!配置, {string.Join(",", duplicate$EntityName$Msgs)},终止导入";
+ var duplicate$EntityName$Msgs = duplicate$EntityName$s.Select(x => $"绗� {string.Join(",", x.Select(x => x.RowIndex))} 琛岋細{x.Key} 鍚嶇О閲嶅");
+ var errorMsg = $"瀵煎叆澶辫触锛侀厤缃紝 {string.Join(",", duplicate$EntityName$Msgs)}锛岀粓姝㈠鍏�";
throw new UserFriendlyException(errorMsg);
}
@@ -283,96 +308,65 @@
foreach (var impItem in importItems)
{
- if (impItem.MaterialCode.IsNullOrWhiteSpace() && impItem.MaterialName.IsNullOrWhiteSpace())
+ if (impItem.$ValidateRepeatName$.IsNullOrWhiteSpace())
{
continue;
}
- if (impItem.MaterialCode.IsNullOrWhiteSpace())
+ if (impItem.$ValidateRepeatName$.IsNullOrWhiteSpace())
{
- var errorMsg = $"导入失败!配置,第{impItem.RowIndex}行:$EntityName$名称不能为空";
+ var errorMsg = $"瀵煎叆澶辫触锛侀厤缃紝绗瑊impItem.RowIndex}琛岋細$EntityName$鍚嶇О涓嶈兘涓虹┖";
throw new UserFriendlyException(errorMsg);
}
- var old$EntityName$ = await $EntityInstanceName$Repository.FindByNameAsync(impItem.MaterialCode);
+ var old$EntityName$ = await _$EntityInstanceName$Repository.FindByNameAsync(impItem.$ValidateRepeatName$);
if (old$EntityName$ != null)
{
- var $EntityInstanceName$UpdateDto = new $EntityName$UpdateDto
- {
- MaterialCode = impItem.MaterialCode,
- MaterialName = impItem.MaterialName,
- PurchaseType = impItem.PurchaseType,
- MaterialType = impItem.MaterialType,
- PrimaryUnit = impItem.PrimaryUnit,
- Standard = impItem.Standard,
- OuterDiameter = impItem.OuterDiameter,
- WallThickness = impItem.WallThickness,
- MaterialQuality = impItem.MaterialQuality,
- Length = impItem.Length,
- IsMainBranch = impItem.IsMainBranch,
- Factory = impItem.Factory,
- Certification = impItem.Certification,
- Remark = impItem.Remark,
- };
-
- $EntityInstanceName$UpdateDtos.Add((impItem.RowIndex, old$EntityName$.Id, $EntityInstanceName$UpdateDto));
+ old$EntityName$ = ObjectMapper.Map(impItem, old$EntityName$); // 绛夋晥浜庢墜鍔ㄨ祴鍊兼墍鏈夊尮閰嶅瓧娈�
+ $EntityInstanceName$UpdateDtos.Add((impItem.RowIndex, old$EntityName$.Id, old$EntityName$));
}
else
{
- var $EntityInstanceName$CreateDto = new $EntityName$CreateDto
- {
- MaterialCode = impItem.MaterialCode,
- MaterialName = impItem.MaterialName,
- PurchaseType = impItem.PurchaseType,
- MaterialType = impItem.MaterialType,
- PrimaryUnit = impItem.PrimaryUnit,
- Standard = impItem.Standard,
- OuterDiameter = impItem.OuterDiameter,
- WallThickness = impItem.WallThickness,
- MaterialQuality = impItem.MaterialQuality,
- Length = impItem.Length,
- IsMainBranch = impItem.IsMainBranch,
- Factory = impItem.Factory,
- Certification = impItem.Certification,
- Remark = impItem.Remark,
- };
-
+ var $EntityInstanceName$CreateDto = new $EntityName$CreateDto { };
+ $EntityInstanceName$CreateDto = ObjectMapper.Map(impItem, $EntityInstanceName$CreateDto); // 绛夋晥浜庢墜鍔ㄨ祴鍊兼墍鏈夊尮閰嶅瓧娈�
$EntityInstanceName$CreateDtos.Add((impItem.RowIndex, $EntityInstanceName$CreateDto));
}
}
}
- // 新增
+ // 鏂板
foreach (var $EntityInstanceName$Dto in $EntityInstanceName$CreateDtos)
{
try
{
+ $EntityInstanceName$Dto.Item.CreatorName = myCurrentUser.UserAccount;//鍒涘缓浜�
await CreateAsync($EntityInstanceName$Dto.Item);
}
catch (Exception e)
{
- var errorMsg = $"导入失败!配置,第{$EntityInstanceName$Dto.RowIndex}行:{e.Message},终止导入";
+ var errorMsg = $"瀵煎叆澶辫触锛侀厤缃紝绗瑊$EntityInstanceName$Dto.RowIndex}琛岋細{e.Message}锛岀粓姝㈠鍏�";
throw new UserFriendlyException(errorMsg);
}
}
- // 更新
+ // 鏇存柊
foreach (var $EntityInstanceName$Dto in $EntityInstanceName$UpdateDtos)
{
try
{
- await UpdateAsync($EntityInstanceName$Dto.Id, $EntityInstanceName$Dto.Item);
+ $EntityInstanceName$Dto.Item.LastModifierName = myCurrentUser.UserAccount;//淇敼浜�
+ await _$EntityInstanceName$Repository.UpdateAsync($EntityInstanceName$Dto.Item);
}
catch (Exception e)
{
- var errorMsg = $"导入失败!配置,第{$EntityInstanceName$Dto.RowIndex}行:{e.Message},终止导入";
+ var errorMsg = $"瀵煎叆澶辫触锛侀厤缃紝绗瑊$EntityInstanceName$Dto.RowIndex}琛岋細{e.Message}锛岀粓姝㈠鍏�";
throw new UserFriendlyException(errorMsg);
}
}
}
/// <summary>
- /// 导出$ChinaComment$
+ /// 瀵煎嚭$ChinaComment$
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
@@ -385,28 +379,28 @@
input.Sorting = nameof($EntityName$.Sort);
}
- #region 动态构造查询条件
+ #region 鍔ㄦ�佹瀯閫犳煡璇㈡潯浠�
- //动态构造查询条件
+ //鍔ㄦ�佹瀯閫犳煡璇㈡潯浠�
var whereConditions = DynamicGetQueryParams(input);
#endregion
- var list = await $EntityInstanceName$Repository.GetListAsync(whereConditions, input.Sorting, input.MaxResultCount, input.SkipCount, includeDetails: true);
+ var list = await _$EntityInstanceName$Repository.GetListAsync(whereConditions, input.Sorting, input.MaxResultCount, input.SkipCount, includeDetails: true);
var result = ObjectMapper.Map<List<$EntityName$>, List<$EntityName$Dto>>(list);
var sheets = new Dictionary<string, object>
{
- ["配置"] = ExportHelper.ConvertListToExportData(result),
+ ["閰嶇疆"] = ExportHelper.ConvertListToExportData(result),
};
- var fileName = result.Count > 1 ? "$EntityName$列表" : result.Count == 1 ? result[0]?.MaterialCode : "$EntityName$模版";
+ var fileName = "$PageMenuName$";
return (sheets, fileName);
}
/// <summary>
- /// 校验$ChinaComment$,当新建或更新时
+ /// 鏍¢獙$ChinaComment$锛屽綋鏂板缓鎴栨洿鏂版椂
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
@@ -416,4 +410,79 @@
$UpdateAttributesForCheckCreateOrUpdateDtoAsync$
return Task.CompletedTask;
}
+
+ /// <summary>
+ /// 鏍规嵁鏉′欢鑾峰彇$ChinaComment$鍒楄〃
+ /// </summary>
+ /// <param name="whereConditions"></param>
+ /// <param name="cancellationToken"></param>
+ /// <returns></returns>
+ public async Task<List<$EntityName$>> GetListByFilterAsync(Expression<Func<$EntityName$, bool>> whereConditions, CancellationToken cancellationToken = default)
+ {
+ return await _$EntityInstanceName$Repository.GetListByFilterAsync(whereConditions);
+ }
+
+ /// <summary>
+ /// 鏍规嵁鏉′欢鑾峰彇鍗曚釜$ChinaComment$
+ /// </summary>
+ /// <param name="whereConditions"></param>
+ /// <param name="isMultipleThrowException">鏄惁鏌ヨ鍑哄鏉″氨鎶ラ敊</param>
+ /// <param name="cancellationToken"></param>
+ /// <returns></returns>
+ /// <exception cref="UserFriendlyException"></exception>
+ public async Task<$EntityName$> GetSingleByFilterAsync(Expression<Func<$EntityName$, bool>> whereConditions, bool is鈥婱ultipleThrowException = false, CancellationToken cancellationToken = default)
+ {
+ return await _$EntityInstanceName$Repository.GetSingleByFilterAsync(whereConditions, is鈥婱ultipleThrowException);
+ }
+
+ /// <summary>
+ /// 鏍规嵁鏉′欢鑾峰彇$ChinaComment$鍒楄〃
+ /// </summary>
+ /// <param name="input"></param>
+ /// <returns></returns>
+ public virtual async Task<List<$EntityName$Dto>> FindListByFilterAsync(Get$EntityName$Input input, CancellationToken cancellationToken = default)
+ {
+ Check.NotNull(input, nameof(input));
+
+ if (input.Sorting.IsNullOrWhiteSpace())
+ {
+ input.Sorting = nameof($EntityName$.Sort);
+ }
+
+ #region 鍔ㄦ�佹瀯閫犳煡璇㈡潯浠�
+
+ //鍔ㄦ�佹瀯閫犳煡璇㈡潯浠�
+ var whereConditions = DynamicGetQueryParams(input);
+
+ #endregion
+
+ var list = await _$EntityInstanceName$Repository.GetListByFilterAsync(whereConditions?.data);
+
+ return new List<$EntityName$Dto>(ObjectMapper.Map<List<$EntityName$>, List<$EntityName$Dto>>(list));
+ }
+ /// <summary>
+ /// 鏍规嵁鏉′欢鑾峰彇鍗曚釜$ChinaComment$
+ /// </summary>
+ /// <param name="input"></param>
+ /// <returns></returns>
+ public virtual async Task<$EntityName$Dto> FindSingleByFilterAsync(Get$EntityName$Input input, CancellationToken cancellationToken = default)
+ {
+ Check.NotNull(input, nameof(input));
+
+ if (input.Sorting.IsNullOrWhiteSpace())
+ {
+ input.Sorting = nameof($EntityName$.Sort);
+ }
+
+ #region 鍔ㄦ�佹瀯閫犳煡璇㈡潯浠�
+
+ //鍔ㄦ�佹瀯閫犳煡璇㈡潯浠�
+ var whereConditions = DynamicGetQueryParams(input);
+
+ #endregion
+
+ var dataObj = await _$EntityInstanceName$Repository.GetSingleByFilterAsync(whereConditions?.data);
+
+ return (ObjectMapper.Map<$EntityName$, $EntityName$Dto>(dataObj));
+ }
}
--
Gitblit v1.9.3