Skip to content

Commit

Permalink
[#52] fix: search Child List
Browse files Browse the repository at this point in the history
  • Loading branch information
hellouz818 committed Jun 1, 2022
1 parent 9a494ef commit 9af22a5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ public interface NoticeRepository extends JpaRepository<Notice, Long> {

List<Notice> findByNdate(LocalDate date);

List<Notice> findByUserAndChild(User user, Child child);
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ public SearchDetailDto searchDetail(@RequestParam("date") String date, HttpServl
return searchService.searchDetailList(date, request);
}

//@RequestMapping(value="/search/child", method = RequestMethod.GET)
//public List<SearchListDto> searchChildList(@RequestParam("cid") Long cid, HttpServletRequest request){
// return searchService.searchChildList(cid, request);
//}
@RequestMapping(value="/search/child", method = RequestMethod.GET)
public List<SearchListDto> searchChildList(@RequestParam("cid") Long cid, HttpServletRequest request){
return searchService.searchChildList(cid, request);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,9 @@ public List<SearchListDto> searchList(HttpServletRequest request) {
dateList.sort(Comparator.reverseOrder()); //최신순 정렬

for (int i = 0; i < dateList.size(); i++) {
List<String> titleList = new ArrayList<>();
List<SearchSavedListDto> savedLists = new ArrayList<>();
for (int j = 0; j < notices.size(); j++) {
if ((notices.get(j).getNdate()).equals(dateList.get(i))) {
titleList.add(notices.get(j).getTitle());
SearchSavedListDto searchSavedListDto = SearchSavedListDto.builder()
.nid(notices.get(j).getNid())
.cid(notices.get(j).getChild().getCid())
Expand Down Expand Up @@ -122,7 +120,7 @@ public SearchDetailDto searchDetailList(String date, HttpServletRequest request)
.build();

}
/*

public List<SearchListDto> searchChildList(Long cid, HttpServletRequest request) {

String token = jwtTokenProvider.resolveToken(request);
Expand All @@ -132,8 +130,7 @@ public List<SearchListDto> searchChildList(Long cid, HttpServletRequest request)
List<Notice> notices = noticeRepository.findByUserAndChild(user, child);

List<LocalDate> dateList = new ArrayList<>();
List<List<String>> titleLists = new ArrayList<>();
List<SearchListDto> searchListDtos = new ArrayList<>();
List<SearchListDto> saved = new ArrayList<>();

//유니크한 날짜값만 리스트에 저장하는 jpa 쿼리 메소드
for (int i = 0; i < noticeRepository.findUniqueNdate(user).size(); i++) {
Expand All @@ -143,26 +140,27 @@ public List<SearchListDto> searchChildList(Long cid, HttpServletRequest request)
dateList.sort(Comparator.reverseOrder()); //최신순 정렬

for (int i = 0; i < dateList.size(); i++) {
List<String> titleList = new ArrayList<>();
List<SearchSavedListDto> savedLists = new ArrayList<>();
for (int j = 0; j < notices.size(); j++) {
if ((notices.get(j).getNdate()).equals(dateList.get(i))) {
if (notices.get(j).getTitle() != null) {
titleList.add(notices.get(j).getTitle());
}
SearchSavedListDto searchSavedListDto = SearchSavedListDto.builder()
.nid(notices.get(j).getNid())
.cid(notices.get(j).getChild().getCid())
.title(notices.get(j).getTitle())
.build();
savedLists.add(searchSavedListDto);
}
}

SearchListDto searchListDto = SearchListDto.builder()
.date(dateList.get(i))
.saved(savedLists)
.build();

if (!titleList.isEmpty()){
titleLists.add(titleList);
SearchListDto searchListDto = SearchListDto.builder()
.date(dateList.get(i))
.saved_titles(titleLists.get(i))
.build();
searchListDtos.add(searchListDto);
saved.add(searchListDto);
}
}
return searchListDtos;
return saved ;
}
*/
}


0 comments on commit 9af22a5

Please sign in to comment.