-> 담당자 개체를 CRUD하기 위한 API명세서를 작성한다.
@Controller
: api와 view를 동시에 사용하는 경우, view(화면) return이 주 목적@RestController
: view가 필요없는 api만 지원하는 서비스에서 사용, data(json, xml 등) return이 주 목적@RestController
=@Controller
+@ResponseBody
Entity(VO)
: entity패키지에 Manager Entity를 생성한다.Controller
: controller패키지에 ManagerApiController를 생성한다.Service(interface)
: service패키지에 ManagerService를 생성한다.ServiceImpl(구현체)
: serviceImpl 패키지에 ManagerServiceImpl를 생성한다.Mapper(interface)
: mapper패키지에 ManagerMapper를 생성한다.SQL Mapper
: resources 폴더 아래 mappers 패키지를 생성한 뒤 mappers 패키지에 managerMapper를 생성한다.Exception 처리
- Exception 패키지 생성
- PracticalErrorCode, PracticalException, PracticalExceptionHandler를 추가하여 커스텀 Exception을 생성하고 처리할 수 있도록 한다.
- ErrorCode에 예외가 발생되는 경우 나타낼 메시지를 추가한다.
- Service에서 데이터를 처리할 때 예외가 발생하는 경우 커스텀 Exception을 활용할 수 있다.
Ex) ID로 담당자 조회 시 해당 담당자가 존재하지 않을 때