-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
814375a
commit f5f3a9a
Showing
11 changed files
with
95 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/main/java/com/dailylife/domain/user/dto/UserPagination.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.dailylife.domain.user.dto; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class UserPagination { | ||
|
||
int pg = 1; // 현재 페이지 | ||
int sz = 15; // 페이지 당 레코드 수 | ||
String userNickName; | ||
int recordCount; // 전체 레코드 수 | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/com/dailylife/domain/user/repository/UserPaginationRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.dailylife.domain.user.repository; | ||
|
||
import com.dailylife.domain.board.dto.BoardPagination; | ||
import com.dailylife.domain.board.entity.Board; | ||
import com.dailylife.domain.user.dto.UserPagination; | ||
import com.dailylife.domain.user.entity.User; | ||
import com.dailylife.domain.user.exception.NotFoundUserException; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.PageRequest; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.domain.Sort; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.List; | ||
|
||
public interface UserPaginationRepository extends JpaRepository<User, Long> { | ||
|
||
public default List<User> findAll(UserPagination pagination) { | ||
if(pagination.getUserNickName()!=null){ | ||
return findUserName(pagination); | ||
} | ||
throw new NotFoundUserException(); | ||
} | ||
|
||
Page<User> findByUserNameContaining(String keyword, Pageable pageable); | ||
|
||
public default List<User> findUserName(UserPagination pagination) { | ||
Page<User> page = this.findByUserNameContaining(pagination.getUserNickName(),PageRequest.of(pagination.getPg() - 1, pagination.getSz(), | ||
Sort.Direction.DESC, "userNum")); | ||
pagination.setRecordCount((int)page.getTotalElements()); | ||
return page.getContent(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,5 +11,7 @@ public class ErrorResponse { | |
|
||
private int errorCode; | ||
private String message; | ||
private String localDateTime; | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,19 +30,19 @@ public void initDB() throws IOException { | |
UserJoinRequest userReq1 = UserJoinRequest.builder() | ||
.userId("dl1") | ||
.userPassword("dl") | ||
.userName("dailyLife") | ||
.userName("dailyLife1") | ||
.userEmail("[email protected]").userJoinDate(LocalDateTime.now()).build(); | ||
|
||
UserJoinRequest userReq2 = UserJoinRequest.builder() | ||
.userId("dl2") | ||
.userPassword("dl") | ||
.userName("dailyLife") | ||
.userName("dailyLife2") | ||
.userEmail("[email protected]").userJoinDate(LocalDateTime.now()).build(); | ||
|
||
UserJoinRequest userReq3 = UserJoinRequest.builder() | ||
.userId("dl3") | ||
.userPassword("dl") | ||
.userName("dailyLife") | ||
.userName("dailyLife3") | ||
.userEmail("[email protected]").userJoinDate(LocalDateTime.now()).build(); | ||
|
||
userService.join(userReq1); | ||
|