-
Notifications
You must be signed in to change notification settings - Fork 2
feature/#194 게시글 API 프론트 QA 반영 #195
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
Changes from 5 commits
0f1e36b
b077490
9213ea4
cfb6cc7
4ed381c
ca40c1c
771d4b6
f76644f
c322e29
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,23 +1,33 @@ | ||||||||||||||||||||||||||
| package kgu.developers.domain.post.application.command; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| import org.springframework.stereotype.Service; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| import kgu.developers.domain.file.application.query.FileQueryService; | ||||||||||||||||||||||||||
| import kgu.developers.domain.file.domain.FileEntity; | ||||||||||||||||||||||||||
| import kgu.developers.domain.file.exception.FileNotFoundException; | ||||||||||||||||||||||||||
| import kgu.developers.domain.post.domain.Category; | ||||||||||||||||||||||||||
| import kgu.developers.domain.post.domain.Post; | ||||||||||||||||||||||||||
| import kgu.developers.domain.post.domain.PostRepository; | ||||||||||||||||||||||||||
| import kgu.developers.domain.user.application.query.UserQueryService; | ||||||||||||||||||||||||||
| import kgu.developers.domain.user.domain.User; | ||||||||||||||||||||||||||
| import lombok.RequiredArgsConstructor; | ||||||||||||||||||||||||||
| import org.springframework.stereotype.Service; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| @Service | ||||||||||||||||||||||||||
| @RequiredArgsConstructor | ||||||||||||||||||||||||||
| public class PostCommandService { | ||||||||||||||||||||||||||
| private final UserQueryService userQueryService; | ||||||||||||||||||||||||||
| private final PostRepository postRepository; | ||||||||||||||||||||||||||
| private final FileQueryService fileQueryService; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| public Long createPost(String title, String content, Category category) { | ||||||||||||||||||||||||||
| public Long createPost(String title, String content, Category category, Long fileId) { | ||||||||||||||||||||||||||
| User author = userQueryService.me(); | ||||||||||||||||||||||||||
| Post post = Post.create(title, content, category, author); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| FileEntity file = null; | ||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||
| file = fileQueryService.getFileById(fileId); | ||||||||||||||||||||||||||
|
Check warning on line 26 in aics-domain/src/main/java/kgu/developers/domain/post/application/command/PostCommandService.java
|
||||||||||||||||||||||||||
| } catch (FileNotFoundException ignored) { | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
Check warning on line 28 in aics-domain/src/main/java/kgu/developers/domain/post/application/command/PostCommandService.java
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| FileEntity file = null; | |
| try { | |
| file = fileQueryService.getFileById(fileId); | |
| } catch (FileNotFoundException ignored) { | |
| } | |
| FileEntity file = null; | |
| try { | |
| file = (fileId != null && fileId > 0) ? fileQueryService.getFileById(fileId) : null; | |
| } catch (FileNotFoundException e) { | |
| // 로그 추가 | |
| log.debug("File not found for ID: {}. Creating post without file.", fileId); | |
| } |
LeeShinHaeng marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,7 +40,8 @@ private Post getPost(User author) { | |
| "title", | ||
| "content.", | ||
| NEWS, | ||
| author | ||
| author, | ||
| null | ||
| ); | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.