Skip to content

Commit

Permalink
#145 fix: pr 리뷰 내용 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
aeyongdodam committed Mar 23, 2024
1 parent 104aa1c commit 5683f8b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@ public class CommentGetResponse {
@Schema(description = "좋아요 수")
private final Long totalLike;

@Schema(description = "마지막 업데이트 일시", example = "11시 10분")
@Schema(description = "마지막 업데이트 일시", example = "오전 11:10")
private final String updatedAt;

@Schema(description = "채택 여부", example="true")
private final Boolean isChosen;

@Builder
public CommentGetResponse(String nickName, String content, Long totalLike, String updatedAt) {
public CommentGetResponse(String nickName, String content, Long totalLike, String updatedAt, Boolean isChosen) {
this.nickName = nickName;
this.content = content;
this.totalLike = totalLike;
this.updatedAt = updatedAt;
this.isChosen = isChosen;
}

public static CommentGetResponse of(Comment comment) {
Expand All @@ -35,6 +39,7 @@ public static CommentGetResponse of(Comment comment) {
.content(comment.getContent())
.totalLike(comment.getTotalLike())
.updatedAt(TimeUtil.getUpdatedAt(comment.getUpdatedAt()))
.isChosen(comment.getIsChosen())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public ResponseEntity<List<CommentGetResponse>> getCounselorComments(@PathVariab
- 상담사 사이드 일대다 상담 댓글 작성 API
- 주소 형식: /api/v1/comments/counselors""")
@ApiResponses({
@ApiResponse(responseCode = "201", description = "조회 성공"),
@ApiResponse(responseCode = "201", description = "댓글 생성 성공"),
@ApiResponse(responseCode = "400", description = "1. 진행중이지 않은 상담 2. 마감된 상담 중 상담사 본인이 답변을 작성하지 않은 상담 3. 이미 답변을 작성한 상담",
content = @Content(mediaType = "application/json",
schema = @Schema(implementation = CustomExceptionResponse.class))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,5 @@ public interface PostService {

PostGetResponse getCounselorPostContent(Long postId, Long customerId);

Post getProceedingPost(Long postId);

Post checkAndGetCounselorPost(Long postId, Long customerId);

Boolean checkCounselorReadAuthority(Long postId, Long customerId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.example.sharemind.customer.application.CustomerService;
import com.example.sharemind.customer.domain.Customer;
import com.example.sharemind.global.content.ConsultCategory;
import com.example.sharemind.post.content.PostStatus;
import com.example.sharemind.post.domain.Post;
import com.example.sharemind.post.dto.request.PostCreateRequest;
import com.example.sharemind.post.dto.request.PostUpdateRequest;
Expand Down Expand Up @@ -111,11 +110,10 @@ public PostGetResponse getCounselorPostContent(Long postId, Long customerId) {
return PostGetResponse.of(post);
}

@Override
public Post getProceedingPost(Long postId) {
private Post getProceedingPost(Long postId) {
Post post = getPostByPostId(postId);

checkPostProceeding(post);
post.checkPostProceeding();
return post;
}

Expand All @@ -126,8 +124,7 @@ public Post checkAndGetCounselorPost(Long postId, Long customerId) {
return getProceedingPost(postId);
}

@Override
public Boolean checkCounselorReadAuthority(Long postId, Long customerId){
private Boolean checkCounselorReadAuthority(Long postId, Long customerId){
Post post = getPostByPostId(postId);

Counselor counselor = counselorService.getCounselorByCustomerId(customerId);
Expand All @@ -136,9 +133,4 @@ public Boolean checkCounselorReadAuthority(Long postId, Long customerId){

return comment != null;
}

private void checkPostProceeding(Post post) {
if (post.getPostStatus() != PostStatus.PROCEEDING)
throw new PostException(PostErrorCode.POST_NOT_PROCEEDING, post.getPostId().toString());
}
}
7 changes: 6 additions & 1 deletion src/main/java/com/example/sharemind/post/domain/Post.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void updateIsPaid() {
this.isPaid = true;
}

public void updatePostStatus(PostStatus postStatus){
public void updatePostStatus(PostStatus postStatus) {
this.postStatus = postStatus;
}

Expand All @@ -112,6 +112,11 @@ public void checkReadAuthority(Long customerId) {
}
}

public void checkPostProceeding() {
if (this.getPostStatus() != PostStatus.PROCEEDING)
throw new PostException(PostErrorCode.POST_NOT_PROCEEDING, this.getPostId().toString());
}

private void setIsPaid(Boolean isPublic) {
if (isPublic) {
this.isPaid = true;
Expand Down

0 comments on commit 5683f8b

Please sign in to comment.