-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v1.3.0
- Loading branch information
Showing
103 changed files
with
3,663 additions
and
1,028 deletions.
There are no files selected for viewing
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
75 changes: 75 additions & 0 deletions
75
main/src/main/java/org/sopt/makers/crew/main/comment/v2/CommentV2Api.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,75 @@ | ||
package org.sopt.makers.crew.main.comment.v2; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
import jakarta.validation.Valid; | ||
|
||
import java.security.Principal; | ||
|
||
import org.sopt.makers.crew.main.comment.v2.dto.query.CommentV2GetCommentsQueryDto; | ||
import org.sopt.makers.crew.main.comment.v2.dto.request.CommentV2CreateCommentBodyDto; | ||
import org.sopt.makers.crew.main.comment.v2.dto.request.CommentV2MentionUserInCommentRequestDto; | ||
import org.sopt.makers.crew.main.comment.v2.dto.request.CommentV2UpdateCommentBodyDto; | ||
import org.sopt.makers.crew.main.comment.v2.dto.response.CommentV2CreateCommentResponseDto; | ||
import org.sopt.makers.crew.main.comment.v2.dto.response.CommentV2GetCommentsResponseDto; | ||
import org.sopt.makers.crew.main.comment.v2.dto.response.CommentV2ReportCommentResponseDto; | ||
import org.sopt.makers.crew.main.comment.v2.dto.response.CommentV2UpdateCommentResponseDto; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ModelAttribute; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
|
||
public interface CommentV2Api { | ||
|
||
@Operation(summary = "모임 게시글 댓글 작성") | ||
@ResponseStatus(HttpStatus.CREATED) | ||
@ApiResponses(value = { | ||
@ApiResponse(responseCode = "201", description = "성공"), | ||
}) | ||
ResponseEntity<CommentV2CreateCommentResponseDto> createComment( | ||
@Valid @RequestBody CommentV2CreateCommentBodyDto requestBody, Principal principal); | ||
|
||
@Operation(summary = "모임 게시글 댓글 수정") | ||
@ResponseStatus(HttpStatus.OK) | ||
@ApiResponses(value = { | ||
@ApiResponse(responseCode = "200", description = "성공"), | ||
}) | ||
ResponseEntity<CommentV2UpdateCommentResponseDto> updateComment( | ||
@PathVariable Integer commentId, | ||
@Valid @RequestBody CommentV2UpdateCommentBodyDto requestBody, | ||
Principal principal); | ||
|
||
@Operation(summary = "댓글 신고하기") | ||
@ResponseStatus(HttpStatus.CREATED) | ||
@ApiResponses(value = { | ||
@ApiResponse(responseCode = "201", description = "성공"), | ||
}) | ||
ResponseEntity<CommentV2ReportCommentResponseDto> reportComment( | ||
@PathVariable Integer commentId, Principal principal); | ||
|
||
@Operation(summary = "모임 게시글 댓글 삭제") | ||
@ResponseStatus(HttpStatus.NO_CONTENT) | ||
@ApiResponses(value = { | ||
@ApiResponse(responseCode = "204", description = "성공"), | ||
}) | ||
ResponseEntity<Void> deleteComment(Principal principal, @PathVariable Integer commentId); | ||
|
||
@Operation(summary = "댓글에서 유저 멘션") | ||
@ResponseStatus(HttpStatus.OK) | ||
@ApiResponses(value = { | ||
@ApiResponse(responseCode = "200", description = "성공"), | ||
}) | ||
ResponseEntity<Void> mentionUserInComment( | ||
@Valid @RequestBody CommentV2MentionUserInCommentRequestDto requestBody, | ||
Principal principal); | ||
|
||
@Operation(summary = "모임 게시글 댓글 리스트 조회") | ||
@ResponseStatus(HttpStatus.OK) | ||
@ApiResponses(value = { | ||
@ApiResponse(responseCode = "200", description = "성공"), | ||
}) | ||
ResponseEntity<CommentV2GetCommentsResponseDto> getComments(@Valid @ModelAttribute CommentV2GetCommentsQueryDto requestBody, Principal principal); | ||
} |
97 changes: 78 additions & 19 deletions
97
main/src/main/java/org/sopt/makers/crew/main/comment/v2/CommentV2Controller.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,42 +1,101 @@ | ||
package org.sopt.makers.crew.main.comment.v2; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import jakarta.validation.Valid; | ||
|
||
import java.security.Principal; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
import org.sopt.makers.crew.main.comment.v2.dto.query.CommentV2GetCommentsQueryDto; | ||
import org.sopt.makers.crew.main.comment.v2.dto.request.CommentV2CreateCommentBodyDto; | ||
import org.sopt.makers.crew.main.comment.v2.dto.request.CommentV2MentionUserInCommentRequestDto; | ||
import org.sopt.makers.crew.main.comment.v2.dto.request.CommentV2UpdateCommentBodyDto; | ||
import org.sopt.makers.crew.main.comment.v2.dto.response.CommentV2CreateCommentResponseDto; | ||
import org.sopt.makers.crew.main.comment.v2.dto.response.CommentV2GetCommentsResponseDto; | ||
import org.sopt.makers.crew.main.comment.v2.dto.response.CommentV2ReportCommentResponseDto; | ||
import org.sopt.makers.crew.main.comment.v2.dto.response.CommentV2UpdateCommentResponseDto; | ||
import org.sopt.makers.crew.main.comment.v2.service.CommentV2Service; | ||
import org.sopt.makers.crew.main.common.util.UserUtil; | ||
import org.springframework.http.HttpStatus; | ||
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.PathVariable; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.PutMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/comment/v2") | ||
@RequiredArgsConstructor | ||
@Tag(name = "댓글/대댓글") | ||
public class CommentV2Controller { | ||
|
||
private final CommentV2Service commentV2Service; | ||
|
||
@Operation(summary = "모임 게시글 댓글 작성") | ||
@PostMapping() | ||
@ResponseStatus(HttpStatus.CREATED) | ||
@ApiResponses(value = { | ||
@ApiResponse(responseCode = "201", description = "성공"), | ||
}) | ||
public ResponseEntity<CommentV2CreateCommentResponseDto> createComment( | ||
@Valid @RequestBody CommentV2CreateCommentBodyDto requestBody, Principal principal) { | ||
Integer userId = UserUtil.getUserId(principal); | ||
return ResponseEntity.ok(commentV2Service.createComment(requestBody, userId)); | ||
} | ||
public class CommentV2Controller implements CommentV2Api { | ||
|
||
private final CommentV2Service commentV2Service; | ||
|
||
@Override | ||
@PostMapping() | ||
public ResponseEntity<CommentV2CreateCommentResponseDto> createComment( | ||
@Valid @RequestBody CommentV2CreateCommentBodyDto requestBody, Principal principal) { | ||
Integer userId = UserUtil.getUserId(principal); | ||
return ResponseEntity.ok(commentV2Service.createComment(requestBody, userId)); | ||
} | ||
|
||
@Override | ||
@PutMapping("/{commentId}") | ||
public ResponseEntity<CommentV2UpdateCommentResponseDto> updateComment( | ||
@PathVariable Integer commentId, | ||
@Valid @RequestBody CommentV2UpdateCommentBodyDto requestBody, | ||
Principal principal) { | ||
Integer userId = UserUtil.getUserId(principal); | ||
return ResponseEntity.ok( | ||
commentV2Service.updateComment(commentId, requestBody.getContents(), userId)); | ||
} | ||
|
||
@Override | ||
@PostMapping("/{commentId}/report") | ||
public ResponseEntity<CommentV2ReportCommentResponseDto> reportComment( | ||
@PathVariable Integer commentId, Principal principal) { | ||
Integer userId = UserUtil.getUserId(principal); | ||
return ResponseEntity.ok(commentV2Service.reportComment(commentId, userId)); | ||
} | ||
|
||
@Override | ||
@DeleteMapping("/{commentId}") | ||
public ResponseEntity<Void> deleteComment( | ||
Principal principal, | ||
@PathVariable Integer commentId) { | ||
Integer userId = UserUtil.getUserId(principal); | ||
|
||
commentV2Service.deleteComment(commentId, userId); | ||
|
||
return ResponseEntity.noContent().build(); | ||
} | ||
|
||
@Override | ||
@PostMapping("/mention") | ||
public ResponseEntity<Void> mentionUserInComment( | ||
@Valid @RequestBody CommentV2MentionUserInCommentRequestDto requestBody, | ||
Principal principal) { | ||
Integer userId = UserUtil.getUserId(principal); | ||
commentV2Service.mentionUserInComment(requestBody, userId); | ||
return ResponseEntity.status(HttpStatus.OK).build(); | ||
} | ||
|
||
@Override | ||
@GetMapping | ||
public ResponseEntity<CommentV2GetCommentsResponseDto> getComments( | ||
@Valid @ModelAttribute CommentV2GetCommentsQueryDto requestBody, | ||
Principal principal) { | ||
|
||
Integer userId = UserUtil.getUserId(principal); | ||
CommentV2GetCommentsResponseDto commentDtos = commentV2Service.getComments(requestBody.getPostId(), | ||
requestBody.getPage(), requestBody.getTake(), userId); | ||
|
||
return ResponseEntity.status(HttpStatus.OK).body(commentDtos); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
main/src/main/java/org/sopt/makers/crew/main/comment/v2/dto/CommentMapper.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,19 @@ | ||
package org.sopt.makers.crew.main.comment.v2.dto; | ||
|
||
import org.mapstruct.Mapper; | ||
import org.mapstruct.Mapping; | ||
import org.sopt.makers.crew.main.comment.v2.dto.request.CommentV2CreateCommentBodyDto; | ||
import org.sopt.makers.crew.main.entity.comment.Comment; | ||
import org.sopt.makers.crew.main.entity.post.Post; | ||
import org.sopt.makers.crew.main.entity.user.User; | ||
|
||
@Mapper(componentModel = "spring") | ||
public interface CommentMapper { | ||
@Mapping(source = "post", target = "post") | ||
@Mapping(source = "requestBody.contents", target = "contents") | ||
@Mapping(source = "user", target = "user") | ||
@Mapping(source = "user.id", target = "userId") | ||
@Mapping(target = "likeCount", constant = "0") | ||
Comment toComment(CommentV2CreateCommentBodyDto requestBody, Post post, User user, int depth, int order, | ||
Integer parentId); | ||
} |
20 changes: 20 additions & 0 deletions
20
...ain/java/org/sopt/makers/crew/main/comment/v2/dto/query/CommentV2GetCommentsQueryDto.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,20 @@ | ||
package org.sopt.makers.crew.main.comment.v2.dto.query; | ||
|
||
import org.sopt.makers.crew.main.common.pagination.dto.PageOptionsDto; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class CommentV2GetCommentsQueryDto extends PageOptionsDto { | ||
|
||
@NotNull | ||
private final Integer postId; | ||
|
||
@Builder | ||
public CommentV2GetCommentsQueryDto(Integer page, Integer take, Integer postId) { | ||
super(page, take); | ||
this.postId = postId; | ||
} | ||
} |
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
31 changes: 31 additions & 0 deletions
31
...sopt/makers/crew/main/comment/v2/dto/request/CommentV2MentionUserInCommentRequestDto.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,31 @@ | ||
package org.sopt.makers.crew.main.comment.v2.dto.request; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.NotEmpty; | ||
import jakarta.validation.constraints.NotNull; | ||
|
||
import java.util.List; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@Schema(description = "댓글에서 유저 언급 request body dto") | ||
public class CommentV2MentionUserInCommentRequestDto { | ||
|
||
/** | ||
* 주의!! : 필드명은 userIds 이지만 실제 요청받는 값은 orgId 입니다. | ||
*/ | ||
|
||
@Schema(example = "[111, 112, 113]", required = true, description = "언급할 유저 ID") | ||
@NotEmpty | ||
private List<Integer> userIds; | ||
|
||
@Schema(example = "1", required = true, description = "게시글 ID") | ||
@NotNull | ||
private Integer postId; | ||
|
||
@Schema(example = "멘션내용~~", required = true, description = "멘션 내용") | ||
private String content; | ||
} |
19 changes: 19 additions & 0 deletions
19
.../java/org/sopt/makers/crew/main/comment/v2/dto/request/CommentV2UpdateCommentBodyDto.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,19 @@ | ||
package org.sopt.makers.crew.main.comment.v2.dto.request; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.NotEmpty; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Schema(description = "댓글 업데이트 request body dto") | ||
public class CommentV2UpdateCommentBodyDto { | ||
|
||
@Schema(example = "알고보면 쓸데있는 개발 프로세스", description = "댓글 내용") | ||
@NotEmpty | ||
private String contents; | ||
|
||
} |
Oops, something went wrong.