goview 图片增加分组功能
parent
a6c37463c5
commit
965c5bb197
|
|
@ -152,6 +152,7 @@ public class GoViewProjectApp : SqlSugarBaseApp<GoviewProject, SugarDbContext>
|
|||
}
|
||||
|
||||
#region 组件数据
|
||||
|
||||
/// <summary>
|
||||
/// 获取组件集合
|
||||
/// </summary>
|
||||
|
|
@ -161,7 +162,7 @@ public class GoViewProjectApp : SqlSugarBaseApp<GoviewProject, SugarDbContext>
|
|||
{
|
||||
RefAsync<int> total = 0;
|
||||
var list = await Repository.ChangeRepository<SugarRepositiry<GoviewComponent>>().AsQueryable()
|
||||
.WhereIF(!string.IsNullOrEmpty(page.key),r=>r.ComponentName.Contains(page.key))
|
||||
.WhereIF(!string.IsNullOrEmpty(page.key), r => r.ComponentName.Contains(page.key))
|
||||
.ToPageListAsync(page.page, page.limit, total);
|
||||
return new Response<PageInfo<List<GoviewComponent>>>()
|
||||
{
|
||||
|
|
@ -172,6 +173,7 @@ public class GoViewProjectApp : SqlSugarBaseApp<GoviewProject, SugarDbContext>
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取组件数据
|
||||
/// </summary>
|
||||
|
|
@ -187,6 +189,7 @@ public class GoViewProjectApp : SqlSugarBaseApp<GoviewProject, SugarDbContext>
|
|||
Result = data
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存组件数据
|
||||
/// </summary>
|
||||
|
|
@ -218,8 +221,10 @@ public class GoViewProjectApp : SqlSugarBaseApp<GoviewProject, SugarDbContext>
|
|||
.IgnoreNullColumns()
|
||||
.ExecuteCommandAsync() > 0;
|
||||
}
|
||||
|
||||
return new Response<bool> { Code = 200, Result = flag, Message = flag ? "数据保存成功" : "数据保存失败" };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除组件
|
||||
/// </summary>
|
||||
|
|
@ -231,9 +236,10 @@ public class GoViewProjectApp : SqlSugarBaseApp<GoviewProject, SugarDbContext>
|
|||
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, string groupName)
|
||||
{
|
||||
if (!_auth.CheckLogin())
|
||||
{
|
||||
|
|
@ -243,13 +249,13 @@ public class GoViewProjectApp : SqlSugarBaseApp<GoviewProject, SugarDbContext>
|
|||
var result = new List<SysUploadFile>();
|
||||
foreach (var file in files)
|
||||
{
|
||||
result.Add(Add(file));
|
||||
result.Add(Add(file, groupName));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public SysUploadFile Add(IFormFile file)
|
||||
public SysUploadFile Add(IFormFile file, string groupName)
|
||||
{
|
||||
if (file != null)
|
||||
{
|
||||
|
|
@ -284,6 +290,7 @@ public class GoViewProjectApp : SqlSugarBaseApp<GoviewProject, SugarDbContext>
|
|||
var image = new GoviewImage
|
||||
{
|
||||
FileId = filedb.Id,
|
||||
GroupName = groupName
|
||||
};
|
||||
Repository.ChangeRepository<SugarRepositiry<GoviewImage>>().Insert(image);
|
||||
return filedb;
|
||||
|
|
@ -346,11 +353,12 @@ public class GoViewProjectApp : SqlSugarBaseApp<GoviewProject, SugarDbContext>
|
|||
}
|
||||
}
|
||||
|
||||
public IList<SysUploadFile> GetImage(PageReq req)
|
||||
public IList<SysUploadFile> GetImage(GoViewImagePage req)
|
||||
{
|
||||
var list = Repository.ChangeRepository<SugarRepositiry<SysUploadFile>>()
|
||||
.AsQueryable()
|
||||
.InnerJoin<GoviewImage>((a, b) => a.Id.Equals(b.FileId))
|
||||
.WhereIF(!string.IsNullOrEmpty(req.GroupName),(a,b)=>b.GroupName.Equals(req.GroupName))
|
||||
.Select<SysUploadFile>()
|
||||
.ToList();
|
||||
return list;
|
||||
|
|
@ -362,6 +370,7 @@ public class GoViewProjectApp : SqlSugarBaseApp<GoviewProject, SugarDbContext>
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var idArray = ids.Split(",").Select(a => a.ToLong());
|
||||
// 向goviewimage中查询
|
||||
var list = Repository.ChangeRepository<SugarRepositiry<GoviewImage>>()
|
||||
|
|
@ -374,4 +383,17 @@ public class GoViewProjectApp : SqlSugarBaseApp<GoviewProject, SugarDbContext>
|
|||
return Repository.ChangeRepository<SugarRepositiry<SysUploadFile>>()
|
||||
.DeleteByIds(list);
|
||||
}
|
||||
|
||||
public Response<IList<string>> GetImageGroupList()
|
||||
{
|
||||
var list = Repository.ChangeRepository<SugarRepositiry<GoviewImage>>()
|
||||
.AsQueryable()
|
||||
.GroupBy(a => a.GroupName)
|
||||
.Select(a => a.GroupName)
|
||||
.ToList();
|
||||
return new Response<IList<string>>
|
||||
{
|
||||
Result = list
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
using OpenAuth.App.BaseApp.Base;
|
||||
|
||||
namespace OpenAuth.App.ServiceApp.GoView.Request;
|
||||
|
||||
public class GoViewImagePage : PageReq
|
||||
{
|
||||
public string GroupName { get; set; }
|
||||
}
|
||||
|
|
@ -22,5 +22,8 @@ namespace OpenAuth.Repository.Domain
|
|||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey=true,ColumnName = "file_id")]
|
||||
public long FileId {get;set;}
|
||||
|
||||
[SugarColumn(ColumnName = "group_name")]
|
||||
public string GroupName { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -162,12 +162,12 @@ public class GoViewProjectController : ControllerBase
|
|||
/// <returns></returns>
|
||||
[HttpPost("image/upload")]
|
||||
[RequestSizeLimit(214748364800)]
|
||||
public Response<IList<SysUploadFile>> UploadImage(IFormFileCollection files)
|
||||
public Response<IList<SysUploadFile>> UploadImage(IFormFileCollection files,string groupName)
|
||||
{
|
||||
var result = new Response<IList<SysUploadFile>>();
|
||||
try
|
||||
{
|
||||
result.Result = _app.Add(files);
|
||||
result.Result = _app.Add(files,groupName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -178,13 +178,20 @@ public class GoViewProjectController : ControllerBase
|
|||
return result;
|
||||
}
|
||||
|
||||
// todo 图片分组列表
|
||||
[HttpGet("imageGroup/list")]
|
||||
public Response<IList<string>> GetImageGroupList()
|
||||
{
|
||||
return _app.GetImageGroupList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取组件图片
|
||||
/// </summary>
|
||||
/// <param name="req"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("image/list")]
|
||||
public Response<IList<SysUploadFile>> GetImage([FromQuery] PageReq req )
|
||||
public Response<IList<SysUploadFile>> GetImage([FromQuery] GoViewImagePage req)
|
||||
{
|
||||
|
||||
return new Response<IList<SysUploadFile>>()
|
||||
|
|
|
|||
Loading…
Reference in New Issue