DonationAlertConfig.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using Web.Api.Common;
  2. using MediatR;
  3. namespace Web.Api.Endpoints.Studio.Donation;
  4. /// <summary>후원 알림 위젯 설정 (스튜디오 전용)</summary>
  5. internal sealed class DonationAlertConfig : IEndpoint
  6. {
  7. public void MapEndpoint(IEndpointRouteBuilder app)
  8. {
  9. /// 금액별 효과음, 이미지, 노출 시간 등 조회
  10. app.MapGet("api/studio/donation/alert/config/{channelID}", async (
  11. int channelID,
  12. ISender sender,
  13. CancellationToken ct
  14. ) => {
  15. var data = await sender.Send(new Application.Features.Api.DonationAlert.GetConfig.Query(channelID), ct);
  16. return ApiResponse.Ok(data);
  17. })
  18. .WithTags("StudioDonationAlert")
  19. .RequireAuthorization();
  20. /// 알림 설정 저장/수정
  21. app.MapPost("api/studio/donation/alert/config", async (
  22. Application.Features.Api.DonationAlert.SaveConfig.Command body,
  23. ISender sender,
  24. CancellationToken ct
  25. ) => {
  26. await sender.Send(body, ct);
  27. return ApiResponse.Ok();
  28. })
  29. .WithTags("StudioDonationAlert")
  30. .RequireAuthorization();
  31. /// 알림 설정 일괄 저장/삭제
  32. app.MapPost("api/studio/donation/alert/config/batch", async (
  33. Application.Features.Api.DonationAlert.BatchSaveConfig.Command body,
  34. ISender sender,
  35. CancellationToken ct
  36. ) => {
  37. await sender.Send(body, ct);
  38. return ApiResponse.Ok();
  39. })
  40. .WithTags("StudioDonationAlert")
  41. .RequireAuthorization();
  42. /// 알림 설정 삭제
  43. app.MapDelete("api/studio/donation/alert/config/{id}/{channelID}", async (
  44. int id,
  45. int channelID,
  46. ISender sender,
  47. CancellationToken ct
  48. ) => {
  49. await sender.Send(new Application.Features.Api.DonationAlert.DeleteConfig.Command(id, channelID), ct);
  50. return ApiResponse.Ok();
  51. })
  52. .WithTags("StudioDonationAlert")
  53. .RequireAuthorization();
  54. }
  55. }