Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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 |<img src="https://user-images.githubusercontent.com/22022776/174630380-998da0b9-4e5a-4b7d-baa4-ac930632fe39.png" height="40px">|
> | RDBS | MySql |<img src="https://user-images.githubusercontent.com/22022776/174739483-c6024a78-8da6-45b4-89ab-c2c7ee4f5222.png" height="40px">|
> | API Doc | Swagger-UI |<img src="https://user-images.githubusercontent.com/22022776/174738161-6ff5c992-00a8-4b8d-a28c-a64be7e2548d.png" height="40px">|
> | CI | Github Actions |<img src="https://user-images.githubusercontent.com/22022776/174737872-343461c0-a5ec-4164-bd68-5639bb5ca2fe.png" height="40px">|
> | CD | AWS CodeDeploy |<img src="https://user-images.githubusercontent.com/22022776/174738914-fc290e74-82ee-4d4d-a9e5-e656e1bbec8d.png" height="40px">|
> | Deploy | AWS EC2 | <img src="https://user-images.githubusercontent.com/22022776/174738914-fc290e74-82ee-4d4d-a9e5-e656e1bbec8d.png" height="40px">|
> -------------------------------------
> ### 역할 분담(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를 통해 구성
>
> | <sub> Swagger UI 구현 <sub> | <sub> API 명세 및 테스트 <sub> |
> |----------------------------|-------------------------------|
> | ![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)
>
> | <sub> CD/CI 구성 및 동작 <sub> |
> |----------------------------|
> |![image](https://user-images.githubusercontent.com/22022776/174751746-2eca574c-8c8f-466b-a6e2-fb2893d2be6a.png)|
Original file line number Diff line number Diff line change
Expand Up @@ -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<ParentComment> getPostParentComment(@PathVariable String postId){
return parentCommentRepository.findAllByPostId(postId);
}
Expand All @@ -60,7 +60,7 @@ public List<ParentComment> 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<ChildComment> getChildComment(@PathVariable String parentCmtId){
public List<ChildComment> getChildComment(@PathVariable Long parentCmtId){
List<ChildComment> childComments = childCommentRepository.findAllByParentCmtId(parentCmtId);
return childComments;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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<ChildComment, Long> {
List<ChildComment> findAllByUuid(String uuid);
List<ChildComment> 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<ChildComment> findAllByParentCmtId(@Param(value = "parentCmtId") Long parentCmtId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
*/
public interface ParentCommentRepository extends JpaRepository<ParentComment,Long> {

List<ParentComment> 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<ParentComment> 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<ParentComment> findUserComments(@Param(value = "uuid") String uuid);
Expand Down