116 lines
3.6 KiB
C#
116 lines
3.6 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
||
using ZR.Model.Business.Dto;
|
||
using ZR.Model.Business;
|
||
using ZR.Service.Business.IBusinessService;
|
||
using ZR.Service.Business;
|
||
|
||
//创建时间:2025-07-30
|
||
namespace ZR.Admin.WebApi.Controllers.Business
|
||
{
|
||
/// <summary>
|
||
/// 礼品小程序
|
||
/// </summary>
|
||
[Route("business/GiftConfig")]
|
||
public class GiftConfigController : BaseController
|
||
{
|
||
/// <summary>
|
||
/// 礼品小程序接口
|
||
/// </summary>
|
||
private readonly IGiftConfigService _GiftConfigService;
|
||
|
||
public GiftConfigController(IGiftConfigService GiftConfigService)
|
||
{
|
||
_GiftConfigService = GiftConfigService;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询礼品小程序列表
|
||
/// </summary>
|
||
/// <param name="parm"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("list")]
|
||
[ActionPermissionFilter(Permission = "giftconfig:list")]
|
||
public IActionResult QueryGiftConfig([FromQuery] GiftConfigQueryDto parm)
|
||
{
|
||
var response = _GiftConfigService.GetList(parm);
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 查询礼品小程序详情
|
||
/// </summary>
|
||
/// <param name="Id"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("{Id}")]
|
||
[ActionPermissionFilter(Permission = "giftconfig:query")]
|
||
public IActionResult GetGiftConfig(int? Id)
|
||
{
|
||
var t = _GiftConfigService.Count(it => true);
|
||
GiftConfigDto info = new GiftConfigDto();
|
||
if (t > 0)
|
||
{
|
||
var response = _GiftConfigService.GetFirst(it => true);
|
||
info = response.Adapt<GiftConfigDto>();
|
||
|
||
}
|
||
else
|
||
{
|
||
var tt = _GiftConfigService.AddGiftConfig(new GiftConfig()
|
||
{
|
||
HomeImage = "",
|
||
Extend = "",
|
||
Extend1 = "",
|
||
});
|
||
info = tt.Adapt<GiftConfigDto>();
|
||
}
|
||
return SUCCESS(info);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 添加礼品小程序
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
[ActionPermissionFilter(Permission = "giftconfig:add")]
|
||
[Log(Title = "礼品小程序", BusinessType = BusinessType.INSERT)]
|
||
public IActionResult AddGiftConfig([FromBody] GiftConfigDto parm)
|
||
{
|
||
var modal = parm.Adapt<GiftConfig>().ToCreate(HttpContext);
|
||
|
||
var response = _GiftConfigService.AddGiftConfig(modal);
|
||
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 更新礼品小程序
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPut]
|
||
[ActionPermissionFilter(Permission = "giftconfig:edit")]
|
||
[Log(Title = "礼品小程序", BusinessType = BusinessType.UPDATE)]
|
||
public IActionResult UpdateGiftConfig([FromBody] GiftConfigDto parm)
|
||
{
|
||
var modal = parm.Adapt<GiftConfig>().ToUpdate(HttpContext);
|
||
var response = _GiftConfigService.UpdateGiftConfig(modal);
|
||
|
||
return ToResponse(response);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 删除礼品小程序
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost("delete/{ids}")]
|
||
[ActionPermissionFilter(Permission = "giftconfig:delete")]
|
||
[Log(Title = "礼品小程序", BusinessType = BusinessType.DELETE)]
|
||
public IActionResult DeleteGiftConfig([FromRoute] string ids)
|
||
{
|
||
var idArr = Tools.SplitAndConvert<int>(ids);
|
||
|
||
return ToResponse(_GiftConfigService.Delete(idArr, "删除礼品小程序"));
|
||
}
|
||
|
||
}
|
||
} |