@NotBlank
private String lectureName;
@NotBlank
private String year;
// 1 or 2
private String semester;
private List<LectureTime> lectureTimeList;
@NotNull
@Range(min = 1,max = 100)
private Integer limitNum;
form은 어노테이션 기반 validation 적용
@PostMapping("/lectures/opened")
public String searchLecture(@Validated @ModelAttribute SearchLectureForm form,
BindingResult bindingResult, Model model, Pageable pageable) {
if (bindingResult.hasErrors()) {
return "lectures/openedLecture";
}
Page<Lecture> findLectures = getLectures(form, pageable);
Page<LectureForm> lectureFormList = findLectures.map(LectureForm::of);
model.addAttribute("lectureList", lectureFormList);
if (lectureFormList.isEmpty()) {
bindingResult.reject("lectureNotFound","검색 조건에 해당하는 강의가 없습니다.");
}
return "lectures/openedLecture";
}
Controller는 bindingResult로 직접 에러 전송
DTO를 컨트롤러 단까지로 제약했기에 모든 DTO는 form으로 통일한다.
Controller에서 Service로 갈 경우 무조건 엔티티로 변환 후 넘긴다.
개인 branch에서 각자 분량 코딩하고 Master에 Pull Request한다.
Pull Request 시 머지 정보를 팀원에게 알려준다.
(이런걸 Convention이라 할 수 있으려나..)