Banner配置
This commit is contained in:
parent
3acea247e2
commit
38f7ff3523
169
YD_Event.Application/Banner/BannerService.cs
Normal file
169
YD_Event.Application/Banner/BannerService.cs
Normal file
@ -0,0 +1,169 @@
|
||||
using YD_Event.Application.Banner.Dtos;
|
||||
using YD_Event.Core.Entities;
|
||||
|
||||
namespace YD_Event.Application.Banner;
|
||||
|
||||
/// <summary>
|
||||
/// 轮播图服务
|
||||
/// </summary>
|
||||
public class BannerService : BaseService<YD_Event.Core.Entities.Banner>, ITransient
|
||||
{
|
||||
private readonly ISqlSugarRepository<YD_Event.Core.Entities.Banner> _repository;
|
||||
private readonly ISqlSugarRepository<BannerConfig> _configRepository;
|
||||
private readonly ISqlSugarRepository<EventInfo> _eventRepository;
|
||||
private readonly IIdGenerator _idGenerator;
|
||||
|
||||
public BannerService(
|
||||
ISqlSugarRepository<YD_Event.Core.Entities.Banner> repository,
|
||||
ISqlSugarRepository<BannerConfig> configRepository,
|
||||
ISqlSugarRepository<EventInfo> eventRepository,
|
||||
IIdGenerator idGenerator) : base(repository)
|
||||
{
|
||||
_repository = repository;
|
||||
_configRepository = configRepository;
|
||||
_eventRepository = eventRepository;
|
||||
_idGenerator = idGenerator;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取轮播图配置模式
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<BannerConfigOutput> GetConfig()
|
||||
{
|
||||
var config = await _configRepository.GetFirstAsync(x => true);
|
||||
return new BannerConfigOutput { Mode = config?.Mode ?? 0 };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新轮播图配置模式
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public async Task UpdateConfig(BannerConfigInput input)
|
||||
{
|
||||
var config = await _configRepository.GetFirstAsync(x => true);
|
||||
if (config == null)
|
||||
{
|
||||
config = new BannerConfig { Id = _idGenerator.NextId(), Mode = input.Mode };
|
||||
await _configRepository.InsertAsync(config);
|
||||
}
|
||||
else
|
||||
{
|
||||
config.Mode = input.Mode;
|
||||
await _configRepository.UpdateAsync(config);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取轮播图列表(前台展示用)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<BannerOutput>> GetList()
|
||||
{
|
||||
var config = await GetConfig();
|
||||
if (config.Mode == 1) // 自动配置
|
||||
{
|
||||
// 获取最新的4场赛事
|
||||
var events = await _eventRepository.AsQueryable()
|
||||
.Where(x => !x.DeleteMark) // 假设EventInfo有DeleteMark
|
||||
.OrderByDescending(x => x.CreatedTime)
|
||||
.Take(4)
|
||||
.Select(x => new BannerOutput
|
||||
{
|
||||
Id = x.Id,
|
||||
Title = x.EventName,
|
||||
ImageUrl = x.CoverImage,
|
||||
LinkType = 1, // 赛事
|
||||
LinkTarget = x.Id.ToString(),
|
||||
Sort = 0,
|
||||
Status = Core.Enum.AvailabilityStatus.Enable,
|
||||
CreatedTime = x.CreatedTime
|
||||
})
|
||||
.ToListAsync();
|
||||
return events;
|
||||
}
|
||||
else // 手动配置
|
||||
{
|
||||
return await _repository.AsQueryable()
|
||||
.Where(x => x.Status == Core.Enum.AvailabilityStatus.Enable)
|
||||
.OrderBy(x => x.Sort)
|
||||
.Select(x => new BannerOutput
|
||||
{
|
||||
Id = x.Id,
|
||||
Title = x.Title,
|
||||
ImageUrl = x.ImageUrl,
|
||||
LinkType = x.LinkType,
|
||||
LinkTarget = x.LinkTarget,
|
||||
Sort = x.Sort,
|
||||
Status = x.Status,
|
||||
Remark = x.Remark,
|
||||
CreatedTime = x.CreatedTime
|
||||
})
|
||||
.ToListAsync();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询(后台管理用)
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<PageResult<BannerOutput>> Page(BannerQueryInput input)
|
||||
{
|
||||
var query = _repository.AsQueryable()
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(input.Title), x => x.Title.Contains(input.Title))
|
||||
.OrderBy(x => x.Sort)
|
||||
.Select(x => new BannerOutput
|
||||
{
|
||||
Id = x.Id,
|
||||
Title = x.Title,
|
||||
ImageUrl = x.ImageUrl,
|
||||
LinkType = x.LinkType,
|
||||
LinkTarget = x.LinkTarget,
|
||||
Sort = x.Sort,
|
||||
Status = x.Status,
|
||||
Remark = x.Remark,
|
||||
CreatedTime = x.CreatedTime
|
||||
});
|
||||
|
||||
return await query.ToPagedListAsync(input);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加轮播图
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public async Task Add(AddBannerInput input)
|
||||
{
|
||||
var entity = input.Adapt<YD_Event.Core.Entities.Banner>();
|
||||
entity.Id = _idGenerator.NextId();
|
||||
await _repository.InsertAsync(entity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新轮播图
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public async Task Update(UpdateBannerInput input)
|
||||
{
|
||||
var entity = await _repository.GetByIdAsync(input.Id);
|
||||
if (entity == null) throw new InvalidOperationException("轮播图不存在");
|
||||
|
||||
input.Adapt(entity);
|
||||
await _repository.UpdateAsync(entity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除轮播图
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
public async Task Delete(List<long> ids)
|
||||
{
|
||||
if (ids == null || !ids.Any()) return;
|
||||
await _repository.DeleteAsync(x => ids.Contains(x.Id));
|
||||
}
|
||||
}
|
||||
106
YD_Event.Application/Banner/Dtos/BannerDtos.cs
Normal file
106
YD_Event.Application/Banner/Dtos/BannerDtos.cs
Normal file
@ -0,0 +1,106 @@
|
||||
using SqlSugar;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using YD_Event.Core.Enum;
|
||||
|
||||
namespace YD_Event.Application.Banner.Dtos;
|
||||
|
||||
/// <summary>
|
||||
/// 添加轮播图输入参数
|
||||
/// </summary>
|
||||
public class AddBannerInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 标题
|
||||
/// </summary>
|
||||
public string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 图片地址
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "图片地址不能为空")]
|
||||
public string ImageUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 跳转链接类型(0-图片/无跳转 1-赛事)
|
||||
/// </summary>
|
||||
public int LinkType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 跳转目标(赛事ID或URL)
|
||||
/// </summary>
|
||||
public string LinkTarget { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序
|
||||
/// </summary>
|
||||
public int Sort { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string Remark { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新轮播图输入参数
|
||||
/// </summary>
|
||||
public class UpdateBannerInput : AddBannerInput
|
||||
{
|
||||
/// <summary>
|
||||
/// Id
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "Id不能为空")]
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 状态
|
||||
/// </summary>
|
||||
public AvailabilityStatus Status { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 轮播图查询参数
|
||||
/// </summary>
|
||||
public class BannerQueryInput : Pagination
|
||||
{
|
||||
/// <summary>
|
||||
/// 标题
|
||||
/// </summary>
|
||||
public string Title { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 轮播图输出参数
|
||||
/// </summary>
|
||||
public class BannerOutput
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string ImageUrl { get; set; }
|
||||
public int LinkType { get; set; }
|
||||
public string LinkTarget { get; set; }
|
||||
public int Sort { get; set; }
|
||||
public AvailabilityStatus Status { get; set; }
|
||||
public string Remark { get; set; }
|
||||
public DateTime CreatedTime { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 轮播图配置输入参数
|
||||
/// </summary>
|
||||
public class BannerConfigInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 模式(0-手动配置 1-自动配置)
|
||||
/// </summary>
|
||||
[Required]
|
||||
public int Mode { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 轮播图配置输出参数
|
||||
/// </summary>
|
||||
public class BannerConfigOutput
|
||||
{
|
||||
public int Mode { get; set; }
|
||||
}
|
||||
@ -1,22 +0,0 @@
|
||||
using YD_Event.Application.Setting.Dtos;
|
||||
|
||||
namespace YD_Event.Application.Setting;
|
||||
|
||||
/// <summary>
|
||||
/// 退款配置服务接口
|
||||
/// </summary>
|
||||
public interface IRefundConfigService : ITransient
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取退款配置
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<RefundConfigOutput> GetConfig();
|
||||
|
||||
/// <summary>
|
||||
/// 更新退款配置
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
Task UpdateConfig(RefundConfigInput input);
|
||||
}
|
||||
@ -5,7 +5,7 @@ namespace YD_Event.Application.Setting;
|
||||
/// <summary>
|
||||
/// 退款配置服务
|
||||
/// </summary>
|
||||
public class RefundConfigService : IRefundConfigService
|
||||
public class RefundConfigService : ITransient
|
||||
{
|
||||
private readonly ISqlSugarRepository<RefundConfig> _repository;
|
||||
private readonly IIdGenerator _idGenerator;
|
||||
|
||||
@ -105,6 +105,138 @@
|
||||
验证码
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:YD_Event.Application.Banner.BannerService">
|
||||
<summary>
|
||||
轮播图服务
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:YD_Event.Application.Banner.BannerService.GetConfig">
|
||||
<summary>
|
||||
获取轮播图配置模式
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:YD_Event.Application.Banner.BannerService.UpdateConfig(YD_Event.Application.Banner.Dtos.BannerConfigInput)">
|
||||
<summary>
|
||||
更新轮播图配置模式
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:YD_Event.Application.Banner.BannerService.GetList">
|
||||
<summary>
|
||||
获取轮播图列表(前台展示用)
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:YD_Event.Application.Banner.BannerService.Page(YD_Event.Application.Banner.Dtos.BannerQueryInput)">
|
||||
<summary>
|
||||
分页查询(后台管理用)
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:YD_Event.Application.Banner.BannerService.Add(YD_Event.Application.Banner.Dtos.AddBannerInput)">
|
||||
<summary>
|
||||
添加轮播图
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:YD_Event.Application.Banner.BannerService.Update(YD_Event.Application.Banner.Dtos.UpdateBannerInput)">
|
||||
<summary>
|
||||
更新轮播图
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:YD_Event.Application.Banner.BannerService.Delete(System.Collections.Generic.List{System.Int64})">
|
||||
<summary>
|
||||
删除轮播图
|
||||
</summary>
|
||||
<param name="ids"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:YD_Event.Application.Banner.Dtos.AddBannerInput">
|
||||
<summary>
|
||||
添加轮播图输入参数
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Banner.Dtos.AddBannerInput.Title">
|
||||
<summary>
|
||||
标题
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Banner.Dtos.AddBannerInput.ImageUrl">
|
||||
<summary>
|
||||
图片地址
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Banner.Dtos.AddBannerInput.LinkType">
|
||||
<summary>
|
||||
跳转链接类型(0-图片/无跳转 1-赛事)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Banner.Dtos.AddBannerInput.LinkTarget">
|
||||
<summary>
|
||||
跳转目标(赛事ID或URL)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Banner.Dtos.AddBannerInput.Sort">
|
||||
<summary>
|
||||
排序
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Banner.Dtos.AddBannerInput.Remark">
|
||||
<summary>
|
||||
备注
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:YD_Event.Application.Banner.Dtos.UpdateBannerInput">
|
||||
<summary>
|
||||
更新轮播图输入参数
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Banner.Dtos.UpdateBannerInput.Id">
|
||||
<summary>
|
||||
Id
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Banner.Dtos.UpdateBannerInput.Status">
|
||||
<summary>
|
||||
状态
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:YD_Event.Application.Banner.Dtos.BannerQueryInput">
|
||||
<summary>
|
||||
轮播图查询参数
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Banner.Dtos.BannerQueryInput.Title">
|
||||
<summary>
|
||||
标题
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:YD_Event.Application.Banner.Dtos.BannerOutput">
|
||||
<summary>
|
||||
轮播图输出参数
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:YD_Event.Application.Banner.Dtos.BannerConfigInput">
|
||||
<summary>
|
||||
轮播图配置输入参数
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Banner.Dtos.BannerConfigInput.Mode">
|
||||
<summary>
|
||||
模式(0-手动配置 1-自动配置)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:YD_Event.Application.Banner.Dtos.BannerConfigOutput">
|
||||
<summary>
|
||||
轮播图配置输出参数
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:YD_Event.Application.BaseService`1.Delete(YD_Event.Core.Shared.KeyDto)">
|
||||
<summary>
|
||||
删除信息
|
||||
@ -1810,24 +1942,6 @@
|
||||
退款配置输出参数
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:YD_Event.Application.Setting.IRefundConfigService">
|
||||
<summary>
|
||||
退款配置服务接口
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:YD_Event.Application.Setting.IRefundConfigService.GetConfig">
|
||||
<summary>
|
||||
获取退款配置
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:YD_Event.Application.Setting.IRefundConfigService.UpdateConfig(YD_Event.Application.Setting.Dtos.RefundConfigInput)">
|
||||
<summary>
|
||||
更新退款配置
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:YD_Event.Application.Setting.RefundConfigService">
|
||||
<summary>
|
||||
退款配置服务
|
||||
|
||||
74
YD_Event.Core/Entities/Banner.cs
Normal file
74
YD_Event.Core/Entities/Banner.cs
Normal file
@ -0,0 +1,74 @@
|
||||
using SqlSugar;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using YD_Event.Core.Enum;
|
||||
|
||||
namespace YD_Event.Core.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 轮播图配置
|
||||
/// </summary>
|
||||
[SugarTable("Banner")]
|
||||
public class Banner : Entity<long>, ICreatedTime, IUpdatedTime, ISoftDelete, IAvailability, ISortable
|
||||
{
|
||||
/// <summary>
|
||||
/// 标题
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "标题", Length = 128, IsNullable = true)]
|
||||
public string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 图片地址
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "图片地址", Length = 512)]
|
||||
[Required, MaxLength(512)]
|
||||
public string ImageUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 跳转链接类型(0-图片/无跳转 1-赛事)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "跳转链接类型")]
|
||||
public int LinkType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 跳转目标(赛事ID或URL)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "跳转目标", Length = 512, IsNullable = true)]
|
||||
public string LinkTarget { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "排序")]
|
||||
public int Sort { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 状态(0-启用 1-禁用)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "状态")]
|
||||
public AvailabilityStatus Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "备注", Length = 256, IsNullable = true)]
|
||||
public string Remark { get; set; }
|
||||
|
||||
public DateTime CreatedTime { get; set; }
|
||||
public DateTime? UpdatedTime { get; set; }
|
||||
public bool DeleteMark { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 轮播图设置(存储手动/自动模式)
|
||||
/// </summary>
|
||||
[SugarTable("BannerConfig")]
|
||||
public class BannerConfig : Entity<long>, IUpdatedTime
|
||||
{
|
||||
/// <summary>
|
||||
/// 模式(0-手动配置 1-自动配置)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "模式(0-手动配置 1-自动配置)")]
|
||||
public int Mode { get; set; }
|
||||
|
||||
public DateTime? UpdatedTime { get; set; }
|
||||
}
|
||||
@ -499,6 +499,56 @@
|
||||
创建时间
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:YD_Event.Core.Entities.Banner">
|
||||
<summary>
|
||||
轮播图配置
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Core.Entities.Banner.Title">
|
||||
<summary>
|
||||
标题
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Core.Entities.Banner.ImageUrl">
|
||||
<summary>
|
||||
图片地址
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Core.Entities.Banner.LinkType">
|
||||
<summary>
|
||||
跳转链接类型(0-图片/无跳转 1-赛事)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Core.Entities.Banner.LinkTarget">
|
||||
<summary>
|
||||
跳转目标(赛事ID或URL)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Core.Entities.Banner.Sort">
|
||||
<summary>
|
||||
排序
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Core.Entities.Banner.Status">
|
||||
<summary>
|
||||
状态(0-启用 1-禁用)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Core.Entities.Banner.Remark">
|
||||
<summary>
|
||||
备注
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:YD_Event.Core.Entities.BannerConfig">
|
||||
<summary>
|
||||
轮播图设置(存储手动/自动模式)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Core.Entities.BannerConfig.Mode">
|
||||
<summary>
|
||||
模式(0-手动配置 1-自动配置)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:YD_Event.Core.Entities.Categories">
|
||||
<summary>
|
||||
文章栏目表
|
||||
|
||||
@ -1,75 +0,0 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user