Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Docs 링크 연동 API 구현 #107

Merged
merged 15 commits into from
Oct 15, 2023

Conversation

Comment on lines 29 to 42
@Column(name = "document_id", nullable = false)
private String documentId;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "category_id", nullable = false)
@OnDelete(action = OnDeleteAction.CASCADE)
private Category category;

@Column(name = "is_active", nullable = false)
private Boolean isActive;

@Column(name = "page_id", nullable = false)
private String pageId;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기서 documentId와 pageId의 차이점은 무엇인가요???

Comment on lines 76 to 97
private static Credential getCredentials(final NetHttpTransport HTTP_TRANSPORT)
throws IOException {
// credentials.json 가져오기
InputStream in = GoogleDocsApiBatchService.class.getResourceAsStream(CREDENTIALS_FILE_PATH);
if (in == null) {
throw new FileNotFoundException("Resource not found: " + CREDENTIALS_FILE_PATH);
}
GoogleClientSecrets clientSecrets =
GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));

// flow생성 및 유저 인증 요청 처리
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES)
.setDataStoreFactory(new FileDataStoreFactory(new java.io.File(TOKENS_DIRECTORY_PATH)))
.setAccessType("offline")
.build();
LocalServerReceiver receiver = new LocalServerReceiver.Builder().setPort(8888).build();
Credential credential = new AuthorizationCodeInstalledApp(flow, receiver).authorize("user");

// Credential 객체 반환
return credential;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getCredential은 해당 Service로직에 있기보단, Configuration으로 따로 떼어내 Bean으로 만들어 Credential 객체를 주입받는 형식은 어떠신가요?

@JS970 JS970 merged commit 22e915b into Step3-kakao-tech-campus:weekly Oct 15, 2023
1 check passed
Comment on lines +51 to +59
public Workspace createDocsWorkspace(String workspaceName, User user) {
Workspace workspace = workspaceJPARepository.findByUserIdAndWorkspaceName(user.getUserId(), workspaceName)
.orElseGet(() -> Workspace.builder()
.workspaceName(workspaceName)
.user(user)
.build());
workspace.setLinkProvider(LinkProvider.GOOGLE_DOCS);
return workspaceJPARepository.saveAndFlush(workspace);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

코드 중복이 생긴다면 createDocsWorkspace가 아닌 createWorkspace로 만들고 인자로 LinkProvider를 받아오면 되지 않을까 싶습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants