Skip to content

Commit

Permalink
Merge pull request #53 from codesquad-issue-team-05/be
Browse files Browse the repository at this point in the history
[TEAM#05] [BE] 3주차 PR
  • Loading branch information
kses1010 authored Aug 13, 2023
2 parents 21a0056 + e854dbe commit 8717dc1
Show file tree
Hide file tree
Showing 91 changed files with 3,144 additions and 555 deletions.
111 changes: 111 additions & 0 deletions .github/workflows/deploy.yml
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,4 @@ dist
/.idea/compiler.xml
/.idea/codeStyles/codeStyleConfig.xml
/.idea/checkstyle-idea.xml
*.yml
/.idea/
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,7 @@
<img src="https://img.shields.io/badge/TypeScript-3178C6.svg?style=for-the-badge&logo=TypeScript&logoColor=white" /> <img src="https://img.shields.io/badge/React-61DAFB.svg?style=for-the-badge&logo=React&logoColor=black" /> <img src="https://img.shields.io/badge/React%20Router-CA4245.svg?style=for-the-badge&logo=React-Router&logoColor=white" /> <img src="https://img.shields.io/badge/Vite-646CFF.svg?style=for-the-badge&logo=Vite&logoColor=white" />
### BE
<img src="https://img.shields.io/badge/Spring%20Boot-6DB33F.svg?style=for-the-badge&logo=Spring-Boot&logoColor=white" /> <img src="https://img.shields.io/badge/MySQL-4479A1.svg?style=for-the-badge&logo=MySQL&logoColor=white" />

## ERD
![image](https://github.com/codesquad-issue-team-05/issue-tracker-max/assets/103398897/0ffd58d6-e2b2-4786-a916-927623f670f8)

2 changes: 2 additions & 0 deletions be/issue/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ out/

### VS Code ###
.vscode/


19 changes: 19 additions & 0 deletions be/issue/appspec.yml
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
2 changes: 0 additions & 2 deletions be/issue/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ repositories {

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
// implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
compileOnly 'org.projectlombok:lombok'
Expand All @@ -39,7 +38,6 @@ dependencies {
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
// 패스워드 암호화
implementation group: 'org.mindrot', name: 'jbcrypt', version: '0.4'

implementation 'org.springframework.boot:spring-boot-starter-webflux'

}
Expand Down
12 changes: 12 additions & 0 deletions be/issue/deploy-app.sh
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 "배포 성공"
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());
}
}
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;
}
}
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;

}
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;
}
}
Loading

0 comments on commit 8717dc1

Please sign in to comment.