| | |
| | | using CMS.Plugin.$NameSpacePath$.Application.Contracts.Dtos.$EntityName$; |
| | | using CMS.Plugin.$NameSpacePath$.Application.Contracts.Dtos.$EntityName$; |
| | | using CMS.Plugin.$NameSpacePath$.Application.Contracts.Services; |
| | | using CMS.Plugin.$NameSpacePath$.Domain.Shared; |
| | | using CmsQueryExtensions; |
| | | 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> |
| | |
| | | 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); |
| | | |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ°å»º$ChinaComment$ |
| | | /// æ°å»º$ChinaComment$ |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | |
| | | { |
| | | await CheckCreateOrUpdateDtoAsync(input); |
| | | |
| | | var exist = await $EntityInstanceName$Repository.NameExistAsync(input.$ValidateRepeatName$); |
| | | var exist = await _$EntityInstanceName$Repository.NameExistAsync(input.$ValidateRepeatName$); |
| | | if (exist) |
| | | { |
| | | 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) |
| | | //{ |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ´æ°$ChinaComment$ |
| | | /// æ´æ°$ChinaComment$ |
| | | /// </summary> |
| | | /// <param name="id"></param> |
| | | /// <param name="input"></param> |
| | |
| | | { |
| | | await CheckCreateOrUpdateDtoAsync(input); |
| | | |
| | | var updateObj = await $EntityInstanceName$Repository.GetAsync(id); |
| | | var exist = await $EntityInstanceName$Repository.NameExistAsync(input.$ValidateRepeatName$, 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.$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; |
| | |
| | | // 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$); |
| | | // } |
| | | // } |
| | |
| | | } |
| | | |
| | | /// <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) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | /// <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; |
| | |
| | | } |
| | | } |
| | | |
| | | 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.$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); |
| | | } |
| | | |
| | |
| | | |
| | | 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.$ValidateRepeatName$); |
| | | var old$EntityName$ = await _$EntityInstanceName$Repository.FindByNameAsync(impItem.$ValidateRepeatName$); |
| | | if (old$EntityName$ != null) |
| | | { |
| | | var $EntityInstanceName$UpdateDto = new $EntityName$UpdateDto |
| | | { |
| | | $AppService_ImportAsync$ |
| | | }; |
| | | |
| | | $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 |
| | | { |
| | | $AppService_ImportAsync$ |
| | | }; |
| | | |
| | | 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> |
| | |
| | | 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 = "$PageMenuName$"; |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ ¡éª$ChinaComment$ï¼å½æ°å»ºææ´æ°æ¶ |
| | | /// æ ¡éª$ChinaComment$ï¼å½æ°å»ºææ´æ°æ¶ |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | |
| | | $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âMultipleThrowException = false, CancellationToken cancellationToken = default) |
| | | { |
| | | return await _$EntityInstanceName$Repository.GetSingleByFilterAsync(whereConditions, isâMultipleThrowException); |
| | | } |
| | | |
| | | /// <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)); |
| | | } |
| | | } |