Merge branch 'main' of http://192.168.0.251:3000/localnet/localhost-back.git into main
This commit is contained in:
commit
c4e523843e
@ -55,16 +55,14 @@ public class localbordService {
|
|||||||
private final PasswordEncoder passwordEncoder;
|
private final PasswordEncoder passwordEncoder;
|
||||||
|
|
||||||
public List<MapDto> selectNotices(MapDto map) {
|
public List<MapDto> selectNotices(MapDto map) {
|
||||||
String keyword = map.getString("searchKeyword");
|
|
||||||
map.put("searchKeyword", null);
|
map.put("searchKeyword", null);
|
||||||
|
|
||||||
List<MapDto> posts = boardMapper.selectNotices(map);
|
List<MapDto> posts = boardMapper.selectNotices(map);
|
||||||
enrichPostsWithAdditionalData(posts);
|
enrichPostsWithAdditionalData(posts);
|
||||||
|
|
||||||
return filterPostsByKeyword(posts, keyword);
|
return posts; // 검색 없이 전체 공지사항 리스트 반환
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public PageInfo<MapDto> selectGeneralPosts(MapDto map) {
|
public PageInfo<MapDto> selectGeneralPosts(MapDto map) {
|
||||||
int page = map.getString("page") != null ? Integer.parseInt(map.getString("page")) : 1;
|
int page = map.getString("page") != null ? Integer.parseInt(map.getString("page")) : 1;
|
||||||
int size = map.getString("size") != null ? Integer.parseInt(map.getString("size")) : 10;
|
int size = map.getString("size") != null ? Integer.parseInt(map.getString("size")) : 10;
|
||||||
@ -75,26 +73,32 @@ public class localbordService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String keyword = map.getString("searchKeyword");
|
String keyword = map.getString("searchKeyword");
|
||||||
map.put("searchKeyword", null); // MyBatis에 전달하지 않음
|
boolean hasKeyword = keyword != null && !keyword.trim().isEmpty();
|
||||||
|
|
||||||
// 넉넉히 많이 가져온 후 Java에서 필터링
|
if (hasKeyword) {
|
||||||
PageHelper.startPage(1, 1000); // 최대 1000개까지만 조회
|
// 전체 데이터를 가져와서 필터링
|
||||||
|
map.put("searchKeyword", null);
|
||||||
|
List<MapDto> allPosts = boardMapper.selectGeneralPosts(map);
|
||||||
|
enrichPostsWithAdditionalData(allPosts);
|
||||||
|
|
||||||
|
// 검색어 기반 필터링
|
||||||
|
List<MapDto> filtered = filterPostsByKeyword(allPosts, keyword.trim());
|
||||||
|
|
||||||
|
// Java에서 수동 페이징
|
||||||
|
int fromIndex = (page - 1) * size;
|
||||||
|
int toIndex = Math.min(fromIndex + size, filtered.size());
|
||||||
|
List<MapDto> pagedList = fromIndex >= filtered.size() ? new ArrayList<>() : filtered.subList(fromIndex, toIndex);
|
||||||
|
|
||||||
|
PageInfo<MapDto> pageInfo = new PageInfo<>(pagedList);
|
||||||
|
pageInfo.setTotal(filtered.size());
|
||||||
|
return PageUtil.redefineNavigation(pageInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 키워드 없으면 MyBatis에서 DB 페이징 처리
|
||||||
|
PageHelper.startPage(page, size);
|
||||||
List<MapDto> result = boardMapper.selectGeneralPosts(map);
|
List<MapDto> result = boardMapper.selectGeneralPosts(map);
|
||||||
|
|
||||||
enrichPostsWithAdditionalData(result);
|
enrichPostsWithAdditionalData(result);
|
||||||
|
return PageUtil.redefineNavigation(new PageInfo<>(result));
|
||||||
// 키워드 필터링 적용
|
|
||||||
List<MapDto> filtered = filterPostsByKeyword(result, keyword);
|
|
||||||
|
|
||||||
// 원하는 페이지만 잘라서 리턴
|
|
||||||
int fromIndex = (page - 1) * size;
|
|
||||||
int toIndex = Math.min(fromIndex + size, filtered.size());
|
|
||||||
List<MapDto> pageList = fromIndex >= filtered.size() ? new ArrayList<>() : filtered.subList(fromIndex, toIndex);
|
|
||||||
|
|
||||||
PageInfo<MapDto> pageInfo = new PageInfo<>(pageList);
|
|
||||||
pageInfo.setTotal(filtered.size());
|
|
||||||
|
|
||||||
return PageUtil.redefineNavigation(pageInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateIncrementViewCount(Long boardId) {
|
public void updateIncrementViewCount(Long boardId) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user