CrewConfig.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System.Security.Claims;
  2. using MediatR;
  3. using Web.Api.Common;
  4. using Web.Api.Extensions;
  5. namespace Web.Api.Endpoints.Studio.Crew;
  6. /// <summary>크루 후원 설정 저장/수정 (스튜디오 전용)</summary>
  7. internal sealed class CrewConfig : IEndpoint
  8. {
  9. internal sealed record SaveRequest(
  10. int? ID,
  11. int ChannelID,
  12. string Name,
  13. string? Description,
  14. int? MinAmount,
  15. bool IsActive
  16. );
  17. public void MapEndpoint(IEndpointRouteBuilder app)
  18. {
  19. app.MapPost("api/studio/crew/save", async (
  20. SaveRequest body,
  21. ClaimsPrincipal user,
  22. ISender sender,
  23. CancellationToken ct
  24. ) => {
  25. var memberID = user.GetRequiredMemberID();
  26. var command = new Application.Features.Api.Crew.SaveCrew.Command(
  27. body.ID, body.ChannelID, memberID,
  28. body.Name, body.Description, body.MinAmount, body.IsActive
  29. );
  30. await sender.Send(command, ct);
  31. return ApiResponse.Ok();
  32. })
  33. .WithTags("StudioCrew")
  34. .RequireAuthorization();
  35. }
  36. }