From 45f81cf83530a8d636630b86dd1d966ec7c5012e Mon Sep 17 00:00:00 2001 From: wanghaomei Date: Thu, 17 Nov 2022 17:03:04 +0800 Subject: [PATCH] =?UTF-8?q?EDI=E5=8F=82=E6=95=B0=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Myshipping.Core/Myshipping.Core.xml | 11 +++--- .../DjyEdiSetting/DjyEdiSettingService.cs | 34 ++++++++++++------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/Myshipping.Core/Myshipping.Core.xml b/Myshipping.Core/Myshipping.Core.xml index 2a339c2f..e5a691df 100644 --- a/Myshipping.Core/Myshipping.Core.xml +++ b/Myshipping.Core/Myshipping.Core.xml @@ -692,6 +692,11 @@ EDI映射 + + + 系统配置 + + 程序集 @@ -7912,12 +7917,10 @@ - + 更新配置缓存 - - @@ -9295,7 +9298,7 @@ - 增加EDI参数设置(同一租户、同一代码的会更新) + 增加EDI参数设置 diff --git a/Myshipping.Core/Service/DjyEdiSetting/DjyEdiSettingService.cs b/Myshipping.Core/Service/DjyEdiSetting/DjyEdiSettingService.cs index 6c9c4e82..dcdb658e 100644 --- a/Myshipping.Core/Service/DjyEdiSetting/DjyEdiSettingService.cs +++ b/Myshipping.Core/Service/DjyEdiSetting/DjyEdiSettingService.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Furion.Logging; using Microsoft.Extensions.Logging; using Myshipping.Core.Entity; +using Furion.FriendlyException; namespace Myshipping.Core.Service { @@ -69,25 +70,21 @@ namespace Myshipping.Core.Service } /// - /// 增加EDI参数设置(同一租户、同一代码的会更新) + /// 增加EDI参数设置 /// /// /// [HttpPost("/DjyEdiSetting/add")] public async Task Add(AddDjyEdiSettingInput input) { - _rep.Context.QueryFilter.Clear(); - var entity = _rep.FirstOrDefault(x => x.EDICODE == input.EDICODE && x.TenantId == input.TenantId); - if (entity == null) - { - entity = input.Adapt(); - await _rep.InsertAsync(entity); - } - else + var cc = _rep.Count(x => x.EDICODE == input.EDICODE && x.TenantId == input.TenantId); + if (cc > 0) { - entity = input.Adapt(entity); - await _rep.UpdateAsync(entity); + throw Oops.Bah($"该租户({input.TenantName})已存在相同类型({input.EDICODE})的参数设置"); } + + var entity = input.Adapt(); + await _rep.InsertAsync(entity); await CacheData(); } @@ -99,8 +96,15 @@ namespace Myshipping.Core.Service [HttpPost("/DjyEdiSetting/edit")] public async Task Update(UpdateDjyEdiSettingInput input) { - var entity = input.Adapt(); - await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); + var entity = _rep.FirstOrDefault(x => x.EDICODE == input.EDICODE && x.TenantId == input.TenantId); + if (entity == null) + { + throw Oops.Bah($"未找到数据"); + } + + entity = input.Adapt(entity); + await _rep.UpdateAsync(entity); + await CacheData(); } @@ -113,6 +117,10 @@ namespace Myshipping.Core.Service public async Task Delete(GetDjyEdiSettingInput input) { var entity = await _rep.FirstOrDefaultAsync(u => u.Id == input.Id); + if (entity == null) + { + throw Oops.Bah($"未找到数据"); + } await _rep.DeleteAsync(entity); await CacheData(); }