-
Notifications
You must be signed in to change notification settings - Fork 5
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
Google Docs 링크 연동 API 구현 #107
Conversation
JS970
commented
Oct 14, 2023
•
edited
Loading
edited
- 작업내용
- Google Docs 링크 연동 entity, repo 설계 #103
- Google Docs 링크 연동 Controller 및 Service logic 구현 #104
- TBD
- Google Docs 링크 연동 테스트 #106
- /api/google-docs/registration - api/google-docs/delete/{docsPageId}
- GoogleDocsApiCreateService - GoogleDocsApiDeleteService
- GooglePageJPARepository.existsByDocumentIdAndUser -
@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; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기서 documentId와 pageId의 차이점은 무엇인가요???
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; | ||
} |
There was a problem hiding this comment.
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 객체를 주입받는 형식은 어떠신가요?
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); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
코드 중복이 생긴다면 createDocsWorkspace
가 아닌 createWorkspace
로 만들고 인자로 LinkProvider를 받아오면 되지 않을까 싶습니다.