ZrAdminNetCore/ZR.Admin.WebApi/Controllers/Liveforum/T_AgreementsController.cs
2025-11-16 18:50:32 +08:00

110 lines
3.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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/tagreements")]
public class T_AgreementsController : BaseController
{
/// <summary>
/// 协议内容接口
/// </summary>
private readonly IT_AgreementsService _T_AgreementsService;
public T_AgreementsController(IT_AgreementsService T_AgreementsService)
{
_T_AgreementsService = T_AgreementsService;
}
/// <summary>
/// 查询协议内容列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
[HttpGet("list")]
[ActionPermissionFilter(Permission = "tagreements:list")]
public IActionResult QueryT_Agreements([FromQuery] T_AgreementsQueryDto parm)
{
var response = _T_AgreementsService.GetList(parm);
return SUCCESS(response);
}
/// <summary>
/// 查询协议内容详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
[HttpGet("{Id}")]
[ActionPermissionFilter(Permission = "tagreements:query")]
public IActionResult GetT_Agreements(int Id)
{
var response = _T_AgreementsService.GetInfo(Id);
var info = response.Adapt<T_AgreementsDto>();
return SUCCESS(info);
}
/// <summary>
/// 添加协议内容
/// </summary>
/// <returns></returns>
[HttpPost]
[ActionPermissionFilter(Permission = "tagreements:add")]
[Log(Title = "协议内容", BusinessType = BusinessType.INSERT)]
public IActionResult AddT_Agreements([FromBody] T_AgreementsDto parm)
{
var modal = parm.Adapt<T_Agreements>().ToCreate(HttpContext);
var response = _T_AgreementsService.AddT_Agreements(modal);
return SUCCESS(response);
}
/// <summary>
/// 更新协议内容
/// </summary>
/// <returns></returns>
[HttpPut]
[ActionPermissionFilter(Permission = "tagreements:edit")]
[Log(Title = "协议内容", BusinessType = BusinessType.UPDATE)]
public IActionResult UpdateT_Agreements([FromBody] T_AgreementsDto parm)
{
if (parm.Id == 0)
{
throw new CustomException(ResultCode.CUSTOM_ERROR, "请求参数为空");
}
var oldal = _T_AgreementsService.GetById(parm.Id);
if (oldal == null)
{
throw new CustomException(ResultCode.CUSTOM_ERROR, "数据不存在");
}
var modal = parm.Adapt(oldal);
var response = _T_AgreementsService.UpdateT_Agreements(modal);
return ToResponse(response);
}
/// <summary>
/// 删除协议内容
/// </summary>
/// <returns></returns>
[HttpPost("delete/{ids}")]
[ActionPermissionFilter(Permission = "tagreements:delete")]
[Log(Title = "协议内容", BusinessType = BusinessType.DELETE)]
public IActionResult DeleteT_Agreements([FromRoute]string ids)
{
var idArr = Tools.SplitAndConvert<int>(ids);
return ToResponse(_T_AgreementsService.Delete(idArr, "删除协议内容"));
}
}
}