Merge remote-tracking branch 'origin/DataMaintenance' into DataMaintenance
# Conflicts: # OpenAuth.App/ServiceApp/GoView/GoViewProjectApp.cs # OpenAuth.WebApi/Controllers/ServiceControllers/GoView/GoViewController.csDataMaintenance
commit
e212d76822
|
|
@ -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())
|
||||||
|
|
|
||||||
|
|
@ -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; }
|
||||||
|
}
|
||||||
|
|
@ -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;
|
||||||
|
|
@ -17,7 +15,6 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers.GoView;
|
||||||
public class GoViewProjectController : ControllerBase
|
public class GoViewProjectController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly GoViewProjectApp _app;
|
private readonly GoViewProjectApp _app;
|
||||||
|
|
||||||
|
|
||||||
public GoViewProjectController(GoViewProjectApp goView)
|
public GoViewProjectController(GoViewProjectApp goView)
|
||||||
{
|
{
|
||||||
|
|
@ -112,57 +109,48 @@ public class GoViewProjectController : ControllerBase
|
||||||
{
|
{
|
||||||
return await _app.SaveData(data);
|
return await _app.SaveData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
//一个上传图片组件里的图片,一个获取所有已上传图片组件里的图片,一个删除图片
|
|
||||||
/// <summary>
|
|
||||||
/// 图片上传接口
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="files"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPost("image/upload")]
|
|
||||||
[RequestSizeLimit(214748364800)]
|
|
||||||
public Response<IList<SysUploadFile>> UploadImage(IFormFileCollection files)
|
|
||||||
{
|
|
||||||
var result = new Response<IList<SysUploadFile>>();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
result.Result = _app.Add(files);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
result.Code = 500;
|
|
||||||
result.Message = ex.Message;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
#region 组件数据
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取组件图片
|
/// 获取组件集合
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="req"></param>
|
/// <param name="page"></param>
|
||||||
|
/// <param name="limit"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("image/list")]
|
[HttpGet("getcomponentlist")]
|
||||||
public Response<IList<SysUploadFile>> GetImage([FromQuery] PageReq req )
|
public async Task<Response<PageInfo<List<GoviewComponent>>>> GetComponentList([FromQuery] GoViewProjectPage req)
|
||||||
{
|
{
|
||||||
|
return await _app.GetComponentList(req);
|
||||||
return new Response<IList<SysUploadFile>>()
|
}
|
||||||
{
|
/// <summary>
|
||||||
Result = _app.GetImage(req)
|
/// 获取组件数据
|
||||||
};
|
/// </summary>
|
||||||
}
|
/// <param name="id"></param>
|
||||||
/// <summary>
|
/// <returns></returns>
|
||||||
/// 删除图片
|
[HttpGet("getComponentData")]
|
||||||
/// </summary>
|
public async Task<Response<GoviewComponent>> GetComponentData(string componentId)
|
||||||
/// <param name="ids"></param>
|
{
|
||||||
/// <returns></returns>
|
return await _app.GetComponentData(componentId);
|
||||||
[HttpPost("image/delete")]
|
}
|
||||||
public Response<bool> DeleteImage(string ids)
|
/// <summary>
|
||||||
{
|
/// 保存组件数据
|
||||||
return new Response<bool>()
|
/// </summary>
|
||||||
{
|
/// <param name="data"></param>
|
||||||
Result = _app.DeleteImage(ids)
|
/// <returns></returns>
|
||||||
};
|
[HttpPost("saveComponentData")]
|
||||||
}
|
public async Task<Response<bool>> SaveComponentData(GoviewComponent data)
|
||||||
|
{
|
||||||
|
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
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue