게시판 정렬필터 추가
This commit is contained in:
parent
1312ac6b5d
commit
b2999ffd51
@ -80,7 +80,7 @@ public class BoardController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 자유/익명 게시판 목록 조회
|
* 자유/익명 게시판 목록 조회
|
||||||
* @ReqMap map 요청 파라미터 (page, searchKeyword)
|
* @ReqMap map 요청 파라미터 (page, searchKeyword, orderBy)
|
||||||
* @return 페이징된 자유/익명 게시판 목록
|
* @return 페이징된 자유/익명 게시판 목록
|
||||||
*/
|
*/
|
||||||
@Member
|
@Member
|
||||||
|
|||||||
@ -27,6 +27,11 @@ public class localbordService {
|
|||||||
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;
|
||||||
|
|
||||||
|
String orderBy = map.getString("orderBy");
|
||||||
|
if (orderBy == null || (!orderBy.equals("date") && !orderBy.equals("views"))) {
|
||||||
|
map.put("orderBy", "date"); // 기본 정렬은 날짜 기준
|
||||||
|
}
|
||||||
|
|
||||||
PageHelper.startPage(page, size);
|
PageHelper.startPage(page, size);
|
||||||
|
|
||||||
List<MapDto> result = boardMapper.getGeneralPosts(map);
|
List<MapDto> result = boardMapper.getGeneralPosts(map);
|
||||||
|
|||||||
@ -31,7 +31,11 @@
|
|||||||
<if test="searchKeyword != null and searchKeyword != ''">
|
<if test="searchKeyword != null and searchKeyword != ''">
|
||||||
AND LOCBRDTTL LIKE CONCAT('%', #{searchKeyword}, '%')
|
AND LOCBRDTTL LIKE CONCAT('%', #{searchKeyword}, '%')
|
||||||
</if>
|
</if>
|
||||||
ORDER BY LOCBRDUDT DESC
|
ORDER BY
|
||||||
|
<choose>
|
||||||
|
<when test="orderBy == 'date'"> LOCBRDUDT DESC </when>
|
||||||
|
<when test="orderBy == 'views'"> LOCBRDCNT DESC </when>
|
||||||
|
</choose>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<update id="incrementViewCount">
|
<update id="incrementViewCount">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user