Skip to content

Commit f0d6991

Browse files
authored
YEL-166 [fix] 내림차순 정렬
YEL-166 [fix] 내림차순 정렬
2 parents ee92854 + be392a1 commit f0d6991

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/main/java/com/yello/server/domain/admin/controller/AdminController.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import static com.yello.server.global.common.SuccessCode.READ_USER_DETAIL_ADMIN_SUCCESS;
1313
import static com.yello.server.global.common.SuccessCode.UPDATE_USER_DETAIL_ADMIN_SUCCESS;
1414
import static com.yello.server.global.common.factory.PaginationFactory.createPageable;
15+
import static com.yello.server.global.common.factory.PaginationFactory.createPageableByNameSortDescLimitTen;
1516
import static com.yello.server.global.common.factory.PaginationFactory.createPageableLimitTen;
1617

1718
import com.yello.server.domain.admin.dto.request.AdminLoginRequest;
@@ -61,9 +62,10 @@ public BaseResponse<AdminUserResponse> getUserAdmin(@AccessTokenUser User user,
6162
@RequestParam Integer page,
6263
@Nullable @RequestParam String field,
6364
@Nullable @RequestParam String value) {
64-
val data = (field == null && value == null)
65-
? adminService.findUser(user.getId(), createPageableLimitTen(page))
66-
: adminService.findUserContaining(user.getId(), createPageableLimitTen(page),
65+
val data = (field==null && value==null)
66+
? adminService.findUser(user.getId(), createPageableByNameSortDescLimitTen(page))
67+
: adminService.findUserContaining(user.getId(),
68+
createPageableByNameSortDescLimitTen(page),
6769
field, value);
6870
return BaseResponse.success(READ_USER_ADMIN_SUCCESS, data);
6971
}
@@ -92,7 +94,7 @@ public BaseResponse deleteUser(@AccessTokenUser User user, @RequestParam Long us
9294
public BaseResponse<AdminCooldownResponse> getCooldownAdmin(@AccessTokenUser User user,
9395
@RequestParam Integer page,
9496
@Nullable @RequestParam String yelloId) {
95-
val data = yelloId == null
97+
val data = yelloId==null
9698
? adminService.findCooldown(user.getId(), createPageableLimitTen(page))
9799
: adminService.findCooldownContaining(user.getId(), createPageableLimitTen(page),
98100
yelloId);

src/main/java/com/yello/server/global/common/factory/PaginationFactory.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.springframework.data.domain.PageRequest;
88
import org.springframework.data.domain.Pageable;
99
import org.springframework.data.domain.Sort;
10+
import org.springframework.data.domain.Sort.Direction;
1011

1112
public class PaginationFactory {
1213

@@ -33,6 +34,10 @@ public static Pageable createPageableByNameSort(Integer page) {
3334
return PageRequest.of(page, PAGE_LIMIT, Sort.by(Sort.Direction.ASC, "name"));
3435
}
3536

37+
public static Pageable createPageableByNameSortDescLimitTen(Integer page) {
38+
return PageRequest.of(page, PAGE_LIMIT_TEN, Sort.by(Direction.DESC, "id"));
39+
}
40+
3641
public static <T> Page<T> getPage(List<T> list, Pageable pageable) {
3742
int start = (int) pageable.getOffset();
3843
int end = Math.min((start + pageable.getPageSize()), list.size());

0 commit comments

Comments
 (0)