76 lines
1.7 KiB
C#
76 lines
1.7 KiB
C#
|
|
using Furion.DynamicApiController;
|
||
|
|
using Microsoft.AspNetCore.Mvc;
|
||
|
|
using YD_Event.Application.Coupon;
|
||
|
|
using YD_Event.Application.Coupon.Dtos;
|
||
|
|
|
||
|
|
namespace YD_Event.Web.Entry.Controllers;
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 优惠券管理
|
||
|
|
/// </summary>
|
||
|
|
[Route("api/coupon")]
|
||
|
|
[ApiDescriptionSettings("优惠券管理")]
|
||
|
|
public class CouponController : IDynamicApiController
|
||
|
|
{
|
||
|
|
private readonly ICouponService _couponService;
|
||
|
|
|
||
|
|
public CouponController(ICouponService couponService)
|
||
|
|
{
|
||
|
|
_couponService = couponService;
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 分页查询
|
||
|
|
/// </summary>
|
||
|
|
[HttpGet("page")]
|
||
|
|
public async Task<CouponPageResult> Page([FromQuery] CouponQueryInput input)
|
||
|
|
{
|
||
|
|
return await _couponService.Page(input);
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 添加优惠券
|
||
|
|
/// </summary>
|
||
|
|
[HttpPost("add")]
|
||
|
|
public async Task Add([FromBody] AddCouponInput input)
|
||
|
|
{
|
||
|
|
await _couponService.Add(input);
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 编辑优惠券
|
||
|
|
/// </summary>
|
||
|
|
[HttpPut("edit")]
|
||
|
|
public async Task Update([FromBody] UpdateCouponInput input)
|
||
|
|
{
|
||
|
|
await _couponService.Update(input);
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 删除优惠券
|
||
|
|
/// </summary>
|
||
|
|
[HttpPost("delete")]
|
||
|
|
public async Task Delete([FromBody] List<long> ids)
|
||
|
|
{
|
||
|
|
await _couponService.Delete(ids);
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 生成/获取兑换码
|
||
|
|
/// </summary>
|
||
|
|
[HttpPost("generateCode")]
|
||
|
|
public async Task<string> GenerateCode([FromBody] long id)
|
||
|
|
{
|
||
|
|
return await _couponService.GenerateCode(id);
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 获取赛事列表
|
||
|
|
/// </summary>
|
||
|
|
[HttpGet("event/list")]
|
||
|
|
public async Task<List<EventSelectOutput>> GetEventList()
|
||
|
|
{
|
||
|
|
return await _couponService.GetEventList();
|
||
|
|
}
|
||
|
|
}
|