diff --git a/OpenAuth.App/ServiceApp/GoView/GoViewProjectApp.cs b/OpenAuth.App/ServiceApp/GoView/GoViewProjectApp.cs index 4496ef4..bc8cb67 100644 --- a/OpenAuth.App/ServiceApp/GoView/GoViewProjectApp.cs +++ b/OpenAuth.App/ServiceApp/GoView/GoViewProjectApp.cs @@ -151,6 +151,88 @@ public class GoViewProjectApp : SqlSugarBaseApp return new Response { Code = 200, Result = flag, Message = flag ? "数据保存成功" : "数据保存失败" }; } + #region 组件数据 + /// + /// 获取组件集合 + /// + /// + /// + public async Task>>> GetComponentList(GoViewProjectPage page) + { + RefAsync total = 0; + var list = await Repository.ChangeRepository>().AsQueryable() + .WhereIF(!string.IsNullOrEmpty(page.key),r=>r.ComponentName.Contains(page.key)) + .ToPageListAsync(page.page, page.limit, total); + return new Response>>() + { + Result = new PageInfo> + { + Items = list, + Total = total + } + }; + } + /// + /// 获取组件数据 + /// + /// + /// + public async Task> GetComponentData(string componentId) + { + var data = await Repository.ChangeRepository>().AsQueryable() + .SingleAsync(a => a.Id == componentId); + + return new Response() + { + Result = data + }; + } + /// + /// 保存组件数据 + /// + /// + /// + /// + public async Task> SaveComponentData(GoviewComponent data) + { + // 更新还是保存, + var comData = await Repository + .ChangeRepository>() + .AsQueryable() + .SingleAsync(a => a.Id == data.Id); + bool flag; + if (comData == null) + { + data.Id = Guid.NewGuid().ToString(); + data.CreateUserId = _auth.GetUserId(); + data.CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + flag = await Repository.ChangeRepository>().InsertAsync(data); + } + else + { + data.Id = comData.Id; + flag = await Repository + .ChangeRepository>() + .AsUpdateable(data) + .IgnoreColumns(a => new { a.CreateTime, a.CreateUserId }) + .IgnoreNullColumns() + .ExecuteCommandAsync() > 0; + } + return new Response { Code = 200, Result = flag, Message = flag ? "数据保存成功" : "数据保存失败" }; + } + /// + /// 删除组件 + /// + /// + /// + public async Task> DeleteComponent(string ids) + { + var idArray = ids.Split(","); + var flag = await Repository.ChangeRepository>().DeleteByIdsAsync(idArray); + return new Response { Code = 200, Result = flag, Message = flag ? "删除成功" : "删除失败" }; + } + #endregion + public IList Add(IFormFileCollection files) { if (!_auth.CheckLogin()) diff --git a/OpenAuth.Repository/Domain/GoView/GoviewComponent.cs b/OpenAuth.Repository/Domain/GoView/GoviewComponent.cs new file mode 100644 index 0000000..942d68a --- /dev/null +++ b/OpenAuth.Repository/Domain/GoView/GoviewComponent.cs @@ -0,0 +1,35 @@ +using SqlSugar; + +namespace OpenAuth.Repository.Domain.GoView; + +/// +/// 组件模型类 +/// +[SugarTable("t_goview_component")] +public class GoviewComponent +{ + [SugarColumn(IsPrimaryKey = true, ColumnName = "id")] + public string Id { get; set; } + + /// + /// 组件名称 + /// + [SugarColumn(ColumnName = "component_name")] + public string ComponentName { get; set; } + + + [SugarColumn(IsNullable = true, ColumnName = "create_time")] + public string CreateTime { get; set; } + + /// + /// 创建人id + /// + [SugarColumn(ColumnName = "create_user_id")] + public string CreateUserId { get; set; } + + /// + /// 组件数据 + /// + [SugarColumn(ColumnName = "component_data")] + public string ComponentData { 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 1034342..518cf64 100644 --- a/OpenAuth.WebApi/Controllers/ServiceControllers/GoView/GoViewController.cs +++ b/OpenAuth.WebApi/Controllers/ServiceControllers/GoView/GoViewController.cs @@ -1,10 +1,8 @@ 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; namespace OpenAuth.WebApi.Controllers.ServiceControllers.GoView; @@ -17,7 +15,6 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers.GoView; public class GoViewProjectController : ControllerBase { private readonly GoViewProjectApp _app; - public GoViewProjectController(GoViewProjectApp goView) { @@ -112,57 +109,48 @@ public class GoViewProjectController : ControllerBase { return await _app.SaveData(data); } - - //一个上传图片组件里的图片,一个获取所有已上传图片组件里的图片,一个删除图片 - /// - /// 图片上传接口 - /// - /// - /// - [HttpPost("image/upload")] - [RequestSizeLimit(214748364800)] - public Response> UploadImage(IFormFileCollection files) - { - var result = new Response>(); - try - { - result.Result = _app.Add(files); - } - catch (Exception ex) - { - result.Code = 500; - result.Message = ex.Message; - } - return result; - } - + #region 组件数据 /// - /// 获取组件图片 + /// 获取组件集合 /// - /// + /// + /// /// - [HttpGet("image/list")] - public Response> GetImage([FromQuery] PageReq req ) - { - - return new Response>() - { - Result = _app.GetImage(req) - }; - } - /// - /// 删除图片 - /// - /// - /// - [HttpPost("image/delete")] - public Response DeleteImage(string ids) - { - return new Response() - { - Result = _app.DeleteImage(ids) - }; - } - + [HttpGet("getcomponentlist")] + public async Task>>> GetComponentList([FromQuery] GoViewProjectPage req) + { + return await _app.GetComponentList(req); + } + /// + /// 获取组件数据 + /// + /// + /// + [HttpGet("getComponentData")] + public async Task> GetComponentData(string componentId) + { + return await _app.GetComponentData(componentId); + } + /// + /// 保存组件数据 + /// + /// + /// + [HttpPost("saveComponentData")] + public async Task> SaveComponentData(GoviewComponent data) + { + return await _app.SaveComponentData(data); + } + /// + /// 删除组件数据 + /// + /// + /// + [HttpPost("deleteComponentData")] + public async Task> DeleteComponent(string ids) + { + return await _app.DeleteComponent(ids); + } + #endregion } \ No newline at end of file