From 1d7c17e2537c6cd538e3d2c6c8f6783c32447538 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A9=99=E5=AD=90?= <454313500@qq.com> Date: Sun, 5 Feb 2023 22:59:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0crud?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/CrudAppService.cs | 9 +++-- .../module/Yi.Framework.Template/Program.cs | 1 - .../rbac/Yi.RBAC.Application/TestService.cs | 34 +++++++++++++++++++ 3 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Application/TestService.cs diff --git a/Yi.Framework.Net6/src/framework/Yi.Framework.Ddd/Services/CrudAppService.cs b/Yi.Framework.Net6/src/framework/Yi.Framework.Ddd/Services/CrudAppService.cs index fe707eb7..e7a1a7a1 100644 --- a/Yi.Framework.Net6/src/framework/Yi.Framework.Ddd/Services/CrudAppService.cs +++ b/Yi.Framework.Net6/src/framework/Yi.Framework.Ddd/Services/CrudAppService.cs @@ -158,13 +158,12 @@ namespace Yi.Framework.Ddd.Services { throw new ArgumentNullException(nameof(id)); } - var entity = await MapToEntityAsync(input); - entity.Id = id; - await _repository.UpdateIgnoreNullAsync(entity); - var newEntity = await _repository.GetByIdAsync(id); + var entity = await _repository.GetByIdAsync(id); + await MapToEntityAsync(input, entity); + await _repository.UpdateAsync(entity); - return await MapToGetOutputDtoAsync(newEntity); + return await MapToGetOutputDtoAsync(entity); } } } diff --git a/Yi.Framework.Net6/src/module/Yi.Framework.Template/Program.cs b/Yi.Framework.Net6/src/module/Yi.Framework.Template/Program.cs index 71621f35..3c9c72c6 100644 --- a/Yi.Framework.Net6/src/module/Yi.Framework.Template/Program.cs +++ b/Yi.Framework.Net6/src/module/Yi.Framework.Template/Program.cs @@ -19,7 +19,6 @@ TemplateFactory templateFactory = new(); //List entityNames = new() { "_" }; string modelName = "Dictionary"; string nameSpaces = "Yi.RBAC"; -List entityNames = new() { "_" }; List entityNames = new() { "_", "_" }; diff --git a/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Application/TestService.cs b/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Application/TestService.cs new file mode 100644 index 00000000..5eff6736 --- /dev/null +++ b/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Application/TestService.cs @@ -0,0 +1,34 @@ +using NET.AutoWebApi.Setting; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Ddd.Services; + +namespace Yi.RBAC.Application +{ + class Test01 + { + + public string Name { get; set; } + public bool State { get; set; } + } + + class Test02 + { + public string Name { get; set; } + } + + public class TestService : ApplicationService, IAutoApiService + { + + public void Test() + { + var t001 = new Test02 { Name = "121233" }; + var t002 = new Test01 { Name = "123", State = true }; + + var entity= _mapper.Map(t001, t002); + } + } +}