128 lines
4.1 KiB
C#
128 lines
4.1 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/tposts")]
|
||
public class T_PostsController : BaseController
|
||
{
|
||
/// <summary>
|
||
/// 论坛帖子接口
|
||
/// </summary>
|
||
private readonly IT_PostsService _T_PostsService;
|
||
|
||
public T_PostsController(IT_PostsService T_PostsService)
|
||
{
|
||
_T_PostsService = T_PostsService;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询论坛帖子列表
|
||
/// </summary>
|
||
/// <param name="parm"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("list")]
|
||
[ActionPermissionFilter(Permission = "tposts:list")]
|
||
public IActionResult QueryT_Posts([FromQuery] T_PostsQueryDto parm)
|
||
{
|
||
var response = _T_PostsService.GetList(parm);
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 查询论坛帖子详情
|
||
/// </summary>
|
||
/// <param name="Id"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("{Id}")]
|
||
[ActionPermissionFilter(Permission = "tposts:query")]
|
||
public IActionResult GetT_Posts(long Id)
|
||
{
|
||
var response = _T_PostsService.GetInfo(Id);
|
||
|
||
var info = response.Adapt<T_PostsDto>();
|
||
return SUCCESS(info);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 添加论坛帖子
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
[ActionPermissionFilter(Permission = "tposts:add")]
|
||
[Log(Title = "论坛帖子", BusinessType = BusinessType.INSERT)]
|
||
public IActionResult AddT_Posts([FromBody] T_PostsDto parm)
|
||
{
|
||
var modal = parm.Adapt<T_Posts>().ToCreate(HttpContext);
|
||
|
||
var response = _T_PostsService.AddT_Posts(modal);
|
||
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 更新论坛帖子
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPut]
|
||
[ActionPermissionFilter(Permission = "tposts:edit")]
|
||
[Log(Title = "论坛帖子", BusinessType = BusinessType.UPDATE)]
|
||
public IActionResult UpdateT_Posts([FromBody] T_PostsDto parm)
|
||
{
|
||
|
||
if (parm.Id == 0)
|
||
{
|
||
throw new CustomException(ResultCode.CUSTOM_ERROR, "请求参数为空");
|
||
}
|
||
var oldal = _T_PostsService.GetById(parm.Id);
|
||
if (oldal == null)
|
||
{
|
||
throw new CustomException(ResultCode.CUSTOM_ERROR, "数据不存在");
|
||
}
|
||
var modal = parm.Adapt(oldal);
|
||
var response = _T_PostsService.UpdateT_Posts(modal);
|
||
|
||
return ToResponse(response);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 删除论坛帖子
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost("delete/{ids}")]
|
||
[ActionPermissionFilter(Permission = "tposts:delete")]
|
||
[Log(Title = "论坛帖子", BusinessType = BusinessType.DELETE)]
|
||
public IActionResult DeleteT_Posts([FromRoute]string ids)
|
||
{
|
||
var idArr = Tools.SplitAndConvert<long>(ids);
|
||
|
||
return ToResponse(_T_PostsService.Delete(idArr, "删除论坛帖子"));
|
||
}
|
||
|
||
/// <summary>
|
||
/// 导出论坛帖子
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[Log(Title = "论坛帖子", BusinessType = BusinessType.EXPORT, IsSaveResponseData = false)]
|
||
[HttpGet("export")]
|
||
[ActionPermissionFilter(Permission = "tposts:export")]
|
||
public IActionResult Export([FromQuery] T_PostsQueryDto parm)
|
||
{
|
||
var list = _T_PostsService.ExportList(parm).Result;
|
||
if (list == null || list.Count <= 0)
|
||
{
|
||
return ToResponse(ResultCode.FAIL, "没有要导出的数据");
|
||
}
|
||
var result = ExportExcelMini(list, "论坛帖子", "论坛帖子");
|
||
return ExportExcel(result.Item2, result.Item1);
|
||
}
|
||
|
||
}
|
||
} |