Merge remote-tracking branch 'origin/DataMaintenance' into DataMaintenance

# Conflicts:
#	OpenAuth.App/ServiceApp/GoView/GoViewProjectApp.cs
#	OpenAuth.WebApi/Controllers/ServiceControllers/GoView/GoViewController.cs
DataMaintenance
陈伟 2025-02-08 15:33:36 +08:00
commit e212d76822
3 changed files with 157 additions and 52 deletions

View File

@ -151,6 +151,88 @@ public class GoViewProjectApp : SqlSugarBaseApp<GoviewProject, SugarDbContext>
return new Response<bool> { Code = 200, Result = flag, Message = flag ? "数据保存成功" : "数据保存失败" }; return new Response<bool> { Code = 200, Result = flag, Message = flag ? "数据保存成功" : "数据保存失败" };
} }
#region 组件数据
/// <summary>
/// 获取组件集合
/// </summary>
/// <param name="page"></param>
/// <returns></returns>
public async Task<Response<PageInfo<List<GoviewComponent>>>> GetComponentList(GoViewProjectPage page)
{
RefAsync<int> total = 0;
var list = await Repository.ChangeRepository<SugarRepositiry<GoviewComponent>>().AsQueryable()
.WhereIF(!string.IsNullOrEmpty(page.key),r=>r.ComponentName.Contains(page.key))
.ToPageListAsync(page.page, page.limit, total);
return new Response<PageInfo<List<GoviewComponent>>>()
{
Result = new PageInfo<List<GoviewComponent>>
{
Items = list,
Total = total
}
};
}
/// <summary>
/// 获取组件数据
/// </summary>
/// <param name="componentId"></param>
/// <returns></returns>
public async Task<Response<GoviewComponent>> GetComponentData(string componentId)
{
var data = await Repository.ChangeRepository<SugarRepositiry<GoviewComponent>>().AsQueryable()
.SingleAsync(a => a.Id == componentId);
return new Response<GoviewComponent>()
{
Result = data
};
}
/// <summary>
/// 保存组件数据
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<Response<bool>> SaveComponentData(GoviewComponent data)
{
// 更新还是保存,
var comData = await Repository
.ChangeRepository<SugarRepositiry<GoviewComponent>>()
.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<SugarRepositiry<GoviewComponent>>().InsertAsync(data);
}
else
{
data.Id = comData.Id;
flag = await Repository
.ChangeRepository<SugarRepositiry<GoviewComponent>>()
.AsUpdateable(data)
.IgnoreColumns(a => new { a.CreateTime, a.CreateUserId })
.IgnoreNullColumns()
.ExecuteCommandAsync() > 0;
}
return new Response<bool> { Code = 200, Result = flag, Message = flag ? "数据保存成功" : "数据保存失败" };
}
/// <summary>
/// 删除组件
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
public async Task<Response<bool>> DeleteComponent(string ids)
{
var idArray = ids.Split(",");
var flag = await Repository.ChangeRepository<SugarRepositiry<GoviewComponent>>().DeleteByIdsAsync(idArray);
return new Response<bool> { Code = 200, Result = flag, Message = flag ? "删除成功" : "删除失败" };
}
#endregion
public IList<SysUploadFile> Add(IFormFileCollection files) public IList<SysUploadFile> Add(IFormFileCollection files)
{ {
if (!_auth.CheckLogin()) if (!_auth.CheckLogin())

View File

@ -0,0 +1,35 @@
using SqlSugar;
namespace OpenAuth.Repository.Domain.GoView;
/// <summary>
/// 组件模型类
/// </summary>
[SugarTable("t_goview_component")]
public class GoviewComponent
{
[SugarColumn(IsPrimaryKey = true, ColumnName = "id")]
public string Id { get; set; }
/// <summary>
/// 组件名称
/// </summary>
[SugarColumn(ColumnName = "component_name")]
public string ComponentName { get; set; }
[SugarColumn(IsNullable = true, ColumnName = "create_time")]
public string CreateTime { get; set; }
/// <summary>
/// 创建人id
/// </summary>
[SugarColumn(ColumnName = "create_user_id")]
public string CreateUserId { get; set; }
/// <summary>
/// 组件数据
/// </summary>
[SugarColumn(ColumnName = "component_data")]
public string ComponentData { get; set; }
}

View File

@ -1,10 +1,8 @@
using Infrastructure; using Infrastructure;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using OpenAuth.App.BaseApp.Base;
using OpenAuth.App.ServiceApp.GoView; using OpenAuth.App.ServiceApp.GoView;
using OpenAuth.App.ServiceApp.GoView.Request; using OpenAuth.App.ServiceApp.GoView.Request;
using OpenAuth.App.ServiceApp.GoView.Response; using OpenAuth.App.ServiceApp.GoView.Response;
using OpenAuth.Repository.Domain;
using OpenAuth.Repository.Domain.GoView; using OpenAuth.Repository.Domain.GoView;
namespace OpenAuth.WebApi.Controllers.ServiceControllers.GoView; namespace OpenAuth.WebApi.Controllers.ServiceControllers.GoView;
@ -18,7 +16,6 @@ public class GoViewProjectController : ControllerBase
{ {
private readonly GoViewProjectApp _app; private readonly GoViewProjectApp _app;
public GoViewProjectController(GoViewProjectApp goView) public GoViewProjectController(GoViewProjectApp goView)
{ {
_app = goView; _app = goView;
@ -113,56 +110,47 @@ public class GoViewProjectController : ControllerBase
return await _app.SaveData(data); return await _app.SaveData(data);
} }
//一个上传图片组件里的图片,一个获取所有已上传图片组件里的图片,一个删除图片 #region 组件数据
/// <summary> /// <summary>
/// 图片上传接口 /// 获取组件集合
/// </summary> /// </summary>
/// <param name="files"></param> /// <param name="page"></param>
/// <param name="limit"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost("image/upload")] [HttpGet("getcomponentlist")]
[RequestSizeLimit(214748364800)] public async Task<Response<PageInfo<List<GoviewComponent>>>> GetComponentList([FromQuery] GoViewProjectPage req)
public Response<IList<SysUploadFile>> UploadImage(IFormFileCollection files)
{ {
var result = new Response<IList<SysUploadFile>>(); return await _app.GetComponentList(req);
try
{
result.Result = _app.Add(files);
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.Message;
}
return result;
}
/// <summary>
/// 获取组件图片
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpGet("image/list")]
public Response<IList<SysUploadFile>> GetImage([FromQuery] PageReq req )
{
return new Response<IList<SysUploadFile>>()
{
Result = _app.GetImage(req)
};
} }
/// <summary> /// <summary>
/// 删除图片 /// 获取组件数据
/// </summary> /// </summary>
/// <param name="ids"></param> /// <param name="id"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost("image/delete")] [HttpGet("getComponentData")]
public Response<bool> DeleteImage(string ids) public async Task<Response<GoviewComponent>> GetComponentData(string componentId)
{ {
return new Response<bool>() return await _app.GetComponentData(componentId);
}
/// <summary>
/// 保存组件数据
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
[HttpPost("saveComponentData")]
public async Task<Response<bool>> SaveComponentData(GoviewComponent data)
{ {
Result = _app.DeleteImage(ids) return await _app.SaveComponentData(data);
};
} }
/// <summary>
/// 删除组件数据
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
[HttpPost("deleteComponentData")]
public async Task<Response<bool>> DeleteComponent(string ids)
{
return await _app.DeleteComponent(ids);
}
#endregion
} }