diff --git a/README.md b/README.md index 5f3c06f..b4967c9 100644 --- a/README.md +++ b/README.md @@ -35,4 +35,31 @@ you can See Vue.js + SpringBoot FullStack Web Site Demo #### **Total 82% Code Coverage** ------- +----- + +# How it works + +- Spring Boot(Java) + - JPA + - Security +- H2 +- Vue3 + - Vite + - vuerouter + - vuex +- localStorage + +# Getting started + +## Run Local +```shell +./gradlew bootRun +``` + +# FrontEnd + +**I don't know much about the front end. I wanted to create a visible application, so I adopted and implemented that framework.** + +But my codes are simple codes that even beginners can easily see. + + diff --git a/src/main/java/com/io/realworld/domain/aggregate/article/service/CommentServiceImpl.java b/src/main/java/com/io/realworld/domain/aggregate/article/service/CommentServiceImpl.java index 7875636..e6ad1b8 100644 --- a/src/main/java/com/io/realworld/domain/aggregate/article/service/CommentServiceImpl.java +++ b/src/main/java/com/io/realworld/domain/aggregate/article/service/CommentServiceImpl.java @@ -61,9 +61,10 @@ public class CommentServiceImpl implements CommentService { if (article.isEmpty()) { throw new CustomException(Error.ARTICLE_NOT_FOUND); } + System.out.println(user.get().getUsername()+"!!"); Comment comment = commentRepository.save(Comment.builder().body(commentdto.getBody()).article(article.get()).author(user.get()).build()); - return convertComment(userAuth, article.get(), comment); + return convertComment(userAuth, comment); } @Override @@ -80,9 +81,9 @@ public class CommentServiceImpl implements CommentService { commentRepository.delete(comment.get()); } - private CommentResponse convertComment(UserAuth userAuth, Article article, Comment comment) { + private CommentResponse convertComment(UserAuth userAuth, Comment comment) { - ProfileResponse profile = profileService.getProfile(userAuth, article.getAuthor().getUsername()); + ProfileResponse profile = profileService.getProfile(userAuth, userAuth.getUsername()); return CommentResponse.builder() .id(comment.getId()) diff --git a/src/vite-frontend/src/api/index.ts b/src/vite-frontend/src/api/index.ts index 020ab42..d63b5dc 100644 --- a/src/vite-frontend/src/api/index.ts +++ b/src/vite-frontend/src/api/index.ts @@ -74,7 +74,7 @@ const createArticle = async (article: object | undefined): Promise => { +const updateArticle = async (article: object | undefined, slug: string | undefined): Promise => { let currentToken = localStorage.getItem("token"); return await axiosService.put('/api/articles/' + slug, { article },{ headers :{ @@ -84,6 +84,16 @@ const updateArticle = async (article: object | undefined, slug: string): Promise }) } +const deleteArticle = async (slug: string | undefined): Promise => { + let currentToken = localStorage.getItem("token"); + return await axiosService.delete('/api/articles/' + slug,{ + headers :{ + Authorization : "TOKEN " + currentToken, + "Content-Type": `application/json`, + } + }) +} + const listArticles = async (): Promise => { let currentToken = localStorage.getItem("token"); if(currentToken == null){ @@ -171,6 +181,17 @@ const getCommentsFromArticle = async (slug: string | undefined): Promise => { + let currentToken = localStorage.getItem("token"); + return await axiosService.delete('/api/articles/' + slug + '/comments/' + id,{ + headers:{ + Authorization : "TOKEN " + currentToken, + "Content-Type": `application/json`, + } + }); +} + + const favoriteArticle = async (slug: string | undefined): Promise => { let currentToken = localStorage.getItem("token"); return await axiosService.post('/api/articles/' + slug + '/favorite',{}, @@ -206,5 +227,6 @@ export { signUp, signIn, addCommentToArticle, getCommentsFromArticle, favoriteArticle, unFavoriteArticle, listArticlesByFavorite, updateArticle, + deleteArticle, deleteCommentsFromArticle, getTags } \ No newline at end of file diff --git a/src/vite-frontend/src/components/commentList.vue b/src/vite-frontend/src/components/commentList.vue index a2e8294..1e54e2e 100644 --- a/src/vite-frontend/src/components/commentList.vue +++ b/src/vite-frontend/src/components/commentList.vue @@ -7,17 +7,21 @@ -   {{comment.author.username}} {{convertDate(comment.updatedAt)}} + + +