128 lines
4.4 KiB
C#
128 lines
4.4 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
||
using ZR.LiveForum.Model.Liveforum.Dto;
|
||
using ZR.LiveForum.Model.Liveforum;
|
||
using ZR.Service.Liveforum.ILiveforumService;
|
||
|
||
//创建时间:2025-11-16
|
||
namespace ZR.Admin.WebApi.Controllers.Liveforum
|
||
{
|
||
/// <summary>
|
||
/// 帖子图片列表
|
||
/// </summary>
|
||
[Route("liveforum/tpostimages")]
|
||
public class T_PostImagesController : BaseController
|
||
{
|
||
/// <summary>
|
||
/// 帖子图片列表接口
|
||
/// </summary>
|
||
private readonly IT_PostImagesService _T_PostImagesService;
|
||
|
||
public T_PostImagesController(IT_PostImagesService T_PostImagesService)
|
||
{
|
||
_T_PostImagesService = T_PostImagesService;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询帖子图片列表列表
|
||
/// </summary>
|
||
/// <param name="parm"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("list")]
|
||
[ActionPermissionFilter(Permission = "tpostimages:list")]
|
||
public IActionResult QueryT_PostImages([FromQuery] T_PostImagesQueryDto parm)
|
||
{
|
||
var response = _T_PostImagesService.GetList(parm);
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 查询帖子图片列表详情
|
||
/// </summary>
|
||
/// <param name="Id"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("{Id}")]
|
||
[ActionPermissionFilter(Permission = "tpostimages:query")]
|
||
public IActionResult GetT_PostImages(long Id)
|
||
{
|
||
var response = _T_PostImagesService.GetInfo(Id);
|
||
|
||
var info = response.Adapt<T_PostImagesDto>();
|
||
return SUCCESS(info);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 添加帖子图片列表
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
[ActionPermissionFilter(Permission = "tpostimages:add")]
|
||
[Log(Title = "帖子图片列表", BusinessType = BusinessType.INSERT)]
|
||
public IActionResult AddT_PostImages([FromBody] T_PostImagesDto parm)
|
||
{
|
||
var modal = parm.Adapt<T_PostImages>().ToCreate(HttpContext);
|
||
|
||
var response = _T_PostImagesService.AddT_PostImages(modal);
|
||
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 更新帖子图片列表
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPut]
|
||
[ActionPermissionFilter(Permission = "tpostimages:edit")]
|
||
[Log(Title = "帖子图片列表", BusinessType = BusinessType.UPDATE)]
|
||
public IActionResult UpdateT_PostImages([FromBody] T_PostImagesDto parm)
|
||
{
|
||
|
||
if (parm.Id == 0)
|
||
{
|
||
throw new CustomException(ResultCode.CUSTOM_ERROR, "请求参数为空");
|
||
}
|
||
var oldal = _T_PostImagesService.GetById(parm.Id);
|
||
if (oldal == null)
|
||
{
|
||
throw new CustomException(ResultCode.CUSTOM_ERROR, "数据不存在");
|
||
}
|
||
var modal = parm.Adapt(oldal);
|
||
var response = _T_PostImagesService.UpdateT_PostImages(modal);
|
||
|
||
return ToResponse(response);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 删除帖子图片列表
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost("delete/{ids}")]
|
||
[ActionPermissionFilter(Permission = "tpostimages:delete")]
|
||
[Log(Title = "帖子图片列表", BusinessType = BusinessType.DELETE)]
|
||
public IActionResult DeleteT_PostImages([FromRoute]string ids)
|
||
{
|
||
var idArr = Tools.SplitAndConvert<long>(ids);
|
||
|
||
return ToResponse(_T_PostImagesService.Delete(idArr, "删除帖子图片列表"));
|
||
}
|
||
|
||
/// <summary>
|
||
/// 导出帖子图片列表
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[Log(Title = "帖子图片列表", BusinessType = BusinessType.EXPORT, IsSaveResponseData = false)]
|
||
[HttpGet("export")]
|
||
[ActionPermissionFilter(Permission = "tpostimages:export")]
|
||
public IActionResult Export([FromQuery] T_PostImagesQueryDto parm)
|
||
{
|
||
var list = _T_PostImagesService.ExportList(parm).Result;
|
||
if (list == null || list.Count <= 0)
|
||
{
|
||
return ToResponse(ResultCode.FAIL, "没有要导出的数据");
|
||
}
|
||
var result = ExportExcelMini(list, "帖子图片列表", "帖子图片列表");
|
||
return ExportExcel(result.Item2, result.Item1);
|
||
}
|
||
|
||
}
|
||
} |