Search

73. 스프링부트 포토그램 댓글 구현하기 컨트롤러, 서비스 만들기

Comment 서비스 만들기

service 폴더에 CommentService.java 생성
package com.cos.photogramstart.service; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.cos.photogramstart.domain.comment.Comment; import com.cos.photogramstart.domain.comment.CommentRepository; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor @Service public class CommentService { private final CommentRepository commentRepository; @Transactional public Comment 댓글쓰기() { return null; } @Transactional public void 댓글삭() { } }
Java
복사

Comment API 컨트롤러 만들기

api 폴더 안에 CommentApiController.java 생성
package com.cos.photogramstart.web.api; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; import com.cos.photogramstart.service.CommentService; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor @RestController public class CommentApiController { private final CommentService commentService; @PostMapping("/api/comment") public ResponseEntity<?> commentSave(){ return null; } @DeleteMapping("/api/comment/{id}") public ResponseEntity<?> commentDelete(@PathVariable int id){ return null; } }
Java
복사
story.js에 getStoryItem() 에서
<div class="sl__item__contents__comment" id="storyCommentItem-1""> <p> <b>Lovely :</b> 부럽습니다. </p> <button> <i class="fas fa-times"></i> </button> </div>
JavaScript
복사
이 부분들을 나중에 수정해줘야 한다.
이건 다음시간에~

*참고