From 94ec9557fa424c704d95787dc78c494a7b69520d Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Mon, 23 Sep 2024 17:35:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8F=82=E6=95=B0=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Ghre/Ghre_ConfigController.cs | 10 +++++++++ .../Ghre/Ghre_RequestController.cs | 2 ++ Tiobon.Core.Api/Tiobon.Core.xml | 6 ++++++ .../Ghre/IGhre_ConfigServices.cs | 2 ++ .../Ghre/Ghre_ConfigServices.cs | 21 ++++++++++++++++--- .../Ghre/Ghre_RequestServices.cs | 6 +++++- Tiobon.Core/Tiobon.Core.xml | 6 ++++++ 7 files changed, 49 insertions(+), 4 deletions(-) diff --git a/Tiobon.Core.Api/Controllers/Ghre/Ghre_ConfigController.cs b/Tiobon.Core.Api/Controllers/Ghre/Ghre_ConfigController.cs index 8a5b290d..cf634c57 100644 --- a/Tiobon.Core.Api/Controllers/Ghre/Ghre_ConfigController.cs +++ b/Tiobon.Core.Api/Controllers/Ghre/Ghre_ConfigController.cs @@ -11,4 +11,14 @@ public class Ghre_ConfigController : BaseController + /// 批量更新数据 + /// + /// + [HttpPost, Route("BulkUpdateValue")] + public virtual async Task BulkUpdateValue([FromBody] List entitys) + { + return await _service.BulkUpdateValue(entitys); + } } \ No newline at end of file diff --git a/Tiobon.Core.Api/Controllers/Ghre/Ghre_RequestController.cs b/Tiobon.Core.Api/Controllers/Ghre/Ghre_RequestController.cs index 3ebf116d..5d8d8c25 100644 --- a/Tiobon.Core.Api/Controllers/Ghre/Ghre_RequestController.cs +++ b/Tiobon.Core.Api/Controllers/Ghre/Ghre_RequestController.cs @@ -26,6 +26,8 @@ public class Ghre_RequestController : BaseController + + + 批量更新数据 + + + Ghre_CourseClass(Controller) diff --git a/Tiobon.Core.IServices/Ghre/IGhre_ConfigServices.cs b/Tiobon.Core.IServices/Ghre/IGhre_ConfigServices.cs index 93930bce..8592d2fc 100644 --- a/Tiobon.Core.IServices/Ghre/IGhre_ConfigServices.cs +++ b/Tiobon.Core.IServices/Ghre/IGhre_ConfigServices.cs @@ -1,4 +1,5 @@ using Tiobon.Core.IServices.BASE; +using Tiobon.Core.Model; using Tiobon.Core.Model.Models; namespace Tiobon.Core.IServices @@ -8,5 +9,6 @@ namespace Tiobon.Core.IServices /// public interface IGhre_ConfigServices :IBaseServices { + Task BulkUpdateValue(List entitys); } } \ No newline at end of file diff --git a/Tiobon.Core.Services/Ghre/Ghre_ConfigServices.cs b/Tiobon.Core.Services/Ghre/Ghre_ConfigServices.cs index e8f8411b..94a19480 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_ConfigServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_ConfigServices.cs @@ -4,12 +4,13 @@ using Tiobon.Core.Model.Models; using Tiobon.Core.Services.BASE; using Tiobon.Core.IRepository.Base; using Tiobon.Core.Common.Caches; +using Tiobon.Core.Model; namespace Tiobon.Core.Services { - /// - /// 参数配置 (服务) - /// + /// + /// 参数配置 (服务) + /// public class Ghre_ConfigServices : BaseServices, IGhre_ConfigServices { private readonly IBaseRepository _dal; @@ -19,5 +20,19 @@ namespace Tiobon.Core.Services base.BaseDal = dal; base._caching = caching; } + + public async Task BulkUpdateValue(List entitys) + { + for (int i = 0; i < entitys.Count; i++) + { + await Db.Updateable() + .SetColumns(it => new Ghre_Config() + { + ConfigValue = entitys[i].ConfigValue + }) + .Where(x => x.Id == entitys[i].Id).ExecuteCommandAsync(); + } + return ServiceResult.OprateSuccess(); + } } } \ No newline at end of file diff --git a/Tiobon.Core.Services/Ghre/Ghre_RequestServices.cs b/Tiobon.Core.Services/Ghre/Ghre_RequestServices.cs index c0da2c4d..71956f71 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_RequestServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_RequestServices.cs @@ -32,7 +32,11 @@ public class Ghre_RequestServices : BaseServices> QueryFilterPage(QueryBody filter, string condition, bool? IsEnable = true) { - var sql = "update A set A.CourseName= B.CourseName FROM Ghre_Request A join Ghre_Course B on A.CourseId = B.Id and A.CourseName != B.CourseName"; + var sql = @"UPDATE A +SET A.CourseName = B.CourseName +FROM Ghre_Request A + JOIN Ghre_Course B + ON A.CourseId = B.Id AND (A.CourseName ! = B.CourseName OR A.CourseName IS NULL)"; await Db.Ado.ExecuteCommandAsync(sql); var result = await base.QueryFilterPage(filter, condition, IsEnable); diff --git a/Tiobon.Core/Tiobon.Core.xml b/Tiobon.Core/Tiobon.Core.xml index dbe355f5..ab37f7bd 100644 --- a/Tiobon.Core/Tiobon.Core.xml +++ b/Tiobon.Core/Tiobon.Core.xml @@ -649,6 +649,12 @@ 参数配置(Controller) + + + 批量更新数据 + + + Ghre_CourseClass(Controller)