-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ [Feature] admin 댓글,방,노쇼 신고조회 api #719
Merged
The head ref may contain hidden characters: "718-feature-admin-\uB313\uAE00,\uBC29,\uB178\uC1FC-\uC2E0\uACE0\uC870\uD68C"
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5846889
GameTemplate added
JaBeast ac0ef6f
[fix] null check fixed
JaBeast 0951760
[feature] report APIs added
JaBeast 4e69df3
[fix] resolve conflict
JaBeast 7e3256f
[fix] resolve conflict
JaBeast 77c8e40
[refactor] 주석 수정
JaBeast 1642f49
[refactor] 주석 수정
JaBeast 45d1cba
[fix] 페이징과 fetch join 추가
JaBeast e7be336
[fix] 체크 스타일 맞춤
JaBeast 09e1c20
Merge branch 'dev' into 718-feature-admin-댓글,방,노쇼-신고조회
JaBeast de23203
[fix] fetch join fixed by adding countQuery
JaBeast 3f0baf6
[fix] fetch join fixed by adding countQuery
JaBeast 4f11ed1
[fix] space deleted
JaBeast a9f6b93
[refactor] file rename
JaBeast File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
count query 는 필요 없을것 같은데 추가하신 이유가 있나요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pageable과 fetch join같이 쓰면 에러 뜹니다(같이 사용 불가). 그래서 query를 fetch join하는데 유효하게 만들기 위해서 사용했습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이때 join 이 내부적으로 inner join 으로 실행되는 것으로 아는데, join 후와 join 전 쿼리 수가 달라지는 경우는 없나요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fetch 하는것 중에서 입력값이 없으면(예를 들어서 comment) 안가져올 것 같은데 이런거는 안가져오는게 맞을것 같습니다.