diff --git a/.gitignore b/.gitignore index ede7ccf..194a78b 100644 --- a/.gitignore +++ b/.gitignore @@ -35,4 +35,4 @@ out/ ### VS Code ### .vscode/ -**/src/main/resources/application.yml \ No newline at end of file +#**/src/main/resources/application.yml \ No newline at end of file diff --git a/src/main/java/com/Nunbody/domain/Mail/repository/MailRepository.java b/src/main/java/com/Nunbody/domain/Mail/repository/MailRepository.java index 8801506..bd1ebd6 100644 --- a/src/main/java/com/Nunbody/domain/Mail/repository/MailRepository.java +++ b/src/main/java/com/Nunbody/domain/Mail/repository/MailRepository.java @@ -1,10 +1,12 @@ package com.Nunbody.domain.Mail.repository; import com.Nunbody.domain.Mail.domain.MailHeader; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import java.util.List; public interface MailRepository extends JpaRepository { - List findAllByMemberId(Long id); + Page findAllByMemberId(Long id, Pageable pageable); } diff --git a/src/main/java/com/Nunbody/domain/mail/controller/MailController.java b/src/main/java/com/Nunbody/domain/mail/controller/MailController.java index a2ed89a..9167011 100644 --- a/src/main/java/com/Nunbody/domain/mail/controller/MailController.java +++ b/src/main/java/com/Nunbody/domain/mail/controller/MailController.java @@ -7,6 +7,7 @@ import com.Nunbody.global.common.SuccessResponse; import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.web.PageableDefault; import org.springframework.http.HttpStatus; @@ -31,7 +32,7 @@ public ResponseEntity> getMail(@RequestParam("host") String h @GetMapping("/header") public ResponseEntity> getHeader(@RequestParam Long userId, @PageableDefault Pageable pageable){ - final List mailListResponseDtoList = mailManageService.getMailList(userId, pageable); + final Page mailListResponseDtoList = mailManageService.getMailList(userId, pageable); return SuccessResponse.ok(mailListResponseDtoList); } diff --git a/src/main/java/com/Nunbody/domain/mail/service/MailManageService.java b/src/main/java/com/Nunbody/domain/mail/service/MailManageService.java index 4ac8eb3..6fe53fd 100644 --- a/src/main/java/com/Nunbody/domain/mail/service/MailManageService.java +++ b/src/main/java/com/Nunbody/domain/mail/service/MailManageService.java @@ -6,6 +6,7 @@ import com.Nunbody.domain.Mail.repository.MailRepository; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -19,16 +20,13 @@ @Service public class MailManageService { private final MailRepository mailRepository; - public List getMailList(Long id, Pageable pageable){ + public Page getMailList(Long id, Pageable pageable){ - List mailListResponseDtoList = createMailListResponseDtoList(id); + Page mailListResponseDtoList = createMailListResponseDtoList(id,pageable); return mailListResponseDtoList; } - private List createMailListResponseDtoList(Long id){ - List mailList = mailRepository.findAllByMemberId(id); - return mailList.stream() - .map(mail -> - MailListResponseDto.of(mail)) - .collect(Collectors.toList()); + private Page createMailListResponseDtoList(Long id, Pageable pageable){ + Page mailHeaderPage = mailRepository.findAllByMemberId(id, pageable); + return mailHeaderPage.map(mailHeader -> MailListResponseDto.of(mailHeader)); } } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..06e0e70 --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,75 @@ +server: + port: 8080 + +spring: + data: + mongodb: + uri: mongodb+srv://parkchris0131:beakgugong0131@cluster0.honhdbo.mongodb.net/test?retryWrites=true&w=majority + oauth2: + client: + registration: + naver: + client-id: f38KmJuFOYmcHZxuJwMB + client-secret: 56VX1sKzQa + redirect-uri: http://localhost:8080/login/oauth/login + userInfoUrl: https://openapi.naver.com/v1/nid/me + tokenUrl: https://nid.naver.com/oauth2.0/token + kakao: + client-id: 560b92df78c778c1482eeaff5d71c194 + client-secret: UinjBl3UQmuj7d3p1osPMTojUNwkRZOk + scope: + # - profile_nickname + - account_email + client-name: Kakao + authorization-grant-type: authorization_code + client-authentication-method: POST #카카오는 필수 파라미터를 POST로 요청해야됌! + redirect-uri: http://localhost:8080/login/oauth2/code/kakao #코드를 받는 uri(naver 의 콜백 uri) + provider: #네이버의 provider는 등록되어 있지 않아 사용자가 등록해야된다. + kakao: + authorization-uri: https://kauth.kakao.com/oauth/authorize + token-uri: https://kauth.kakao.com/oauth/token + user-info-uri: https://kapi.kakao.com/v2/user/me + user-name-attribute: kakao_account + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://database-1.ci1oetc0wppg.ap-northeast-2.rds.amazonaws.com:3306/spam_application + username: admin + password: qkrwlstjr1! + + jpa: + hibernate: + ddl-auto: validate + properties: + hibernate.format_sql: true + +app: + google: + url: https://accounts.google.com/o/oauth2/v2/auth + client: + id: 799333127259-2e22vu6n71ctc579itbpvpdivoa8am99.apps.googleusercontent.com + secret: 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 + callback: + url: http://localhost:8080/login/oauth2/code/google + token: + url: https://oauth2.googleapis.com/token + userinfo: + url: https://www.googleapis.com/oauth2/v1/userinfo + kakao: + url: https://kauth.kakao.com/oauth/authorize + client: + id: 560b92df78c778c1482eeaff5d71c194 + secret: UinjBl3UQmuj7d3p1osPMTojUNwkRZOk + callback: + url: http://localhost:8080/login/oauth2/code/kakao + token: + url: https://kauth.kakao.com/oauth/token + userinfo: + url: https://kapi.kakao.com/v2/user/me + + + +security: + jwt: + token: + secret-key: Vu6WXrg3t9 + expire-length: 3600000 \ No newline at end of file