-
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.
- Loading branch information
Showing
8 changed files
with
89 additions
and
2 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
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()); | ||
} | ||
} |
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); | ||
} | ||
|
||
} |