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
{
///
/// 帖子评论记录
///
[Route("liveforum/tcomments")]
public class T_CommentsController : BaseController
{
///
/// 帖子评论记录接口
///
private readonly IT_CommentsService _T_CommentsService;
public T_CommentsController(IT_CommentsService T_CommentsService)
{
_T_CommentsService = T_CommentsService;
}
///
/// 查询帖子评论记录列表
///
///
///
[HttpGet("list")]
[ActionPermissionFilter(Permission = "tcomments:list")]
public IActionResult QueryT_Comments([FromQuery] T_CommentsQueryDto parm)
{
var response = _T_CommentsService.GetList(parm);
return SUCCESS(response);
}
///
/// 查询帖子评论记录详情
///
///
///
[HttpGet("{Id}")]
[ActionPermissionFilter(Permission = "tcomments:query")]
public IActionResult GetT_Comments(long Id)
{
var response = _T_CommentsService.GetInfo(Id);
var info = response.Adapt();
return SUCCESS(info);
}
///
/// 更新帖子评论记录
///
///
[HttpPut]
[ActionPermissionFilter(Permission = "tcomments:edit")]
[Log(Title = "帖子评论记录", BusinessType = BusinessType.UPDATE)]
public IActionResult UpdateT_Comments([FromBody] T_CommentsDto parm)
{
if (parm.Id == 0)
{
throw new CustomException(ResultCode.CUSTOM_ERROR, "请求参数为空");
}
var oldal = _T_CommentsService.GetById(parm.Id);
if (oldal == null)
{
throw new CustomException(ResultCode.CUSTOM_ERROR, "数据不存在");
}
var modal = parm.Adapt(oldal);
var response = _T_CommentsService.UpdateT_Comments(modal);
return ToResponse(response);
}
///
/// 删除帖子评论记录
///
///
[HttpPost("delete/{ids}")]
[ActionPermissionFilter(Permission = "tcomments:delete")]
[Log(Title = "帖子评论记录", BusinessType = BusinessType.DELETE)]
public IActionResult DeleteT_Comments([FromRoute]string ids)
{
var idArr = Tools.SplitAndConvert(ids);
return ToResponse(_T_CommentsService.Delete(idArr));
}
}
}