Skip to content

Commit

Permalink
✨ Feat #66 : [동네정보] 댓글 수정 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Suanna01 committed Aug 6, 2023
1 parent 5dc5797 commit 7c637e0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,12 @@ public String postComment(@PathVariable("townInformationId") Long townInformatio
return "";
}

// [동네정보] 댓글 수정
@PutMapping("/{commentId}")
public String putComment(@PathVariable("commentId") Long commentId, @RequestBody DongnaeCommentDto dongnaeCommentDto) {
dongnaeCommentService.modifyComment(commentId, dongnaeCommentDto);
return "";
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import static lombok.AccessLevel.PROTECTED;

import com.umc.DongnaeFriend.domain.BaseTimeEntity;
import com.umc.DongnaeFriend.domain.account.sharing.dto.ReqSharingCommentDto;
import com.umc.DongnaeFriend.domain.dongnae.dto.DongnaeCommentDto;
import com.umc.DongnaeFriend.domain.user.entity.User;
import java.util.List;
import javax.persistence.*;
Expand Down Expand Up @@ -44,4 +46,7 @@ public class DongnaeComment extends BaseTimeEntity {
@Column(nullable = false)
private String content;

public void modifyComment(DongnaeCommentDto dongnaeCommentDto) {
this.content = dongnaeCommentDto.getContent();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.umc.DongnaeFriend.domain.dongnae.service;

import com.umc.DongnaeFriend.domain.account.sharing.dto.ReqSharingCommentDto;
import com.umc.DongnaeFriend.domain.account.sharing.entity.SharingBoard;
import com.umc.DongnaeFriend.domain.account.sharing.entity.SharingComment;
import com.umc.DongnaeFriend.domain.dongnae.dto.DongnaeCommentDto;
Expand Down Expand Up @@ -58,4 +59,18 @@ public String newComment(Long townInformationId, DongnaeCommentDto dongnaeCommen

return "댓글 등록 성공";
}

// [동네정보] 댓글 수정
public String modifyComment(Long commentId, DongnaeCommentDto dongnaeCommentDto) {
// 댓글 찾기
Optional<DongnaeComment> dongnaeCommentOptional = dongnaeCommentRepository.findById(commentId);
DongnaeComment dongnaeComment = dongnaeCommentOptional.get();

dongnaeComment.modifyComment(dongnaeCommentDto);

dongnaeCommentRepository.save(dongnaeComment);

return "댓글 수정 성공";
}

}

0 comments on commit 7c637e0

Please sign in to comment.