From 34e85c1fa0a30b5a7eeaa8a76a1a38848331627f Mon Sep 17 00:00:00 2001 From: bbungjin Date: Wed, 21 Jan 2026 18:20:41 +0900 Subject: [PATCH 1/3] feat: admin report search return type update --- .../controller/response/ReportGameDetailResponseDto.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/core-api/src/main/java/org/ject/recreation/core/api/controller/response/ReportGameDetailResponseDto.java b/core/core-api/src/main/java/org/ject/recreation/core/api/controller/response/ReportGameDetailResponseDto.java index e51592c..24eeb86 100644 --- a/core/core-api/src/main/java/org/ject/recreation/core/api/controller/response/ReportGameDetailResponseDto.java +++ b/core/core-api/src/main/java/org/ject/recreation/core/api/controller/response/ReportGameDetailResponseDto.java @@ -17,11 +17,14 @@ public class ReportGameDetailResponseDto { private String gameTitle; private String makerNickname; private String makerEmail; + private boolean isMakerBlock; + private ReportStatus status; private int questionCount; private long version; private List qustions; private String reporterEmail; private String reporterNickname; + private boolean isReporterBlock; private GameReportReason reasonCode; public static ReportGameDetailResponseDto from(ReportEntity reportEntity) { @@ -47,11 +50,14 @@ public static ReportGameDetailResponseDto from(ReportEntity reportEntity) { .gameTitle(game.getGameTitle()) .makerNickname(gameCreator.getNickname()) .makerEmail(gameCreator.getEmail()) + .isMakerBlock(gameCreator.getBlockReason() != null) + .status(reportEntity.getStatus()) .questionCount(game.getQuestionCount()) .version(game.getVersion()) .qustions(list) .reporterEmail(reporter != null ? reporter.getEmail() : null) .reporterNickname(reporter != null ? reporter.getNickname() : null) + .isReporterBlock(reporter.getBlockReason() != null) .reasonCode(gameReportReason) .build(); } From 727af8462f9285b5bbcc371876a67ac7ba8c4244 Mon Sep 17 00:00:00 2001 From: bbungjin Date: Wed, 28 Jan 2026 17:36:22 +0900 Subject: [PATCH 2/3] fix: ReportGameDetail NPE --- .../controller/response/ReportGameDetailResponseDto.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/core-api/src/main/java/org/ject/recreation/core/api/controller/response/ReportGameDetailResponseDto.java b/core/core-api/src/main/java/org/ject/recreation/core/api/controller/response/ReportGameDetailResponseDto.java index 24eeb86..4e0c369 100644 --- a/core/core-api/src/main/java/org/ject/recreation/core/api/controller/response/ReportGameDetailResponseDto.java +++ b/core/core-api/src/main/java/org/ject/recreation/core/api/controller/response/ReportGameDetailResponseDto.java @@ -31,6 +31,7 @@ public static ReportGameDetailResponseDto from(ReportEntity reportEntity) { GameEntity game = reportEntity.getGame(); UserEntity gameCreator = game.getGameCreator(); UserEntity reporter = reportEntity.getReporter(); + List questions = game.getQuestions(); ReportReason reason = reportEntity.getReason(); @@ -46,18 +47,21 @@ public static ReportGameDetailResponseDto from(ReportEntity reportEntity) { question.getVersion())) .toList(); + boolean isMakerBlock = gameCreator.getBlockReason() != null; + boolean isReporterBlock = reporter != null && reporter.getBlockReason() != null; + return ReportGameDetailResponseDto.builder() .gameTitle(game.getGameTitle()) .makerNickname(gameCreator.getNickname()) .makerEmail(gameCreator.getEmail()) - .isMakerBlock(gameCreator.getBlockReason() != null) + .isMakerBlock(isMakerBlock) .status(reportEntity.getStatus()) .questionCount(game.getQuestionCount()) .version(game.getVersion()) .qustions(list) .reporterEmail(reporter != null ? reporter.getEmail() : null) .reporterNickname(reporter != null ? reporter.getNickname() : null) - .isReporterBlock(reporter.getBlockReason() != null) + .isReporterBlock(isReporterBlock) .reasonCode(gameReportReason) .build(); } From 6a6e7a1bd3ff3907b43dc0c7832de89e363b2073 Mon Sep 17 00:00:00 2001 From: bbungjin Date: Thu, 29 Jan 2026 18:31:03 +0900 Subject: [PATCH 3/3] feat: get admin's games --- .../core/api/controller/AdminController.java | 12 +++++++++- .../core/domain/admin/AdminService.java | 22 +++++++++++++++++++ .../storage/db/core/GameRepository.java | 5 +++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/core/core-api/src/main/java/org/ject/recreation/core/api/controller/AdminController.java b/core/core-api/src/main/java/org/ject/recreation/core/api/controller/AdminController.java index 4c52750..f3f5476 100644 --- a/core/core-api/src/main/java/org/ject/recreation/core/api/controller/AdminController.java +++ b/core/core-api/src/main/java/org/ject/recreation/core/api/controller/AdminController.java @@ -3,6 +3,7 @@ import lombok.extern.slf4j.Slf4j; import org.ject.recreation.core.api.controller.request.BlockUserRequestDto; import org.ject.recreation.core.api.controller.request.GameDeleteRequestDto; +import org.ject.recreation.core.api.controller.response.GameListResponseDto; import org.ject.recreation.core.api.controller.response.GetAllUserResponseDto; import org.ject.recreation.core.api.controller.response.ReportGameDetailResponseDto; import org.ject.recreation.core.api.controller.response.ReportGameResponseDto; @@ -28,6 +29,7 @@ public ApiResponse> getReportGames( return ApiResponse.success(adminService.getReportedGames(page)); } + // report 상세 내역 조회 @GetMapping("games/{reportId}") public ApiResponse getReportGame( @PathVariable Long reportId @@ -40,6 +42,14 @@ public ApiResponse deleteReportGame(@RequestBody GameDeleteRequestDto game return ApiResponse.success(adminService.deleteReportedDetailGames(gameDeleteRequestDto)); } + + @GetMapping("games/admin") + public ApiResponse> getAdminGames( + @RequestParam(defaultValue = "0") int page + ) { + return ApiResponse.success(adminService.getAdminGames(page)); + } + @GetMapping("/users") public ApiResponse> getUsers( @RequestParam(defaultValue = "0") int page @@ -53,7 +63,7 @@ public ApiResponse blockUser(@RequestBody BlockUserRequestDto blockUserReq } @PostMapping("/users/unblock") - public ApiResponse unBlockUser(@RequestBody BlockUserRequestDto blockUserRequestDto){ + public ApiResponse unBlockUser(@RequestBody BlockUserRequestDto blockUserRequestDto) { return ApiResponse.success(adminService.unBlockUser(blockUserRequestDto)); } } diff --git a/core/core-api/src/main/java/org/ject/recreation/core/domain/admin/AdminService.java b/core/core-api/src/main/java/org/ject/recreation/core/domain/admin/AdminService.java index ef94cee..64b7eb6 100644 --- a/core/core-api/src/main/java/org/ject/recreation/core/domain/admin/AdminService.java +++ b/core/core-api/src/main/java/org/ject/recreation/core/domain/admin/AdminService.java @@ -3,6 +3,7 @@ import lombok.RequiredArgsConstructor; import org.ject.recreation.core.api.controller.request.BlockUserRequestDto; import org.ject.recreation.core.api.controller.request.GameDeleteRequestDto; +import org.ject.recreation.core.api.controller.response.GameListResponseDto; import org.ject.recreation.core.api.controller.response.GetAllUserResponseDto; import org.ject.recreation.core.api.controller.response.ReportGameDetailResponseDto; import org.ject.recreation.core.api.controller.response.ReportGameResponseDto; @@ -10,6 +11,7 @@ import org.ject.recreation.core.support.error.ErrorType; import org.ject.recreation.core.support.response.PageResponseDto; import org.ject.recreation.storage.db.core.*; +import org.springframework.context.support.BeanDefinitionDsl; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -27,9 +29,11 @@ public class AdminService { private final ReportRepository reportRepository; private final UserRepository userRepository; + private final GameRepository gameRepository; public PageResponseDto getReportedGames(int page) { Pageable pageable = PageRequest.of(page, 7); +// BeanDefinitionDsl.Role // return reportRepository.findAllForAdmin(pageable) // .map(ReportGameResponseDto::from); Page result = @@ -67,6 +71,24 @@ public PageResponseDto getAllUsers(int page) { return PageResponseDto.of(result); } + public PageResponseDto getAdminGames(int page) { + Pageable pageable = PageRequest.of(page, 7); +// return reportRepository.findAllForAdmin(pageable) +// .map(ReportGameResponseDto::from); + Page allByAdmin = gameRepository.findAllByAdmin(pageable); + Page list = allByAdmin.map(game -> + GameListResponseDto.GameDto.builder() + .gameId(game.getGameId()) + .gameThumbnailUrl(game.getGameThumbnailUrl()) + .gameTitle(game.getGameTitle()) + .questionCount(game.getQuestionCount()) + .playCount(game.getPlayCount()) + .updatedAt(game.getUpdatedAt()) + .build() + ); + return PageResponseDto.of(list); + } + public Void blockUser(BlockUserRequestDto blockUserRequestDto) { List emailList = blockUserRequestDto.getBanList().stream() .map(BlockUserRequestDto.UserBanItem::getEmail) diff --git a/storage/db-core/src/main/java/org/ject/recreation/storage/db/core/GameRepository.java b/storage/db-core/src/main/java/org/ject/recreation/storage/db/core/GameRepository.java index 62afd74..40c18dd 100644 --- a/storage/db-core/src/main/java/org/ject/recreation/storage/db/core/GameRepository.java +++ b/storage/db-core/src/main/java/org/ject/recreation/storage/db/core/GameRepository.java @@ -1,5 +1,6 @@ package org.ject.recreation.storage.db.core; +import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; @@ -50,4 +51,8 @@ List findGamesWithEmailAndCursor( // 기본 게임들을 조회하는 메서드 List findAllByGameCreatorEmailAndIsDeletedFalse(String gameCreatorEmail); + + @Query(value = "SELECT g FROM GameEntity g JOIN g.gameCreator u WHERE u.role = 'ADMIN'", + countQuery = "SELECT count(g) FROM GameEntity g JOIN g.gameCreator u WHERE u.role = 'ADMIN'") + Page findAllByAdmin( Pageable pageable); }