Skip to content

Commit

Permalink
[fix]: Main 코드정리
Browse files Browse the repository at this point in the history
  • Loading branch information
qogustj committed Nov 28, 2023
1 parent 81864ac commit f7ac243
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ out/

### VS Code ###
.vscode/
**/src/main/resources/application.yml
#**/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -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<MailHeader,Long> {
List<MailHeader> findAllByMemberId(Long id);
Page<MailHeader> findAllByMemberId(Long id, Pageable pageable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -31,7 +32,7 @@ public ResponseEntity<SuccessResponse<?>> getMail(@RequestParam("host") String h

@GetMapping("/header")
public ResponseEntity<SuccessResponse<?>> getHeader(@RequestParam Long userId, @PageableDefault Pageable pageable){
final List<MailListResponseDto> mailListResponseDtoList = mailManageService.getMailList(userId, pageable);
final Page<MailListResponseDto> mailListResponseDtoList = mailManageService.getMailList(userId, pageable);
return SuccessResponse.ok(mailListResponseDtoList);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -19,16 +20,13 @@
@Service
public class MailManageService {
private final MailRepository mailRepository;
public List<MailListResponseDto> getMailList(Long id, Pageable pageable){
public Page<MailListResponseDto> getMailList(Long id, Pageable pageable){

List<MailListResponseDto> mailListResponseDtoList = createMailListResponseDtoList(id);
Page<MailListResponseDto> mailListResponseDtoList = createMailListResponseDtoList(id,pageable);
return mailListResponseDtoList;
}
private List<MailListResponseDto> createMailListResponseDtoList(Long id){
List<MailHeader> mailList = mailRepository.findAllByMemberId(id);
return mailList.stream()
.map(mail ->
MailListResponseDto.of(mail))
.collect(Collectors.toList());
private Page<MailListResponseDto> createMailListResponseDtoList(Long id, Pageable pageable){
Page<MailHeader> mailHeaderPage = mailRepository.findAllByMemberId(id, pageable);
return mailHeaderPage.map(mailHeader -> MailListResponseDto.of(mailHeader));
}
}
75 changes: 75 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
server:
port: 8080

spring:
data:
mongodb:
uri: mongodb+srv://parkchris0131:[email protected]/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

0 comments on commit f7ac243

Please sign in to comment.