forked from codesquad-members-2023/issue-tracker-max
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from codesquad-issue-team-05/be
[TEAM#05] [BE] 3주차 PR
- Loading branch information
Showing
91 changed files
with
3,144 additions
and
555 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
name: Java CI with Gradle | ||
|
||
on: | ||
push: | ||
branches: release | ||
|
||
env: | ||
APPLICATION_YML_FILE_PATH: ./src/main/resources/application.yml | ||
AWS_REGION: ap-northeast-2 | ||
S3_BUCKET_NAME: issue-tracker-s3-bucket | ||
CODE_DEPLOY_APPLICATION_NAME: issue-tracker-codedeploy-app | ||
CODE_DEPLOY_DEPLOYMENT_GROUP_NAME: issuetracker-codedeploy-deployment-group | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
app-build-and-deploy: | ||
name: BE Deploy | ||
runs-on: ubuntu-latest | ||
environment: production | ||
defaults: | ||
run: | ||
shell: bash | ||
working-directory: ./be/issue | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '11' | ||
distribution: 'temurin' | ||
|
||
- name: Output application information | ||
run: echo '${{ secrets.APPLICATION }}' > '${{ env.APPLICATION_YML_FILE_PATH }}' | ||
|
||
- name: Build with Gradle | ||
run: | | ||
chmod +x gradlew | ||
./gradlew clean build -x test | ||
- name: Make zip file | ||
run: zip -r ./$GITHUB_SHA.zip . | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v2 | ||
with: | ||
aws-access-key-id: ${{secrets.AWS_ACCESS_KEY_ID}} | ||
aws-secret-access-key: ${{secrets.AWS_SECRET_ACCESS_KEY}} | ||
aws-region: ${{env.AWS_REGION}} | ||
|
||
- name: Upload to S3 | ||
run: aws s3 cp | ||
--region '${{ env.AWS_REGION }}' ./$GITHUB_SHA.zip | ||
s3://$S3_BUCKET_NAME/Build/$GITHUB_SHA.zip | ||
|
||
- name: Code Deploy | ||
run: aws deploy create-deployment | ||
--application-name $CODE_DEPLOY_APPLICATION_NAME | ||
--deployment-config-name CodeDeployDefault.AllAtOnce | ||
--deployment-group-name $CODE_DEPLOY_DEPLOYMENT_GROUP_NAME | ||
--s3-location bucket=$S3_BUCKET_NAME,bundleType=zip,key=Build/$GITHUB_SHA.zip | ||
|
||
web-build-and-deploy: | ||
name: FE Deploy | ||
needs: app-build-and-deploy | ||
runs-on: ubuntu-latest | ||
environment: production | ||
defaults: | ||
run: | ||
shell: bash | ||
working-directory: ./frontend | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '18' | ||
|
||
- name: Build with npm | ||
run: | | ||
npm install | ||
npm run build | ||
- name: Make zip file | ||
run: zip -r ./react-build.zip . | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v2 | ||
with: | ||
aws-access-key-id: ${{secrets.AWS_ACCESS_KEY_ID}} | ||
aws-secret-access-key: ${{secrets.AWS_SECRET_ACCESS_KEY}} | ||
aws-region: ${{env.AWS_REGION}} | ||
|
||
- name: Upload to S3 | ||
run: aws s3 cp | ||
--region ${{ env.AWS_REGION }} ./react-build.zip | ||
s3://$S3_BUCKET_NAME/Build/react-build.zip | ||
|
||
- name: Code Deploy | ||
run: aws deploy create-deployment | ||
--application-name $CODE_DEPLOY_APPLICATION_NAME | ||
--deployment-config-name CodeDeployDefault.AllAtOnce | ||
--deployment-group-name $CODE_DEPLOY_DEPLOYMENT_GROUP_NAME | ||
--s3-location bucket=$S3_BUCKET_NAME,bundleType=zip,key=Build/react-build.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -141,4 +141,4 @@ dist | |
/.idea/compiler.xml | ||
/.idea/codeStyles/codeStyleConfig.xml | ||
/.idea/checkstyle-idea.xml | ||
*.yml | ||
/.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,5 @@ out/ | |
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
version: 0.0 | ||
os: linux | ||
|
||
files: | ||
- source: / | ||
destination: /home/ubuntu/app | ||
overwrite: yes | ||
|
||
permissions: | ||
- object: / | ||
pattern: "**" | ||
owner: ubuntu | ||
group: ubuntu | ||
|
||
hooks: | ||
AfterInstall: | ||
- location: deploy-app.sh | ||
timeout: 60 | ||
runas: ubuntu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
ISSUE_ID=$(jps | grep be | awk '{ print $1 }') | ||
|
||
if [ -z $ISSUE_ID ]; then | ||
echo "동작중인 서버가 없습니다." | ||
else | ||
echo "$ISSUE_ID 프로세스를 삭제합니다." | ||
kill -9 $ISSUE_ID | ||
fi | ||
|
||
echo "서버 시작" | ||
nohup java -jar ~/app/build/libs/issue-0.0.1-SNAPSHOT.jar >/home/ubuntu/app/log.txt 2>&1 & | ||
echo "배포 성공" |
49 changes: 48 additions & 1 deletion
49
be/issue/src/main/java/codesquad/issueTracker/comment/controller/CommentController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,59 @@ | ||
package codesquad.issueTracker.comment.controller; | ||
|
||
import static codesquad.issueTracker.global.exception.SuccessCode.*; | ||
|
||
import java.util.List; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
|
||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PatchMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import codesquad.issueTracker.comment.dto.CommentRequestDto; | ||
import codesquad.issueTracker.comment.dto.CommentResponseDto; | ||
import codesquad.issueTracker.comment.service.CommentService; | ||
import codesquad.issueTracker.global.common.ApiResponse; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api") | ||
public class CommentController { | ||
|
||
private final CommentService commentService; | ||
|
||
@GetMapping("/issues/{issueId}/comments") | ||
public ApiResponse<List<CommentResponseDto>> getComments(@PathVariable Long issueId) { | ||
List<CommentResponseDto> commentResponseDtos = commentService.getComments(issueId); | ||
|
||
return ApiResponse.success(SUCCESS.getStatus(), commentResponseDtos); | ||
} | ||
|
||
@PostMapping("/issues/{issueId}/comments") | ||
public ApiResponse<String> save(@PathVariable Long issueId, | ||
@RequestBody CommentRequestDto commentRequestDto, | ||
HttpServletRequest request) { | ||
commentService.save(request, issueId, commentRequestDto); | ||
|
||
return ApiResponse.success(SUCCESS.getStatus(), SUCCESS.getMessage()); | ||
} | ||
|
||
@PatchMapping("/issues/comments/{commentId}") | ||
public ApiResponse<String> modify(@PathVariable Long commentId, | ||
@RequestBody CommentRequestDto commentRequestDto) { | ||
commentService.modify(commentId, commentRequestDto); | ||
return ApiResponse.success(SUCCESS.getStatus(), SUCCESS.getMessage()); | ||
} | ||
|
||
@DeleteMapping("issues/comments/{commentId}") | ||
public ApiResponse<String> delete(@PathVariable Long commentId) { | ||
commentService.delete(commentId); | ||
return ApiResponse.success(SUCCESS.getStatus(), SUCCESS.getMessage()); | ||
} | ||
} |
29 changes: 13 additions & 16 deletions
29
be/issue/src/main/java/codesquad/issueTracker/comment/domain/Comment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,23 @@ | ||
package codesquad.issueTracker.comment.domain; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class Comment { | ||
private Long id; | ||
private Long userId; | ||
private Long issueId; | ||
private String content; | ||
private LocalDateTime createdAt; | ||
|
||
private Long id; | ||
private Long userId; | ||
private Long issueId; | ||
private String content; | ||
private LocalDateTime createdAt; | ||
|
||
@Builder | ||
|
||
public Comment(Long id, Long userId, Long issueId, String content, LocalDateTime createdAt) { | ||
this.id = id; | ||
this.userId = userId; | ||
this.issueId = issueId; | ||
this.content = content; | ||
this.createdAt = createdAt; | ||
} | ||
@Builder | ||
public Comment(Long id, Long userId, Long issueId, String content, LocalDateTime createdAt) { | ||
this.id = id; | ||
this.userId = userId; | ||
this.issueId = issueId; | ||
this.content = content; | ||
this.createdAt = createdAt; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
be/issue/src/main/java/codesquad/issueTracker/comment/dto/CommentRequestDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package codesquad.issueTracker.comment.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class CommentRequestDto { | ||
|
||
private String content; | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
be/issue/src/main/java/codesquad/issueTracker/comment/dto/CommentResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package codesquad.issueTracker.comment.dto; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import codesquad.issueTracker.comment.vo.CommentUserVo; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class CommentResponseDto { | ||
|
||
private Long id; | ||
private LocalDateTime createdAt; | ||
private String content; | ||
private CommentUserVo writer; | ||
|
||
@Builder | ||
public CommentResponseDto(Long id, LocalDateTime createdAt, String content, CommentUserVo writer) { | ||
this.id = id; | ||
this.createdAt = createdAt; | ||
this.content = content; | ||
this.writer = writer; | ||
} | ||
} |
Oops, something went wrong.