-
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.
Merge branch 'dev' into 641-방-시작-API
- Loading branch information
Showing
14 changed files
with
203 additions
and
6 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
gg-admin-repo/src/main/java/gg/admin/repo/comment/CommentAdminRepository.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,8 @@ | ||
package gg.admin.repo.comment; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import gg.data.party.Comment; | ||
|
||
public interface CommentAdminRepository extends JpaRepository<Comment, Long> { | ||
} |
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
29 changes: 28 additions & 1 deletion
29
...gpong-api/src/main/java/gg/party/api/admin/comment/controller/CommentAdminController.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,34 @@ | ||
package gg.pingpong.api.party.admin.comment.controller; | ||
package gg.party.api.admin.comment.controller; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PatchMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import gg.auth.UserDto; | ||
import gg.auth.argumentresolver.Login; | ||
import gg.party.api.admin.comment.controller.request.CommentUpdateAdminRequestDto; | ||
import gg.party.api.admin.comment.service.CommentAdminService; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/party/admin/comments") | ||
public class CommentAdminController { | ||
private final CommentAdminService commentAdminService; | ||
|
||
/** | ||
* 댓글 숨김 | ||
* @param commentId 댓글 번호 | ||
* @return 숨김 성공 여부 | ||
*/ | ||
@PatchMapping("/{commentId}") | ||
public ResponseEntity<Void> hideComment(@PathVariable Long commentId, | ||
@RequestBody CommentUpdateAdminRequestDto reqDto, @Login UserDto user) { | ||
commentAdminService.hideComment(commentId, reqDto); | ||
return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...main/java/gg/party/api/admin/comment/controller/request/CommentUpdateAdminRequestDto.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,10 @@ | ||
package gg.party.api.admin.comment.controller.request; | ||
|
||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
public class CommentUpdateAdminRequestDto { | ||
private Boolean isHidden; | ||
} |
24 changes: 24 additions & 0 deletions
24
gg-pingpong-api/src/main/java/gg/party/api/admin/comment/service/CommentAdminService.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,24 @@ | ||
package gg.party.api.admin.comment.service; | ||
|
||
import javax.transaction.Transactional; | ||
|
||
import org.springframework.stereotype.Service; | ||
|
||
import gg.admin.repo.comment.CommentAdminRepository; | ||
import gg.data.party.Comment; | ||
import gg.party.api.admin.comment.controller.request.CommentUpdateAdminRequestDto; | ||
import gg.utils.exception.party.CommentNotFoundException; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class CommentAdminService { | ||
private final CommentAdminRepository commentAdminRepository; | ||
|
||
@Transactional | ||
public void hideComment(Long commentId, CommentUpdateAdminRequestDto reqDto) { | ||
Comment comment = commentAdminRepository.findById(commentId) | ||
.orElseThrow(CommentNotFoundException::new); | ||
comment.updateHidden(reqDto.getIsHidden()); | ||
} | ||
} |
35 changes: 34 additions & 1 deletion
35
gg-pingpong-api/src/main/java/gg/party/api/admin/room/controller/RoomAdminController.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,40 @@ | ||
package gg.pingpong.api.party.admin.room.controller; | ||
package gg.party.api.admin.room.controller; | ||
|
||
import javax.validation.Valid; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PatchMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import gg.data.party.type.RoomType; | ||
import gg.party.api.admin.room.controller.request.RoomShowChangeReqDto; | ||
import gg.party.api.admin.room.service.RoomAdminService; | ||
import gg.utils.exception.ErrorCode; | ||
import gg.utils.exception.party.RoomStatNotFoundException; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/party/admin/rooms") | ||
public class RoomAdminController { | ||
|
||
private final RoomAdminService roomAdminService; | ||
|
||
@PatchMapping("/{roomId}") | ||
public ResponseEntity<Void> changeRoomVisibility(@PathVariable Long roomId, | ||
@Valid @RequestBody RoomShowChangeReqDto reqDto) throws RoomStatNotFoundException { | ||
|
||
RoomType roomType; | ||
try { | ||
roomType = RoomType.valueOf(reqDto.getStatus().toUpperCase()); | ||
} catch (IllegalArgumentException e) { | ||
throw new RoomStatNotFoundException(); | ||
} | ||
|
||
roomAdminService.modifyRoomStatus(roomId, roomType); | ||
return ResponseEntity.ok().build(); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...ng-api/src/main/java/gg/party/api/admin/room/controller/request/RoomShowChangeReqDto.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,13 @@ | ||
package gg.party.api.admin.room.controller.request; | ||
|
||
import javax.validation.constraints.NotNull; | ||
|
||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
public class RoomShowChangeReqDto { | ||
@NotNull | ||
private String status; | ||
} |
30 changes: 30 additions & 0 deletions
30
gg-pingpong-api/src/main/java/gg/party/api/admin/room/service/RoomAdminService.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,30 @@ | ||
package gg.party.api.admin.room.service; | ||
|
||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import gg.data.party.Room; | ||
import gg.data.party.type.RoomType; | ||
import gg.repo.party.RoomRepository; | ||
import gg.utils.exception.party.RoomAlreadyHiddenException; | ||
import gg.utils.exception.party.RoomNotFoundException; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class RoomAdminService { | ||
private final RoomRepository roomRepository; | ||
|
||
@Transactional | ||
public void modifyRoomStatus(Long roomId, RoomType newStatus) { | ||
Room room = roomRepository.findById(roomId) | ||
.orElseThrow(RoomNotFoundException::new); | ||
|
||
if (RoomType.HIDDEN == room.getStatus() && RoomType.HIDDEN == newStatus) { | ||
throw new RoomAlreadyHiddenException(); | ||
} | ||
|
||
room.updateRoomStatus(newStatus); | ||
roomRepository.save(room); | ||
} | ||
} |
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
11 changes: 11 additions & 0 deletions
11
gg-utils/src/main/java/gg/utils/exception/party/CommentNotFoundException.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,11 @@ | ||
package gg.utils.exception.party; | ||
|
||
import gg.utils.exception.ErrorCode; | ||
import gg.utils.exception.custom.NotExistException; | ||
|
||
public class CommentNotFoundException extends NotExistException { | ||
public CommentNotFoundException() { | ||
super(ErrorCode.COMMENT_NOT_FOUND.getMessage(), ErrorCode.COMMENT_NOT_FOUND); | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
gg-utils/src/main/java/gg/utils/exception/party/RoomAlreadyHiddenException.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,14 @@ | ||
package gg.utils.exception.party; | ||
|
||
import gg.utils.exception.ErrorCode; | ||
import gg.utils.exception.custom.DuplicationException; | ||
|
||
public class RoomAlreadyHiddenException extends DuplicationException { | ||
public RoomAlreadyHiddenException(String message, ErrorCode errorCode) { | ||
super(message, errorCode); | ||
} | ||
|
||
public RoomAlreadyHiddenException() { | ||
super(ErrorCode.ROOM_ALREADY_HIDDEN.getMessage(), ErrorCode.ROOM_ALREADY_HIDDEN); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
gg-utils/src/main/java/gg/utils/exception/party/RoomStatNotFoundException.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,14 @@ | ||
package gg.utils.exception.party; | ||
|
||
import gg.utils.exception.ErrorCode; | ||
import gg.utils.exception.custom.NotExistException; | ||
|
||
public class RoomStatNotFoundException extends NotExistException { | ||
public RoomStatNotFoundException(String message, ErrorCode errorCode) { | ||
super(message, errorCode); | ||
} | ||
|
||
public RoomStatNotFoundException() { | ||
super(ErrorCode.ROOMSTAT_NOT_FOUND.getMessage(), ErrorCode.ROOMSTAT_NOT_FOUND); | ||
} | ||
} |