오늘은 새로운 팀원들과 배달 프로그램 프로젝트 설계를 했다.
ERD를 만들고
API명세도 쓰고, 와이어 프레임도 만들었다.
그 뒤 언제나처럼 역할을 정하고 작업을 하는데, 카테고리를 어떻게 만들어야할지 고민이 되기 시작했다.
1번 방법
- 프론트 단에서 HomeController를 이용해 처리하고 여러 프론트 화면을 불러온다.
2번 방법
- 조회 API에서 JPA를 이용해 받아온 id값으로 카테고리를 찾아서 해당카테고리와 같은 카테고리를 가진 Shop데이터만 뽑아와서 조회한다.
난이도는 1번방법이 간단하지만 당연하게도 2번 방법인 백단에서 해결하는 방법을 이용했다.
List<Shop> postList = shopRepository.findAllByCategory_IdOrderByModifiedAtDesc(categoryId);
▲JPA를 이용해 같은 카테고리를 가진 Shop을 List형으로 찾아오는 코드
생각한것보다는 간단했다. 물론 아직 적용도 안 해보고 테스트도 전이지만 테스트는 내일 팀원들과 같이 해봐야겠다.
그 외 알게된 것
@JsonIgnore : 해당 어노테이션을 붙이면 Dto반환시 제외처리되게 된다.