Service Repository 구분 이유
Service Repository 구분 이유
Service Repository 구분 이유
Repository
는 DB에 접근하는 코드 영역- DB 관련 문제가 생기면 여기만 확인하면 됨
Service
는repository
를 이용해 비즈니스 로직을 처리하는 코드 영역Controller
가service
를 호출하면, 비즈니스 로직을 수행하고 결과를controller
에게 넘겨 줌- 비즈니스 로직에 문제가 생기면 여기만 확인하면 됨
- 이렇게 DB 접근과 비즈니스 로직을 분리하면, 어디에서 문제가 발생했는지 알기 쉽고, 코드가 잘 모듈화됨
References
- https://www.inflearn.com/questions/77417/repository-vs-service-%EC%9D%98-%EC%97%AD%ED%95%A0%EC%9D%98-%EC%B0%A8%EC%9D%B4%EC%A0%90
- https://velog.io/@jybin96/Controller-Service-Repository-%EA%B0%80-%EB%AC%B4%EC%97%87%EC%9D%BC%EA%B9%8C