128 lines
4.2 KiB
C#
128 lines
4.2 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/tfollows")]
|
||
public class T_FollowsController : BaseController
|
||
{
|
||
/// <summary>
|
||
/// 关注记录接口
|
||
/// </summary>
|
||
private readonly IT_FollowsService _T_FollowsService;
|
||
|
||
public T_FollowsController(IT_FollowsService T_FollowsService)
|
||
{
|
||
_T_FollowsService = T_FollowsService;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询关注记录列表
|
||
/// </summary>
|
||
/// <param name="parm"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("list")]
|
||
[ActionPermissionFilter(Permission = "tfollows:list")]
|
||
public IActionResult QueryT_Follows([FromQuery] T_FollowsQueryDto parm)
|
||
{
|
||
var response = _T_FollowsService.GetList(parm);
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 查询关注记录详情
|
||
/// </summary>
|
||
/// <param name="Id"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("{Id}")]
|
||
[ActionPermissionFilter(Permission = "tfollows:query")]
|
||
public IActionResult GetT_Follows(long Id)
|
||
{
|
||
var response = _T_FollowsService.GetInfo(Id);
|
||
|
||
var info = response.Adapt<T_FollowsDto>();
|
||
return SUCCESS(info);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 添加关注记录
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
[ActionPermissionFilter(Permission = "tfollows:add")]
|
||
[Log(Title = "关注记录", BusinessType = BusinessType.INSERT)]
|
||
public IActionResult AddT_Follows([FromBody] T_FollowsDto parm)
|
||
{
|
||
var modal = parm.Adapt<T_Follows>().ToCreate(HttpContext);
|
||
|
||
var response = _T_FollowsService.AddT_Follows(modal);
|
||
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 更新关注记录
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPut]
|
||
[ActionPermissionFilter(Permission = "tfollows:edit")]
|
||
[Log(Title = "关注记录", BusinessType = BusinessType.UPDATE)]
|
||
public IActionResult UpdateT_Follows([FromBody] T_FollowsDto parm)
|
||
{
|
||
|
||
if (parm.Id == 0)
|
||
{
|
||
throw new CustomException(ResultCode.CUSTOM_ERROR, "请求参数为空");
|
||
}
|
||
var oldal = _T_FollowsService.GetById(parm.Id);
|
||
if (oldal == null)
|
||
{
|
||
throw new CustomException(ResultCode.CUSTOM_ERROR, "数据不存在");
|
||
}
|
||
var modal = parm.Adapt(oldal);
|
||
var response = _T_FollowsService.UpdateT_Follows(modal);
|
||
|
||
return ToResponse(response);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 删除关注记录
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost("delete/{ids}")]
|
||
[ActionPermissionFilter(Permission = "tfollows:delete")]
|
||
[Log(Title = "关注记录", BusinessType = BusinessType.DELETE)]
|
||
public IActionResult DeleteT_Follows([FromRoute]string ids)
|
||
{
|
||
var idArr = Tools.SplitAndConvert<long>(ids);
|
||
|
||
return ToResponse(_T_FollowsService.Delete(idArr));
|
||
}
|
||
|
||
/// <summary>
|
||
/// 导出关注记录
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[Log(Title = "关注记录", BusinessType = BusinessType.EXPORT, IsSaveResponseData = false)]
|
||
[HttpGet("export")]
|
||
[ActionPermissionFilter(Permission = "tfollows:export")]
|
||
public IActionResult Export([FromQuery] T_FollowsQueryDto parm)
|
||
{
|
||
var list = _T_FollowsService.ExportList(parm).Result;
|
||
if (list == null || list.Count <= 0)
|
||
{
|
||
return ToResponse(ResultCode.FAIL, "没有要导出的数据");
|
||
}
|
||
var result = ExportExcelMini(list, "关注记录", "关注记录");
|
||
return ExportExcel(result.Item2, result.Item1);
|
||
}
|
||
|
||
}
|
||
} |