141 lines
4.3 KiB
C#
141 lines
4.3 KiB
C#
using MiaoYu.Api.Admin.ApplicationServices.Apps;
|
|
using MiaoYu.Repository.ChatAI.Admin.Entities;
|
|
|
|
using Microsoft.AspNetCore.Http.Extensions;
|
|
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
|
|
|
using NPOI.HPSF;
|
|
|
|
using System.Net;
|
|
namespace MiaoYu.Api.Admin.Controllers.Apps;
|
|
|
|
/// <summary>
|
|
/// 图片表 控制器
|
|
/// </summary>
|
|
[ControllerDescriptor(MenuId = "44", DisplayName = "图片表")]
|
|
public class TImageConfigController : AdminControllerBase<TImageConfigService>
|
|
{
|
|
public TImageConfigController(TImageConfigService defaultService)
|
|
: base(defaultService)
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取列表
|
|
/// </summary>
|
|
/// <param name="pagingSearchInput"></param>
|
|
/// <returns></returns>
|
|
[ActionDescriptor(PermissionFunctionConsts.Function_Display, DisplayName = "查看数据")]
|
|
[HttpPost]
|
|
public Task<PagingView> FindListAsync([FromBody] PagingSearchInput<T_Image_Config> pagingSearchInput)
|
|
{
|
|
return this._defaultService.FindListAsync(pagingSearchInput);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据id数组删除
|
|
/// </summary>
|
|
/// <param name="ids">ids</param>
|
|
/// <returns></returns>
|
|
[ActionDescriptor(PermissionFunctionConsts.Function_Delete, DisplayName = "删除数据")]
|
|
[HttpPost]
|
|
public async Task<bool> DeleteListAsync([FromBody] List<int> ids)
|
|
{
|
|
await this._defaultService.DeleteListAsync(ids);
|
|
return true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询表单数据
|
|
/// </summary>
|
|
/// <param name="id">id</param>
|
|
/// <returns></returns>
|
|
[ActionDescriptor(DisplayName = "查看表单")]
|
|
[HttpGet("{id?}")]
|
|
public Task<Dictionary<string, object>> FindFormAsync([FromRoute] int id)
|
|
{
|
|
return this._defaultService.FindFormAsync(id);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加
|
|
/// </summary>
|
|
/// <param name="form"></param>
|
|
/// <returns></returns>
|
|
[RequestLimitFilter(Duration = 1, LimitCount = 1)]
|
|
[ActionDescriptor(PermissionFunctionConsts.Function_Insert, DisplayName = "创建表单")]
|
|
[HttpPost]
|
|
[ApiCheckModel]
|
|
public async Task<int> CreateAsync([FromBody] T_Image_Config form)
|
|
{
|
|
|
|
form.UpdateAt = DateTime.Now;
|
|
form.CreateAt = DateTime.Now;
|
|
var image = await this._defaultService.SaveFormAsync(form, false);
|
|
return image?.ImageId ?? 0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 编辑
|
|
/// </summary>
|
|
/// <param name="form"></param>
|
|
/// <returns></returns>
|
|
[RequestLimitFilter(Duration = 1, LimitCount = 1)]
|
|
[ActionDescriptor(PermissionFunctionConsts.Function_Update, DisplayName = "编辑表单")]
|
|
[HttpPost]
|
|
[ApiCheckModel]
|
|
public async Task<int> UpdateAsync([FromBody] T_Image_Config form)
|
|
{
|
|
form.UpdateAt = DateTime.Now;
|
|
var image = await this._defaultService.SaveFormAsync(form, true);
|
|
return image?.ImageId ?? 0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 导出Excel
|
|
/// </summary>
|
|
/// <param name="pagingSearchInput"></param>
|
|
/// <returns></returns>
|
|
[ActionDescriptor(PermissionFunctionConsts.Function_Export, DisplayName = "导出数据")]
|
|
[ApiResourceCacheFilter(10)]
|
|
[HttpPost]
|
|
public async Task ExportExcelAsync([FromBody] PagingSearchInput<T_Image_Config> pagingSearchInput)
|
|
{
|
|
var data = await this._defaultService.ExportExcelAsync(pagingSearchInput);
|
|
var name = $"{PermissionUtil.GetControllerDisplayName(this.GetType())}列表数据 {DateTime.Now.ToString("yyyy-MM-dd")}.xls";
|
|
base.HttpContext.DownLoadFile(data, Tools.GetFileContentType[".xls"].ToStr(), name);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取图片
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[ActionDescriptor(DisplayName = "获取图片")]
|
|
[HttpGet("{imageId?}")]
|
|
[AllowAnonymous]
|
|
public async Task Image([FromRoute] int imageId)
|
|
{
|
|
var url = await this._defaultService.GetImageUrl(imageId);
|
|
if (!string.IsNullOrEmpty(url))
|
|
{
|
|
Response.Redirect(url);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取图片数据源
|
|
/// </summary>
|
|
/// <param name="name"></param>
|
|
/// <returns></returns>
|
|
[ActionDescriptor(DisplayName = "获取图片数据源")]
|
|
[HttpGet]
|
|
public async Task<dynamic> GetImageList([FromQuery] string? name)
|
|
{
|
|
name = WebUtility.UrlDecode(name);
|
|
|
|
return await this._defaultService.GetImageList(name);
|
|
}
|
|
|
|
|
|
} |