diff --git a/README.md b/README.md index fbd77ce..d592cdd 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,41 @@ # Balance-Vote-Server -[![Java CI only on develop environment with Gradle](https://github.com/Balance-Vote/Balance-Vote-Server/actions/workflows/dev_gradle.yml/badge.svg)](https://github.com/Balance-Vote/Balance-Vote-Server/actions/workflows/dev_gradle.yml) +> ## Balance-Vote-Server는 BalanceVote App의 API 서버입니다. +> ### 구현 기능 +> +> | Feature | Stack | | +> |---------|-------|-| +> | Server | Spring Boot || +> | RDBS | MySql || +> | API Doc | Swagger-UI || +> | CI | Github Actions || +> | CD | AWS CodeDeploy || +> | Deploy | AWS EC2 | | +> ------------------------------------- +> ### 역할 분담(R & R) +> | 담당자 | 담당 기능 | | +> |-------|-----------|-| +> | 최준만 | SpringBoot 초기 세팅 및 MVC 구성 | :heavy_check_mark: | +> | | User, Comment API | :heavy_check_mark: | +> | | AWS EC2 구성 | :heavy_check_mark: | +> | | AWS CodeDeploy 배포 자동화 구현(CD) | :heavy_check_mark: | +> | | RDBS 테이블 설계 및 구현 | :heavy_check_mark: | +> | 이동건 | Vote Post API | :heavy_check_mark: | +> | | Swagger-ui API 명세사이트 구성 | :heavy_check_mark: | +> | | Github Actions 지속적 통합 과정 구현(CI) | :heavy_check_mark: | +> | | RDBS 테이블 설계 및 구현 | :heavy_check_mark: | +>-------------------------------------- +> ### 기능 설명 +> - API는 유저, 투표 게시물, 댓글 및 대댓글 CRUD로 구성 +>-------------------------------------- +> - API 명세는 Swagger-UI를 통해 구성 +> +> | Swagger UI 구현 | API 명세 및 테스트 | +> |----------------------------|-------------------------------| +> | ![swagger-ui](https://user-images.githubusercontent.com/22022776/174628458-7834d296-7981-4ec6-a204-0787dbc4eb14.png) | ![swagger-ui](https://user-images.githubusercontent.com/22022776/174628957-66d6ee3e-5c4b-4d3a-8fa3-97344e3bc39d.png) | +>--------------------------------------- +> - 자동 배포(Github Actions & AWS) +> +> | CD/CI 구성 및 동작 | +> |----------------------------| +> |![image](https://user-images.githubusercontent.com/22022776/174751746-2eca574c-8c8f-466b-a6e2-fb2893d2be6a.png)| diff --git a/src/main/java/com/BalanceVote/BalanceVoteServer/contorller/CommentController.java b/src/main/java/com/BalanceVote/BalanceVoteServer/contorller/CommentController.java index 8f6ee31..43bf791 100644 --- a/src/main/java/com/BalanceVote/BalanceVoteServer/contorller/CommentController.java +++ b/src/main/java/com/BalanceVote/BalanceVoteServer/contorller/CommentController.java @@ -36,7 +36,7 @@ public class CommentController { */ @GetMapping("/comment/get-comment/parent/post-id/{postId}") @ApiOperation(value = "포스트 댓글 조회", notes = "특정 포스트의 부모 댓글(1차댓글) 조회") - @ApiImplicitParam(name="postId", required = true,value = "게시물 ID",dataType = "int") + @ApiImplicitParam(name="postId", required = true,value = "게시물 ID",dataType = "string") public List getPostParentComment(@PathVariable String postId){ return parentCommentRepository.findAllByPostId(postId); } @@ -60,7 +60,7 @@ public List getUserComment(@PathVariable String uuid){ @GetMapping("/comment/get-comment/child/parent-id/{parentCmtId}") @ApiOperation(value = "대댓글 조회", notes = "특정 부모 댓글(1차 댓글)의 자식 댓글(대댓글) 조회") @ApiImplicitParam(name="parentCmtId", required = true,value = "부모 댓글 ID",dataType = "int") - public List getChildComment(@PathVariable String parentCmtId){ + public List getChildComment(@PathVariable Long parentCmtId){ List childComments = childCommentRepository.findAllByParentCmtId(parentCmtId); return childComments; } diff --git a/src/main/java/com/BalanceVote/BalanceVoteServer/dto/ChildCommentForm.java b/src/main/java/com/BalanceVote/BalanceVoteServer/dto/ChildCommentForm.java index f4b6edf..fca1437 100644 --- a/src/main/java/com/BalanceVote/BalanceVoteServer/dto/ChildCommentForm.java +++ b/src/main/java/com/BalanceVote/BalanceVoteServer/dto/ChildCommentForm.java @@ -26,7 +26,7 @@ public class ChildCommentForm { @ApiModelProperty(example = "1", value = "부모 댓글 ID",required = true) private Long parentCmtId; @ApiModelProperty(example = "1", value = "게시물 ID",required = true) - private Long postId; + private String postId; @ApiModelProperty(example = "junman95", value = "범용 고유 식별자",required = true) private String uuid; /** diff --git a/src/main/java/com/BalanceVote/BalanceVoteServer/dto/ParentCommentForm.java b/src/main/java/com/BalanceVote/BalanceVoteServer/dto/ParentCommentForm.java index c82ef9d..dbe6a71 100644 --- a/src/main/java/com/BalanceVote/BalanceVoteServer/dto/ParentCommentForm.java +++ b/src/main/java/com/BalanceVote/BalanceVoteServer/dto/ParentCommentForm.java @@ -24,7 +24,7 @@ public class ParentCommentForm { @ApiModelProperty(hidden = true) private Integer likeCnt; @ApiModelProperty(example = "1", value = "게시물 ID",required = true) - private Long postId; + private String postId; @ApiModelProperty(example = "junman95", value = "범용 고유 식별자",required = true) private String uuid; /** diff --git a/src/main/java/com/BalanceVote/BalanceVoteServer/entity/ChildComment.java b/src/main/java/com/BalanceVote/BalanceVoteServer/entity/ChildComment.java index f6f172f..8161d4f 100644 --- a/src/main/java/com/BalanceVote/BalanceVoteServer/entity/ChildComment.java +++ b/src/main/java/com/BalanceVote/BalanceVoteServer/entity/ChildComment.java @@ -35,7 +35,7 @@ public class ChildComment { private Long parentCmtId; @Column(name = "post_id") @ApiModelProperty(example = "1",value = "게시글 ID") - private Long postId; + private String postId; @Column(name = "uuid") @ApiModelProperty(example = "junman95",value = "범용 고유 식별자") private String uuid; diff --git a/src/main/java/com/BalanceVote/BalanceVoteServer/entity/ParentComment.java b/src/main/java/com/BalanceVote/BalanceVoteServer/entity/ParentComment.java index efa55b6..51d8f77 100644 --- a/src/main/java/com/BalanceVote/BalanceVoteServer/entity/ParentComment.java +++ b/src/main/java/com/BalanceVote/BalanceVoteServer/entity/ParentComment.java @@ -33,7 +33,7 @@ public class ParentComment { private Integer likeCnt; @Column(name = "post_id") @ApiModelProperty(example = "1",value = "게시글 ID") - private Long postId; + private String postId; @Column(name = "uuid") @ApiModelProperty(example = "junman95",value = "범용 고유 식별자") private String uuid; diff --git a/src/main/java/com/BalanceVote/BalanceVoteServer/repository/ChildCommentRepository.java b/src/main/java/com/BalanceVote/BalanceVoteServer/repository/ChildCommentRepository.java index 97ed8ba..48b03c7 100644 --- a/src/main/java/com/BalanceVote/BalanceVoteServer/repository/ChildCommentRepository.java +++ b/src/main/java/com/BalanceVote/BalanceVoteServer/repository/ChildCommentRepository.java @@ -1,12 +1,17 @@ package com.BalanceVote.BalanceVoteServer.repository; import com.BalanceVote.BalanceVoteServer.entity.ChildComment; +import com.BalanceVote.BalanceVoteServer.entity.ParentComment; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import java.util.List; import java.util.Optional; public interface ChildCommentRepository extends JpaRepository { List findAllByUuid(String uuid); - List findAllByParentCmtId(String parentCmtId); -} + + @Query(value = "SELECT child.* FROM balance_vote_database.child_comment child WHERE child.parent_id = :parentCmtId ORDER BY time_stamp DESC", nativeQuery = true) + List findAllByParentCmtId(@Param(value = "parentCmtId") Long parentCmtId); +} \ No newline at end of file diff --git a/src/main/java/com/BalanceVote/BalanceVoteServer/repository/ParentCommentRepository.java b/src/main/java/com/BalanceVote/BalanceVoteServer/repository/ParentCommentRepository.java index 4700f78..bc1d934 100644 --- a/src/main/java/com/BalanceVote/BalanceVoteServer/repository/ParentCommentRepository.java +++ b/src/main/java/com/BalanceVote/BalanceVoteServer/repository/ParentCommentRepository.java @@ -12,7 +12,8 @@ */ public interface ParentCommentRepository extends JpaRepository { - List findAllByPostId(String postId); + @Query(value = "SELECT parent.* FROM balance_vote_database.parent_comment parent WHERE parent.post_id = :postId ORDER BY time_stamp DESC", nativeQuery = true) + List findAllByPostId(@Param(value = "postId") String postId); @Query(value = "SELECT parent.* FROM balance_vote_database.parent_comment parent LEFT OUTER JOIN balance_vote_database.child_comment child ON child.parent_id = parent.id WHERE parent.uuid = :uuid ORDER BY time_stamp DESC", nativeQuery = true) List findUserComments(@Param(value = "uuid") String uuid);