: 프론트와 소통하는 창구
클라이언트의 요청(Request)을 전달받는 코드
요청(Request)/응답(Response)를 처리함
💡 클라이언트 단의 작업을 수행하는 부분!
: JSON 형식만을 돌려주는 Controller
@RestController
public class PostController {
@GetMapping("/posts")
public Post getPosts() {
Post post = new Post();
post.setTitle();
post.setAuthor();
post.setDatetime();
return post;
}
}
@GetMapping
/posts
일 때, getPost 메소드를 실행함: 중간 부분
💡 즉, 요청 / 응답 보내는 부분은 Controller가, DB 만지는 쪽은 Repository가, 나머지 부분은 거의 모두 Service에서 처리하는 것이라고 보면 됨!!!
: DB와 소통하는 창구
서버 - DB 사이의 작업을 수행하는 부분!