parent
fb2bad4e91
commit
6aeb5a0084
|
|
@ -410,7 +410,7 @@ public class GoViewProjectApp : SqlSugarBaseApp<GoviewProject, SugarDbContext>
|
|||
|
||||
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<GoviewProject, SugarDbContext>
|
|||
|
||||
return Repository.ChangeRepository<SugarRepositiry<GoViewParam>>().InsertOrUpdate(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存自定义组件
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> SaveCustomComponent(CustomComponentReq data)
|
||||
{
|
||||
// 保存
|
||||
var record = new GoviewCustomComponent
|
||||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
Content = data.Content,
|
||||
};
|
||||
return await Repository.ChangeRepository<SugarRepositiry<GoviewCustomComponent>>().InsertAsync(record);
|
||||
}
|
||||
|
||||
|
||||
public async Task<Response<PageInfo<List<GoviewCustomComponent>>>> GetCustomComponentList(PageReq req)
|
||||
{
|
||||
return new Response<PageInfo<List<GoviewCustomComponent>>>
|
||||
{
|
||||
Result = new PageInfo<List<GoviewCustomComponent>>
|
||||
{
|
||||
Items = await Repository.ChangeRepository<SugarRepositiry<GoviewCustomComponent>>()
|
||||
.AsQueryable()
|
||||
.ToPageListAsync(req.page, req.limit),
|
||||
Total = await Repository.ChangeRepository<SugarRepositiry<GoviewCustomComponent>>()
|
||||
.AsQueryable()
|
||||
.CountAsync()
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<bool> DeleteCustomComponent(string ids)
|
||||
{
|
||||
var idArray = ids.Split(",");
|
||||
var result = await Repository.ChangeRepository<SugarRepositiry<GoviewCustomComponent>>()
|
||||
.DeleteByIdsAsync(idArray);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
using System.Text.Json.Nodes;
|
||||
|
||||
namespace OpenAuth.App.ServiceApp.GoView.Request;
|
||||
|
||||
public class CustomComponentReq
|
||||
{
|
||||
public string Content { get; set; }
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
namespace OpenAuth.Repository.Domain.GoView.Request;
|
||||
namespace OpenAuth.App.ServiceApp.GoView.Request;
|
||||
|
||||
public class MainPageReq
|
||||
{
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
using System.Text.Json.Nodes;
|
||||
using SqlSugar;
|
||||
|
||||
namespace OpenAuth.Repository.Domain.GoView;
|
||||
|
||||
/// <summary>
|
||||
/// 组件模型类
|
||||
/// </summary>
|
||||
[SugarTable("t_goview_custom_component")]
|
||||
public class GoviewCustomComponent
|
||||
{
|
||||
[SugarColumn(IsPrimaryKey = true, ColumnName = "id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 组件数据
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "content")]
|
||||
public string Content { get; set; }
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自定义组件保存
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("customComponent/save")]
|
||||
public async Task<Response<bool>> SaveCustomComponent(CustomComponentReq data)
|
||||
{
|
||||
var result = new Response<bool>();
|
||||
try
|
||||
{
|
||||
result.Result = await _app.SaveCustomComponent(data);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.Code = 500;
|
||||
result.Message = ex.Message;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
///自定义组件列表
|
||||
/// </summary>
|
||||
/// <param name="req"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("customComponent/list")]
|
||||
public async Task<Response<PageInfo<List<GoviewCustomComponent>>>> GetCustomComponentList([FromQuery] PageReq req)
|
||||
{
|
||||
return await _app.GetCustomComponentList(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除自定义组件
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("customComponent/delete")]
|
||||
public async Task<Response<bool>> DeleteCustomComponent(string ids)
|
||||
{
|
||||
|
||||
var result = new Response<bool>();
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue