| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- using Web.Api.Common;
- using Web.Api.Extensions;
- using MediatR;
- namespace Web.Api.Endpoints.Studio.Donation;
- /// <summary>후원 알림 위젯 설정 (스튜디오 전용)</summary>
- internal sealed class DonationAlertConfig : IEndpoint
- {
- public void MapEndpoint(IEndpointRouteBuilder app)
- {
- /// 금액별 효과음, 이미지, 노출 시간 등 조회
- app.MapGet("api/studio/donation/alert/config/{channelID}", async (
- int channelID,
- ISender sender,
- CancellationToken ct
- ) => {
- var data = await sender.Send(new Application.Features.Api.DonationAlert.GetConfig.Query(channelID), ct);
- return ApiResponse.Ok(data);
- })
- .WithTags("StudioDonationAlert")
- .RequireAuthorization();
- /// 알림 설정 저장/수정
- app.MapPost("api/studio/donation/alert/config", async (
- Application.Features.Api.DonationAlert.SaveConfig.Command body,
- ISender sender,
- CancellationToken ct
- ) => {
- await sender.Send(body, ct);
- return ApiResponse.Ok();
- })
- .WithTags("StudioDonationAlert")
- .RequireAuthorization();
- /// 알림 설정 일괄 저장/삭제
- app.MapPost("api/studio/donation/alert/config/batch", async (
- Application.Features.Api.DonationAlert.BatchSaveConfig.Command body,
- ISender sender,
- CancellationToken ct
- ) => {
- await sender.Send(body, ct);
- return ApiResponse.Ok();
- })
- .WithTags("StudioDonationAlert")
- .RequireAuthorization();
- /// 알림 설정 삭제
- app.MapDelete("api/studio/donation/alert/config/{id}/{channelID}", async (
- int id,
- int channelID,
- ISender sender,
- CancellationToken ct
- ) => {
- await sender.Send(new Application.Features.Api.DonationAlert.DeleteConfig.Command(id, channelID), ct);
- return ApiResponse.Ok();
- })
- .WithTags("StudioDonationAlert")
- .RequireAuthorization();
- /// 알림 활성/비활성 토글
- app.MapPatch("api/studio/donation/alert/config/{id}/active", async (
- int id,
- ToggleActiveRequest body,
- ISender sender,
- CancellationToken ct
- ) => {
- var result = await sender.Send(new Application.Features.Api.DonationAlert.ToggleActive.Command(id, body.ChannelID, body.IsActive), ct);
- return result.Match(
- data => ApiResponse.Ok(data),
- CustomResults.Problem
- );
- })
- .WithTags("StudioDonationAlert")
- .RequireAuthorization();
- }
- public sealed record ToggleActiveRequest(int ChannelID, bool IsActive);
- }
|