Add admin REST API endpoints for backoffice operations#189
Add admin REST API endpoints for backoffice operations#189
Conversation
Extract backoffice features from Blazor dashboard into REST API controllers: - AdminSeasonController: CRUD seasons, adjust end blocks - AdminPolicyController: manage battle/refresh ticket policies - AdminReviewController: review unconfirmed battles and ticket purchases - AdminPreparationController: season init, round prep, ranking cache - AdminLeaderboardController: leaderboard data and CSV export All endpoints require Admin role authentication. Includes unit tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
BackOffice(Blazor)에서만 가능했던 관리 기능을 Admin 전용 REST API로 노출해 운영/관리 작업을 HTTP 기반으로 수행할 수 있게 하는 PR입니다.
Changes:
- Admin 전용 REST 컨트롤러 5개 추가(시즌/정책/리뷰/준비/리더보드) 및
[Authorize(Roles="Admin")]적용 - 누락된 서비스/리포지토리 DI 등록 추가
- Admin 컨트롤러 단위 테스트 5개 파일(총 25 케이스) 추가
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| ArenaService/Setup.cs | Admin API에 필요한 서비스/리포지토리 DI 등록 추가 |
| ArenaService/Controllers/AdminSeasonController.cs | 시즌 CRUD + 종료 블록 조정 Admin API 추가 |
| ArenaService/Controllers/AdminPolicyController.cs | 배틀/리프레시 티켓 정책 조회/생성 Admin API 추가 |
| ArenaService/Controllers/AdminReviewController.cs | 미검토 항목 조회 및 리뷰 확정 Admin API 추가 |
| ArenaService/Controllers/AdminPreparationController.cs | 시즌 초기화/다음 라운드 준비/랭킹 캐시 초기화 Admin API 추가 |
| ArenaService/Controllers/AdminLeaderboardController.cs | 시즌 리더보드 조회 및 CSV 다운로드 Admin API 추가 |
| ArenaService.Tests/Controllers/AdminSeasonControllerTests.cs | AdminSeasonController 단위 테스트 추가 |
| ArenaService.Tests/Controllers/AdminPolicyControllerTests.cs | AdminPolicyController 단위 테스트 추가 |
| ArenaService.Tests/Controllers/AdminReviewControllerTests.cs | AdminReviewController 단위 테스트 추가 |
| ArenaService.Tests/Controllers/AdminPreparationControllerTests.cs | AdminPreparationController 단위 테스트 추가 |
| ArenaService.Tests/Controllers/AdminLeaderboardControllerTests.cs | AdminLeaderboardController 단위 테스트 추가 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Move all admin request DTOs to ArenaService.Shared/Dtos/AdminRequests.cs with validation attributes ([Required], [Range]) - Add GET by ID endpoints for battle-ticket and refresh-ticket policies, fix CreatedAtAction to reference correct routes - DeleteSeason now fetches currentBlockIndex from ISeasonCacheRepository instead of relying on client-supplied value - ConfirmTicketPurchase validates type parameter (case-insensitive), returns 400 for invalid values - GetUnreviewedTicketPurchases uses Task.WhenAll for parallel queries - Leaderboard addresses now use ToLower() for consistency - Add tests for invalid ticket type, case-insensitive type, policy GET by ID Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
BackOffice(Blazor)에서만 가능했던 관리 기능을 ArenaService에 Admin 전용 REST API로 노출하여, 시즌/정책/리뷰/준비/리더보드 운영 작업을 HTTP 기반으로 수행할 수 있게 하는 PR입니다.
Changes:
- Admin 전용 컨트롤러 5개 추가 및
[Authorize(Roles = "Admin")]적용 - Admin 요청 DTO를 Shared 레이어로 분리하고(DataAnnotations) 모델 바인딩 검증 추가
- 누락된 DI 등록 보완 및 컨트롤러 단위 테스트(총 25개) 추가
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| ArenaService/Setup.cs | Admin 컨트롤러가 사용하는 서비스/리포지토리 DI 등록 추가 |
| ArenaService/Controllers/AdminSeasonController.cs | 시즌 CRUD 및 end-block 조정 Admin API 추가 |
| ArenaService/Controllers/AdminPolicyController.cs | 배틀/리프레시 티켓 정책 조회/생성(+ by-id 조회) Admin API 추가 |
| ArenaService/Controllers/AdminReviewController.cs | 미검토 배틀/구매 로그 조회 및 confirm Admin API 추가 |
| ArenaService/Controllers/AdminPreparationController.cs | 시즌 초기화/다음 라운드 준비/랭킹 캐시 초기화 Admin API 추가 |
| ArenaService/Controllers/AdminLeaderboardController.cs | 리더보드 조회 및 CSV 다운로드 Admin API 추가 |
| ArenaService.Shared/Dtos/AdminRequests.cs | Admin API 요청 DTO 및 검증 어노테이션 추가 |
| ArenaService.Tests/Controllers/AdminSeasonControllerTests.cs | AdminSeasonController 단위 테스트 추가 |
| ArenaService.Tests/Controllers/AdminPolicyControllerTests.cs | AdminPolicyController 단위 테스트 추가 |
| ArenaService.Tests/Controllers/AdminReviewControllerTests.cs | AdminReviewController 단위 테스트 추가 |
| ArenaService.Tests/Controllers/AdminPreparationControllerTests.cs | AdminPreparationController 단위 테스트 추가 |
| ArenaService.Tests/Controllers/AdminLeaderboardControllerTests.cs | AdminLeaderboardController 단위 테스트 추가 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Return SeasonResponse DTO instead of EF entities to avoid cyclic reference serialization errors (GetSeason, UpdateSeason, AdjustEndBlock, CreateSeason) - Add checked overflow validation for RoundInterval * RoundCount - Validate PurchasePrices.Count matches max purchasable limits for both battle and refresh ticket policies - Add missing tests: UpdateSeason NotFound, AdjustEndBlock NotFound, CreateSeason overflow, RefreshTicketPolicy NotFound, battle/refresh policy price mismatch validation Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR extracts backoffice-only administrative operations into REST endpoints in ArenaService, reusing existing Shared-layer services/repositories and adding unit tests for the new controllers.
Changes:
- Added 5 new admin controllers under
/admin/*with[Authorize(Roles = "Admin")]. - Added shared admin request DTOs with validation attributes.
- Registered missing DI bindings and introduced controller unit tests (36 cases as described).
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| ArenaService/Setup.cs | Adds DI registrations for new admin-related services and repositories. |
| ArenaService/Controllers/AdminSeasonController.cs | CRUD + end-block adjustment endpoints for seasons. |
| ArenaService/Controllers/AdminPolicyController.cs | CRUD-style reads + create endpoints for battle/refresh ticket policies. |
| ArenaService/Controllers/AdminReviewController.cs | Endpoints to list unreviewed items and confirm reviews. |
| ArenaService/Controllers/AdminPreparationController.cs | Endpoints to initialize season / prepare next round / initialize ranking cache. |
| ArenaService/Controllers/AdminLeaderboardController.cs | Admin leaderboard query and CSV download endpoints. |
| ArenaService.Shared/Dtos/AdminRequests.cs | Adds admin request DTOs and attempts to apply validation. |
| ArenaService.Tests/Controllers/AdminSeasonControllerTests.cs | Unit tests for AdminSeasonController. |
| ArenaService.Tests/Controllers/AdminPolicyControllerTests.cs | Unit tests for AdminPolicyController. |
| ArenaService.Tests/Controllers/AdminReviewControllerTests.cs | Unit tests for AdminReviewController. |
| ArenaService.Tests/Controllers/AdminPreparationControllerTests.cs | Unit tests for AdminPreparationController. |
| ArenaService.Tests/Controllers/AdminLeaderboardControllerTests.cs | Unit tests for AdminLeaderboardController. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- DeleteSeason: catch InvalidOperationException for non-existent season, return 404 - AdjustEndBlock: validate NewEndBlock >= season.StartBlock, return 400 - CreateSeason: fix unused variable warning with discard (_) - DTO: replace ineffective [Required] on value types with [Range], add [EnumDataType] for ArenaType, [MinLength(1)] for PurchasePrices - Add tests: DeleteSeason NotFound, AdjustEndBlock below start block Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR extracts backoffice-only admin operations into REST APIs by introducing admin controllers that reuse the existing Shared service/repository layer, along with request DTOs, DI registrations, and unit tests.
Changes:
- Added 5 new
Admin*ControllerREST endpoints under/admin/*with role-based authorization. - Introduced admin request DTOs with validation attributes in the shared DTO layer.
- Registered missing DI services/repositories and added controller unit tests.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| ArenaService/Setup.cs | Registers newly required services/repositories for the admin endpoints. |
| ArenaService/Controllers/AdminSeasonController.cs | Admin CRUD + end-block adjustment endpoints for seasons. |
| ArenaService/Controllers/AdminPolicyController.cs | Admin read/create endpoints for battle/refresh ticket policies. |
| ArenaService/Controllers/AdminReviewController.cs | Admin endpoints for unreviewed battle/ticket-purchase review confirmation. |
| ArenaService/Controllers/AdminPreparationController.cs | Admin endpoints for season init / next-round prep / ranking cache init. |
| ArenaService/Controllers/AdminLeaderboardController.cs | Admin leaderboard read + CSV download endpoints. |
| ArenaService.Shared/Dtos/AdminRequests.cs | Shared admin request DTOs with data-annotations validation. |
| ArenaService.Tests/Controllers/AdminSeasonControllerTests.cs | Unit tests for admin season endpoints. |
| ArenaService.Tests/Controllers/AdminPolicyControllerTests.cs | Unit tests for admin policy endpoints. |
| ArenaService.Tests/Controllers/AdminReviewControllerTests.cs | Unit tests for admin review endpoints. |
| ArenaService.Tests/Controllers/AdminPreparationControllerTests.cs | Unit tests for admin preparation endpoints. |
| ArenaService.Tests/Controllers/AdminLeaderboardControllerTests.cs | Unit tests for admin leaderboard endpoints. |
| .claude/scheduled_tasks.lock | Adds a tool lockfile (should not be committed). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Return admin-specific DTOs instead of EF entities in review endpoints (AdminBattleReviewResponse, AdminTicketPurchaseReviewResponse) - Use AdminLeaderboardEntryResponse DTO with Swagger type annotation - Fix int overflow in SeasonRepository.AddSeasonWithRoundsAsync by casting to long before multiplication - Remove accidentally committed .claude/scheduled_tasks.lock - Add .gitignore entry for scheduled_tasks.lock Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR extracts several BackOffice-only admin operations into REST endpoints under /admin/*, secured via role-based authorization, while reusing existing Shared services/repositories and adding unit test coverage for the new controllers.
Changes:
- Added 5 new Admin controllers exposing season CRUD, policy CRUD, review confirmation, preparation operations, and leaderboard retrieval/CSV download.
- Introduced shared Admin request/response DTOs with validation attributes.
- Updated DI registrations and fixed a season end-block overflow hazard in
SeasonRepository.
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| ArenaService/Setup.cs | Registers new admin-facing services/repositories in DI. |
| ArenaService/Controllers/AdminSeasonController.cs | Adds season create/read/update/delete + end-block adjustment endpoints. |
| ArenaService/Controllers/AdminPolicyController.cs | Adds battle/refresh ticket policy list/detail/create endpoints. |
| ArenaService/Controllers/AdminReviewController.cs | Adds unreviewed listings + confirm endpoints for battles and ticket purchases. |
| ArenaService/Controllers/AdminPreparationController.cs | Adds season init / next-round prep / ranking-cache init endpoints. |
| ArenaService/Controllers/AdminLeaderboardController.cs | Adds leaderboard retrieval + CSV download endpoints. |
| ArenaService.Tests/Controllers/AdminSeasonControllerTests.cs | Unit tests for AdminSeasonController behaviors. |
| ArenaService.Tests/Controllers/AdminPolicyControllerTests.cs | Unit tests for policy endpoints and validations. |
| ArenaService.Tests/Controllers/AdminReviewControllerTests.cs | Unit tests for review listing/confirm + type validation. |
| ArenaService.Tests/Controllers/AdminPreparationControllerTests.cs | Unit tests for preparation endpoints and error paths. |
| ArenaService.Tests/Controllers/AdminLeaderboardControllerTests.cs | Unit tests for leaderboard + CSV download. |
| ArenaService.Shared/Repositories/SeasonRepository.cs | Prevents int multiplication overflow when computing season end block. |
| ArenaService.Shared/Dtos/AdminRequests.cs | New validated request DTOs for admin endpoints. |
| ArenaService.Shared/Dtos/AdminResponses.cs | New response DTOs for admin review/leaderboard endpoints. |
| .gitignore | Ignores a Claude lock file. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Change MaxPurchasableTicketsPerSeason/PerRound range to start at 1 to align with PurchasePrices [MinLength(1)] constraint - Remove unused `using Libplanet.Crypto` from AdminResponses.cs Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR extracts backoffice-only admin operations into REST endpoints under /admin/*, reusing the existing Shared services/repositories and adding unit tests to cover the new controller behaviors.
Changes:
- Added 5 Admin controllers exposing season CRUD, policy management, review confirmation, preparation operations, and leaderboard retrieval/CSV download (all Admin-role authorized).
- Introduced shared Admin request/response DTOs (with validation) and adjusted DI registrations to wire required services/repositories.
- Added controller unit tests to validate success/error paths across the new endpoints.
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| ArenaService/Setup.cs | Registers new admin-related services and policy repositories in DI. |
| ArenaService/Controllers/AdminSeasonController.cs | Adds REST endpoints for season CRUD + end-block adjustment. |
| ArenaService/Controllers/AdminReviewController.cs | Adds endpoints to list/confirm unreviewed battles and ticket purchases. |
| ArenaService/Controllers/AdminPreparationController.cs | Adds endpoints to initialize season/round and ranking cache. |
| ArenaService/Controllers/AdminPolicyController.cs | Adds endpoints to list/get/create battle & refresh ticket policies. |
| ArenaService/Controllers/AdminLeaderboardController.cs | Adds leaderboard retrieval and CSV download endpoints. |
| ArenaService.Tests/Controllers/AdminSeasonControllerTests.cs | Unit tests for AdminSeason controller behaviors. |
| ArenaService.Tests/Controllers/AdminReviewControllerTests.cs | Unit tests for AdminReview controller behaviors. |
| ArenaService.Tests/Controllers/AdminPreparationControllerTests.cs | Unit tests for AdminPreparation controller behaviors. |
| ArenaService.Tests/Controllers/AdminPolicyControllerTests.cs | Unit tests for AdminPolicy controller behaviors. |
| ArenaService.Tests/Controllers/AdminLeaderboardControllerTests.cs | Unit tests for AdminLeaderboard controller behaviors. |
| ArenaService.Shared/Repositories/SeasonRepository.cs | Adjusts end-block calculation to avoid int multiplication overflow. |
| ArenaService.Shared/Dtos/AdminResponses.cs | Adds DTOs for admin review and leaderboard responses. |
| ArenaService.Shared/Dtos/AdminRequests.cs | Adds admin request DTOs with validation attributes. |
| .gitignore | Ignores .claude/scheduled_tasks.lock. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Replace .Result with await for Task.WhenAll pattern - Use named DTOs: AdminTicketPurchaseReviewListResponse, AdminPreparationResponse with Swagger type annotations - Separate try/catch in CreateSeason to distinguish overlap vs reload errors - Fix overflow error message to be accurate - Add checked block in SeasonRepository.AddSeasonWithRoundsAsync Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Extracts BackOffice-only admin operations into authenticated REST endpoints (/admin/*) while reusing existing Shared services/repositories, and adds unit tests to cover the new controllers.
Changes:
- Added 5 admin controllers for season CRUD, policy management, review confirmation, preparation tasks, and leaderboard/CSV download (all admin-role authorized).
- Introduced shared admin request/response DTOs with validation, plus missing DI registrations for new services/repositories.
- Added controller unit tests and hardened season end-block computation against overflow (controller + repository).
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| ArenaService/Setup.cs | Registers newly used services and policy repositories for the admin controllers. |
| ArenaService/Controllers/AdminSeasonController.cs | Adds admin season CRUD + end-block adjustment endpoints. |
| ArenaService/Controllers/AdminReviewController.cs | Adds admin review list/confirm endpoints (battle + ticket purchase). |
| ArenaService/Controllers/AdminPreparationController.cs | Adds admin endpoints for season/round prep and ranking cache init. |
| ArenaService/Controllers/AdminPolicyController.cs | Adds admin endpoints to list/get/create battle/refresh ticket policies. |
| ArenaService/Controllers/AdminLeaderboardController.cs | Adds admin endpoints to fetch leaderboard and download CSV. |
| ArenaService.Tests/Controllers/AdminSeasonControllerTests.cs | Unit tests for AdminSeasonController behaviors. |
| ArenaService.Tests/Controllers/AdminReviewControllerTests.cs | Unit tests for AdminReviewController behaviors. |
| ArenaService.Tests/Controllers/AdminPreparationControllerTests.cs | Unit tests for AdminPreparationController behaviors. |
| ArenaService.Tests/Controllers/AdminPolicyControllerTests.cs | Unit tests for AdminPolicyController behaviors. |
| ArenaService.Tests/Controllers/AdminLeaderboardControllerTests.cs | Unit tests for AdminLeaderboardController behaviors. |
| ArenaService.Shared/Repositories/SeasonRepository.cs | Uses checked arithmetic for end-block computation to prevent overflow. |
| ArenaService.Shared/Dtos/AdminResponses.cs | Adds response DTOs for admin endpoints. |
| ArenaService.Shared/Dtos/AdminRequests.cs | Adds request DTOs + validation annotations for admin endpoints. |
| .gitignore | Ignores Claude scheduled task lock file. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| public class InitializeSeasonRequest | ||
| { | ||
| [Range(0, long.MaxValue)] | ||
| public long BlockIndex { get; set; } | ||
| } |
| public class PrepareNextRoundRequest | ||
| { | ||
| [Range(0, long.MaxValue)] | ||
| public long BlockIndex { get; set; } | ||
| } |
…ssues Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
BackOffice Blazor 대시보드에서만 수행하던 운영/관리 기능을 Admin 전용 REST API로 분리해 외부 도구/자동화에서 사용할 수 있게 확장하는 PR입니다.
Changes:
- Admin 전용 컨트롤러 5개 추가(시즌/정책/리뷰/준비/리더보드) 및 신규 엔드포인트 제공
- Admin 요청/응답 DTO 추가 및 시즌 생성 블록 계산 오버플로 방지 로직 반영
- 누락된 DI 등록 추가 및 컨트롤러 단위 테스트 추가
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| ArenaService/Setup.cs | 신규 Admin 기능에서 사용하는 서비스/리포지토리 DI 등록 추가 |
| ArenaService/Controllers/AdminSeasonController.cs | 시즌 CRUD 및 end-block 조정 Admin API 추가 |
| ArenaService/Controllers/AdminPolicyController.cs | 배틀/리프레시 티켓 정책 조회/생성 Admin API 추가 |
| ArenaService/Controllers/AdminReviewController.cs | 미검토 배틀/구매 목록 조회 및 confirm 처리 Admin API 추가 |
| ArenaService/Controllers/AdminPreparationController.cs | 시즌 초기화/다음 라운드 준비/랭킹 캐시 초기화 Admin API 추가 |
| ArenaService/Controllers/AdminLeaderboardController.cs | 리더보드 조회 및 CSV 다운로드 Admin API 추가 |
| ArenaService.Shared/Repositories/SeasonRepository.cs | 시즌 end block 계산에서 checked 오버플로 방지 적용 |
| ArenaService.Shared/Dtos/AdminRequests.cs | Admin 요청 DTO 및 validation attributes 추가 |
| ArenaService.Shared/Dtos/AdminResponses.cs | Admin 응답 DTO 추가 |
| ArenaService.Tests/Controllers/AdminSeasonControllerTests.cs | AdminSeasonController 단위 테스트 추가 |
| ArenaService.Tests/Controllers/AdminPolicyControllerTests.cs | AdminPolicyController 단위 테스트 추가 |
| ArenaService.Tests/Controllers/AdminReviewControllerTests.cs | AdminReviewController 단위 테스트 추가 |
| ArenaService.Tests/Controllers/AdminPreparationControllerTests.cs | AdminPreparationController 단위 테스트 추가 |
| ArenaService.Tests/Controllers/AdminLeaderboardControllerTests.cs | AdminLeaderboardController 단위 테스트 추가 |
| .gitignore | Claude 관련 lock 파일 ignore 추가 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
[Authorize(Roles = "Admin")]적용)New Endpoints
/admin/seasons/admin/seasons/{id}/admin/seasons/{id}/admin/seasons/{id}/admin/seasons/{id}/end-block/admin/policies/battle-ticket/admin/policies/battle-ticket/{id}/admin/policies/battle-ticket/admin/policies/refresh-ticket/admin/policies/refresh-ticket/{id}/admin/policies/refresh-ticket/admin/reviews/battles/admin/reviews/ticket-purchases/admin/reviews/battles/{id}/confirm/admin/reviews/ticket-purchases/{id}/confirm/admin/preparation/season/initialize/admin/preparation/round/prepare-next/admin/preparation/ranking-cache/initialize/admin/leaderboard/{seasonId}/admin/leaderboard/{seasonId}/csvChanges
ArenaService/Controllers/Admin*.cs- 5개 신규 컨트롤러ArenaService.Shared/Dtos/AdminRequests.cs- Admin 요청 DTO (validation 포함)ArenaService/Setup.cs- 누락된 DI 등록 추가ArenaService.Tests/Controllers/Admin*Tests.cs- 5개 테스트 파일 (36 테스트 케이스)Review feedback addressed
Test plan
🤖 Generated with Claude Code