zs
2025-06-04 5a149d626ae8bc3fa4bddbb53f8caf40f51f6da6
Weben_CMSרÓôúÂëÉú³ÉÆ÷/Code/Templete/AppService/AppServiceÄ£°å.txt
@@ -1,16 +1,15 @@
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;
using CmsQueryExtensions.Entitys;
namespace CMS.Plugin.$NameSpacePath$.Application.Implements;
@@ -145,7 +144,8 @@
        updateObj.SetConcurrencyStampIfNotNull(input.ConcurrencyStamp);
        input.MapExtraPropertiesTo(updateObj, MappingPropertyDefinitionChecks.None);
        $UpdateAttributes$
        // æ‰¹é‡èµ‹å€¼æ‰€æœ‰å¯æ˜ å°„字段(通过匿名对象)
        updateObj = ObjectMapper.Map(input, updateObj); // ç­‰æ•ˆäºŽæ‰‹åŠ¨èµ‹å€¼æ‰€æœ‰åŒ¹é…å­—æ®µ
        updateObj.LastModifierName = input.LastModifierName;//修改人
@@ -288,7 +288,7 @@
        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())
@@ -322,20 +322,13 @@
                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));
                }
            }
@@ -362,7 +355,7 @@
            try
            {
                $EntityInstanceName$Dto.Item.LastModifierName = myCurrentUser.UserAccount;//修改人
                await UpdateAsync($EntityInstanceName$Dto.Id, $EntityInstanceName$Dto.Item);
                await _$EntityInstanceName$Repository.UpdateAsync($EntityInstanceName$Dto.Item);
            }
            catch (Exception e)
            {
@@ -441,4 +434,55 @@
    {
        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));
    }
}