ZrAdminNetCore/ZR.Admin.WebApi/Controllers/Liveforum/T_UserLevelsController.cs
2025-11-16 11:23:52 +08:00

132 lines
4.4 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 Mapster;
using Microsoft.AspNetCore.Mvc;
using ZR.LiveForum.Model.Liveforum;
using ZR.LiveForum.Model.Liveforum.Dto;
using ZR.Service.Liveforum;
using ZR.Service.Liveforum.ILiveforumService;
//创建时间2025-11-15
namespace ZR.Admin.WebApi.Controllers.Liveforum
{
/// <summary>
/// 等级配置
/// </summary>
[Route("liveforum/tuserlevels")]
public class T_UserLevelsController : BaseController
{
/// <summary>
/// 等级配置接口
/// </summary>
private readonly IT_UserLevelsService _T_UserLevelsService;
public T_UserLevelsController(IT_UserLevelsService T_UserLevelsService)
{
_T_UserLevelsService = T_UserLevelsService;
}
/// <summary>
/// 查询等级配置列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
[HttpGet("list")]
[ActionPermissionFilter(Permission = "tuserlevels:list")]
public IActionResult QueryT_UserLevels([FromQuery] T_UserLevelsQueryDto parm)
{
var response = _T_UserLevelsService.GetList(parm);
return SUCCESS(response);
}
/// <summary>
/// 查询等级配置详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
[HttpGet("{Id}")]
[ActionPermissionFilter(Permission = "tuserlevels:query")]
public IActionResult GetT_UserLevels(int Id)
{
var response = _T_UserLevelsService.GetInfo(Id);
var info = response.Adapt<T_UserLevelsDto>();
return SUCCESS(info);
}
/// <summary>
/// 添加等级配置
/// </summary>
/// <returns></returns>
[HttpPost]
[ActionPermissionFilter(Permission = "tuserlevels:add")]
[Log(Title = "等级配置", BusinessType = BusinessType.INSERT)]
public IActionResult AddT_UserLevels([FromBody] T_UserLevelsDto parm)
{
var modal = parm.Adapt<T_UserLevels>().ToCreate(HttpContext);
modal.CreatedAt = DateTime.Now;
modal.UpdatedAt = DateTime.Now;
var response = _T_UserLevelsService.AddT_UserLevels(modal);
return SUCCESS(response);
}
/// <summary>
/// 更新等级配置
/// </summary>
/// <returns></returns>
[HttpPut]
[ActionPermissionFilter(Permission = "tuserlevels:edit")]
[Log(Title = "等级配置", BusinessType = BusinessType.UPDATE)]
public IActionResult UpdateT_UserLevels([FromBody] T_UserLevelsDto parm)
{
if (parm.Id == 0)
{
throw new CustomException(ResultCode.CUSTOM_ERROR, "请求参数为空");
}
var oldal = _T_UserLevelsService.GetById(parm.Id);
if (oldal == null)
{
throw new CustomException(ResultCode.CUSTOM_ERROR, "数据不存在");
}
var modal = parm.Adapt(oldal);
modal.UpdatedAt = DateTime.Now;
var response = _T_UserLevelsService.UpdateT_UserLevels(modal);
return ToResponse(response);
}
/// <summary>
/// 删除等级配置
/// </summary>
/// <returns></returns>
[HttpPost("delete/{ids}")]
[ActionPermissionFilter(Permission = "tuserlevels:delete")]
[Log(Title = "等级配置", BusinessType = BusinessType.DELETE)]
public IActionResult DeleteT_UserLevels([FromRoute] string ids)
{
var idArr = Tools.SplitAndConvert<int>(ids);
return ToResponse(_T_UserLevelsService.Delete(idArr));
}
/// <summary>
/// 导出等级配置
/// </summary>
/// <returns></returns>
[Log(Title = "等级配置", BusinessType = BusinessType.EXPORT, IsSaveResponseData = false)]
[HttpGet("export")]
[ActionPermissionFilter(Permission = "tuserlevels:export")]
public IActionResult Export([FromQuery] T_UserLevelsQueryDto parm)
{
var list = _T_UserLevelsService.ExportList(parm).Result;
if (list == null || list.Count <= 0)
{
return ToResponse(ResultCode.FAIL, "没有要导出的数据");
}
var result = ExportExcelMini(list, "等级配置", "等级配置");
return ExportExcel(result.Item2, result.Item1);
}
}
}