From 6aeb5a00847d6310670caa9d9af19a6baa6f08a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E4=BC=9F?= <421281095@qq.com> Date: Mon, 24 Feb 2025 10:47:37 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E8=B0=83=E6=95=B4=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=202.=20=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E7=BB=84=E4=BB=B6=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ServiceApp/GoView/GoViewProjectApp.cs | 43 ++++++++++++- .../GoView/Request/CustomComponentReq.cs | 8 +++ .../ServiceApp}/GoView/Request/MainPageReq.cs | 2 +- .../Domain/GoView/GoviewCustomComponent.cs | 20 ++++++ .../GoView/GoViewController.cs | 61 ++++++++++++++++++- 5 files changed, 131 insertions(+), 3 deletions(-) create mode 100644 OpenAuth.App/ServiceApp/GoView/Request/CustomComponentReq.cs rename {OpenAuth.Repository/Domain => OpenAuth.App/ServiceApp}/GoView/Request/MainPageReq.cs (54%) create mode 100644 OpenAuth.Repository/Domain/GoView/GoviewCustomComponent.cs diff --git a/OpenAuth.App/ServiceApp/GoView/GoViewProjectApp.cs b/OpenAuth.App/ServiceApp/GoView/GoViewProjectApp.cs index 4e799ec..0b15689 100644 --- a/OpenAuth.App/ServiceApp/GoView/GoViewProjectApp.cs +++ b/OpenAuth.App/ServiceApp/GoView/GoViewProjectApp.cs @@ -410,7 +410,7 @@ public class GoViewProjectApp : SqlSugarBaseApp public bool AddParam(string key, string mainPage) { - var result = new GoViewParam + var result = new GoViewParam { ParamName = key, ParamValue = mainPage, @@ -419,4 +419,45 @@ public class GoViewProjectApp : SqlSugarBaseApp return Repository.ChangeRepository>().InsertOrUpdate(result); } + + /// + /// 保存自定义组件 + /// + /// + /// + public async Task SaveCustomComponent(CustomComponentReq data) + { + // 保存 + var record = new GoviewCustomComponent + { + Id = Guid.NewGuid().ToString(), + Content = data.Content, + }; + return await Repository.ChangeRepository>().InsertAsync(record); + } + + + public async Task>>> GetCustomComponentList(PageReq req) + { + return new Response>> + { + Result = new PageInfo> + { + Items = await Repository.ChangeRepository>() + .AsQueryable() + .ToPageListAsync(req.page, req.limit), + Total = await Repository.ChangeRepository>() + .AsQueryable() + .CountAsync() + } + }; + } + + public async Task DeleteCustomComponent(string ids) + { + var idArray = ids.Split(","); + var result = await Repository.ChangeRepository>() + .DeleteByIdsAsync(idArray); + return result; + } } \ No newline at end of file diff --git a/OpenAuth.App/ServiceApp/GoView/Request/CustomComponentReq.cs b/OpenAuth.App/ServiceApp/GoView/Request/CustomComponentReq.cs new file mode 100644 index 0000000..4e6021e --- /dev/null +++ b/OpenAuth.App/ServiceApp/GoView/Request/CustomComponentReq.cs @@ -0,0 +1,8 @@ +using System.Text.Json.Nodes; + +namespace OpenAuth.App.ServiceApp.GoView.Request; + +public class CustomComponentReq +{ + public string Content { get; set; } +} \ No newline at end of file diff --git a/OpenAuth.Repository/Domain/GoView/Request/MainPageReq.cs b/OpenAuth.App/ServiceApp/GoView/Request/MainPageReq.cs similarity index 54% rename from OpenAuth.Repository/Domain/GoView/Request/MainPageReq.cs rename to OpenAuth.App/ServiceApp/GoView/Request/MainPageReq.cs index 8c9feef..238bd69 100644 --- a/OpenAuth.Repository/Domain/GoView/Request/MainPageReq.cs +++ b/OpenAuth.App/ServiceApp/GoView/Request/MainPageReq.cs @@ -1,4 +1,4 @@ -namespace OpenAuth.Repository.Domain.GoView.Request; +namespace OpenAuth.App.ServiceApp.GoView.Request; public class MainPageReq { diff --git a/OpenAuth.Repository/Domain/GoView/GoviewCustomComponent.cs b/OpenAuth.Repository/Domain/GoView/GoviewCustomComponent.cs new file mode 100644 index 0000000..63d9805 --- /dev/null +++ b/OpenAuth.Repository/Domain/GoView/GoviewCustomComponent.cs @@ -0,0 +1,20 @@ +using System.Text.Json.Nodes; +using SqlSugar; + +namespace OpenAuth.Repository.Domain.GoView; + +/// +/// 组件模型类 +/// +[SugarTable("t_goview_custom_component")] +public class GoviewCustomComponent +{ + [SugarColumn(IsPrimaryKey = true, ColumnName = "id")] + public string Id { get; set; } + + /// + /// 组件数据 + /// + [SugarColumn(ColumnName = "content")] + public string Content { get; set; } +} \ No newline at end of file diff --git a/OpenAuth.WebApi/Controllers/ServiceControllers/GoView/GoViewController.cs b/OpenAuth.WebApi/Controllers/ServiceControllers/GoView/GoViewController.cs index ab09085..61c22d3 100644 --- a/OpenAuth.WebApi/Controllers/ServiceControllers/GoView/GoViewController.cs +++ b/OpenAuth.WebApi/Controllers/ServiceControllers/GoView/GoViewController.cs @@ -1,11 +1,11 @@ using Infrastructure; using Microsoft.AspNetCore.Mvc; +using OpenAuth.App.BaseApp.Base; using OpenAuth.App.ServiceApp.GoView; using OpenAuth.App.ServiceApp.GoView.Request; using OpenAuth.App.ServiceApp.GoView.Response; using OpenAuth.Repository.Domain; using OpenAuth.Repository.Domain.GoView; -using OpenAuth.Repository.Domain.GoView.Request; namespace OpenAuth.WebApi.Controllers.ServiceControllers.GoView; @@ -253,4 +253,63 @@ public class GoViewProjectController : ControllerBase } return result; } + + /// + /// 自定义组件保存 + /// + /// + /// + [HttpPost("customComponent/save")] + public async Task> SaveCustomComponent(CustomComponentReq data) + { + var result = new Response(); + try + { + result.Result = await _app.SaveCustomComponent(data); + } + catch (Exception ex) + { + result.Code = 500; + result.Message = ex.Message; + } + return result; + } + /// + ///自定义组件列表 + /// + /// + /// + [HttpGet("customComponent/list")] + public async Task>>> GetCustomComponentList([FromQuery] PageReq req) + { + return await _app.GetCustomComponentList(req); + } + + /// + /// 删除自定义组件 + /// + /// + /// + [HttpPost("customComponent/delete")] + public async Task> DeleteCustomComponent(string ids) + { + + var result = new Response(); + if (string.IsNullOrEmpty(ids)) + { + result.Result = false; + result.Message = "参数不能为空"; + } + try + { + result.Result = await _app.DeleteCustomComponent(ids); + } + catch (Exception ex) + { + result.Code = 500; + result.Message = ex.Message; + } + return result; + } + } \ No newline at end of file