-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ [Feature] admin 댓글,방,노쇼 신고조회 api (#719)
- Loading branch information
Showing
12 changed files
with
349 additions
and
1 deletion.
There are no files selected for viewing
51 changes: 50 additions & 1 deletion
51
...ingpong-api/src/main/java/gg/party/api/admin/report/controller/ReportAdminController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,56 @@ | ||
package gg.pingpong.api.party.admin.report.controller; | ||
package gg.party.api.admin.report.controller; | ||
|
||
import javax.validation.Valid; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.ModelAttribute; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import gg.party.api.admin.report.controller.request.ReportPageReqDto; | ||
import gg.party.api.admin.report.controller.response.CommentReportListResDto; | ||
import gg.party.api.admin.report.controller.response.RoomReportListResDto; | ||
import gg.party.api.admin.report.controller.response.UserReportListResDto; | ||
import gg.party.api.admin.report.service.ReportAdminService; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/party/admin/reports") | ||
public class ReportAdminController { | ||
private final ReportAdminService reportAdminService; | ||
|
||
/** | ||
* 댓글 신고 전체 리스트 조회 | ||
* return 200 status code(성공 status) | ||
*/ | ||
@GetMapping("/comments") | ||
public ResponseEntity<CommentReportListResDto> getCommentReports( | ||
@ModelAttribute @Valid ReportPageReqDto reportPageReqDto) { | ||
CommentReportListResDto commentReportListResDto = reportAdminService.getCommentReports(reportPageReqDto); | ||
return ResponseEntity.ok(commentReportListResDto); | ||
} | ||
|
||
/** | ||
* 방 신고 전체 리스트 조회 | ||
* return 200 status code(성공 status) | ||
*/ | ||
@GetMapping("/rooms") | ||
public ResponseEntity<RoomReportListResDto> getRoomReports( | ||
@ModelAttribute @Valid ReportPageReqDto reportPageReqDto) { | ||
RoomReportListResDto roomReportListResDto = reportAdminService.getRoomReports(reportPageReqDto); | ||
return ResponseEntity.ok(roomReportListResDto); | ||
} | ||
|
||
/** | ||
* 노쇼 신고 전체 리스트 조회 | ||
* return 200 status code(성공 status) | ||
*/ | ||
@GetMapping("/users") | ||
public ResponseEntity<UserReportListResDto> getUserReports( | ||
@ModelAttribute @Valid ReportPageReqDto reportPageReqDto) { | ||
UserReportListResDto userReportListResDto = reportAdminService.getUserReports(reportPageReqDto); | ||
return ResponseEntity.ok(userReportListResDto); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...pong-api/src/main/java/gg/party/api/admin/report/controller/request/ReportPageReqDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package gg.party.api.admin.report.controller.request; | ||
|
||
import javax.validation.constraints.Max; | ||
import javax.validation.constraints.Min; | ||
import javax.validation.constraints.NotNull; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
public class ReportPageReqDto { | ||
@Min(value = 1) | ||
@NotNull | ||
private Integer page; | ||
|
||
@Min(value = 1) | ||
@Max(value = 30) | ||
private Integer size = 10; | ||
|
||
public ReportPageReqDto(Integer page, Integer size) { | ||
this.page = page; | ||
if (size == null) { | ||
this.size = 10; | ||
} else { | ||
this.size = size; | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...src/main/java/gg/party/api/admin/report/controller/response/CommentReportAdminResDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package gg.party.api.admin.report.controller.response; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import gg.data.party.CommentReport; | ||
import lombok.Getter; | ||
|
||
/** | ||
* 댓글 신고 dto | ||
*/ | ||
@Getter | ||
public class CommentReportAdminResDto { | ||
private Long id; | ||
private String reporterIntraId; | ||
private Long commentId; | ||
private Long roomId; | ||
private String message; | ||
private LocalDateTime createdAt; | ||
|
||
public CommentReportAdminResDto(CommentReport commentReport) { | ||
this.id = commentReport.getId(); | ||
this.reporterIntraId = commentReport.getReporter().getIntraId(); | ||
this.commentId = commentReport.getComment().getId(); | ||
this.roomId = commentReport.getRoom().getId(); | ||
this.message = commentReport.getMessage(); | ||
this.createdAt = commentReport.getCreatedAt(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
.../src/main/java/gg/party/api/admin/report/controller/response/CommentReportListResDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package gg.party.api.admin.report.controller.response; | ||
|
||
import java.util.List; | ||
|
||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED) | ||
@Getter | ||
public class CommentReportListResDto { | ||
private List<CommentReportAdminResDto> commentReportPageList; | ||
private int totalPages; | ||
|
||
public CommentReportListResDto(List<CommentReportAdminResDto> commentReportPageList, int totalPages) { | ||
this.commentReportPageList = commentReportPageList; | ||
this.totalPages = totalPages; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...pi/src/main/java/gg/party/api/admin/report/controller/response/RoomReportAdminResDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package gg.party.api.admin.report.controller.response; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import gg.data.party.RoomReport; | ||
import lombok.Getter; | ||
|
||
/** | ||
* 방 신고 dto | ||
*/ | ||
@Getter | ||
public class RoomReportAdminResDto { | ||
private Long id; | ||
private String reporterIntraId; | ||
private String reporteeIntraId; | ||
private Long roomId; | ||
private String message; | ||
private LocalDateTime createdAt; | ||
|
||
public RoomReportAdminResDto(RoomReport roomReport) { | ||
this.id = roomReport.getId(); | ||
this.reporterIntraId = roomReport.getReporter().getIntraId(); | ||
this.reporteeIntraId = roomReport.getReportee().getIntraId(); | ||
this.roomId = roomReport.getRoom().getId(); | ||
this.message = roomReport.getMessage(); | ||
this.createdAt = roomReport.getCreatedAt(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...api/src/main/java/gg/party/api/admin/report/controller/response/RoomReportListResDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package gg.party.api.admin.report.controller.response; | ||
|
||
import java.util.List; | ||
|
||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED) | ||
@Getter | ||
public class RoomReportListResDto { | ||
private List<RoomReportAdminResDto> roomReportPageList; | ||
private int totalPages; | ||
|
||
public RoomReportListResDto(List<RoomReportAdminResDto> roomReportPageList, int totalPages) { | ||
this.roomReportPageList = roomReportPageList; | ||
this.totalPages = totalPages; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...pi/src/main/java/gg/party/api/admin/report/controller/response/UserReportAdminResDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package gg.party.api.admin.report.controller.response; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import gg.data.party.UserReport; | ||
import lombok.Getter; | ||
|
||
/** | ||
* 노쇼 신고 dto | ||
*/ | ||
@Getter | ||
public class UserReportAdminResDto { | ||
private Long id; | ||
private String reporterIntraId; | ||
private String reporteeIntraId; | ||
private Long roomId; | ||
private String message; | ||
private LocalDateTime createdAt; | ||
|
||
public UserReportAdminResDto(UserReport userReport) { | ||
this.id = userReport.getId(); | ||
this.reporterIntraId = userReport.getReporter().getIntraId(); | ||
this.reporteeIntraId = userReport.getReportee().getIntraId(); | ||
this.roomId = userReport.getRoom().getId(); | ||
this.message = userReport.getMessage(); | ||
this.createdAt = userReport.getCreatedAt(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...api/src/main/java/gg/party/api/admin/report/controller/response/UserReportListResDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package gg.party.api.admin.report.controller.response; | ||
|
||
import java.util.List; | ||
|
||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED) | ||
@Getter | ||
public class UserReportListResDto { | ||
private List<UserReportAdminResDto> userReportPageList; | ||
private int totalPages; | ||
|
||
public UserReportListResDto(List<UserReportAdminResDto> userReportPageList, int totalPages) { | ||
this.userReportPageList = userReportPageList; | ||
this.totalPages = totalPages; | ||
} | ||
} |
92 changes: 92 additions & 0 deletions
92
gg-pingpong-api/src/main/java/gg/party/api/admin/report/service/ReportAdminService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package gg.party.api.admin.report.service; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.PageRequest; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.domain.Sort; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import gg.data.party.CommentReport; | ||
import gg.data.party.RoomReport; | ||
import gg.data.party.UserReport; | ||
import gg.party.api.admin.report.controller.request.ReportPageReqDto; | ||
import gg.party.api.admin.report.controller.response.CommentReportAdminResDto; | ||
import gg.party.api.admin.report.controller.response.CommentReportListResDto; | ||
import gg.party.api.admin.report.controller.response.RoomReportAdminResDto; | ||
import gg.party.api.admin.report.controller.response.RoomReportListResDto; | ||
import gg.party.api.admin.report.controller.response.UserReportAdminResDto; | ||
import gg.party.api.admin.report.controller.response.UserReportListResDto; | ||
import gg.repo.party.CommentReportRepository; | ||
import gg.repo.party.RoomReportRepository; | ||
import gg.repo.party.UserReportRepository; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class ReportAdminService { | ||
private final CommentReportRepository commentReportRepository; | ||
private final RoomReportRepository roomReportRepository; | ||
private final UserReportRepository userReportRepository; | ||
|
||
/** | ||
* 댓글 신고 전체 리스트를 조회한다 | ||
* | ||
* @return 전체 댓글 신고 리스트 (시간순 정렬) | ||
*/ | ||
@Transactional(readOnly = true) | ||
public CommentReportListResDto getCommentReports(ReportPageReqDto reportPageReqDto) { | ||
int page = reportPageReqDto.getPage(); | ||
int size = reportPageReqDto.getSize(); | ||
|
||
Pageable pageable = PageRequest.of(page - 1, size, Sort.by(Sort.Direction.DESC, "createdAt")); | ||
Page<CommentReport> commentReportPage = commentReportRepository.findAllWithFetchJoin(pageable); | ||
|
||
List<CommentReportAdminResDto> commentReportPageResDto = commentReportPage.getContent().stream() | ||
.map(CommentReportAdminResDto::new) | ||
.collect(Collectors.toList()); | ||
|
||
return new CommentReportListResDto(commentReportPageResDto, commentReportPage.getTotalPages()); | ||
} | ||
|
||
/** | ||
* 방 신고 전체 리스트를 조회한다 | ||
* @return 전체 방 신고 리스트 (시간순 정렬) | ||
*/ | ||
@Transactional(readOnly = true) | ||
public RoomReportListResDto getRoomReports(ReportPageReqDto reportPageReqDto) { | ||
int page = reportPageReqDto.getPage(); | ||
int size = reportPageReqDto.getSize(); | ||
|
||
Pageable pageable = PageRequest.of(page - 1, size, Sort.by(Sort.Direction.DESC, "createdAt")); | ||
Page<RoomReport> roomReportPage = roomReportRepository.findAllWithFetchJoin(pageable); | ||
|
||
List<RoomReportAdminResDto> roomReportPageResDto = roomReportPage.getContent().stream() | ||
.map(RoomReportAdminResDto::new) | ||
.collect(Collectors.toList()); | ||
|
||
return new RoomReportListResDto(roomReportPageResDto, roomReportPage.getTotalPages()); | ||
} | ||
|
||
/** | ||
* 노쇼 신고 전체 리스트를 조회한다 | ||
* @return 전체 노쇼 신고 리스트 (시간순 정렬) | ||
*/ | ||
@Transactional(readOnly = true) | ||
public UserReportListResDto getUserReports(ReportPageReqDto reportPageReqDto) { | ||
int page = reportPageReqDto.getPage(); | ||
int size = reportPageReqDto.getSize(); | ||
|
||
Pageable pageable = PageRequest.of(page - 1, size, Sort.by(Sort.Direction.DESC, "createdAt")); | ||
Page<UserReport> userReportPage = userReportRepository.findAllWithFetchJoin(pageable); | ||
|
||
List<UserReportAdminResDto> userReportPageResDto = userReportPage.getContent().stream() | ||
.map(UserReportAdminResDto::new) | ||
.collect(Collectors.toList()); | ||
|
||
return new UserReportListResDto(userReportPageResDto, userReportPage.getTotalPages()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
gg-repo/src/main/java/gg/repo/party/UserReportRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package gg.repo.party; | ||
|
||
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; | ||
|
||
import gg.data.party.UserReport; | ||
|
||
public interface UserReportRepository extends JpaRepository<UserReport, Long> { | ||
|
||
@Query(value = "SELECT ur FROM UserReport ur " | ||
+ "JOIN FETCH ur.reporter " | ||
+ "JOIN FETCH ur.reportee " | ||
+ "JOIN FETCH ur.room", | ||
countQuery = "SELECT count(ur) FROM UserReport ur") | ||
Page<UserReport> findAllWithFetchJoin(Pageable pageable); | ||
} |