From 61fbe3202c6e7808b6bd47b4388d929ff4d3ee39 Mon Sep 17 00:00:00 2001 From: duswnwn <96100633+duswnwn@users.noreply.github.com> Date: Mon, 10 Apr 2023 16:12:44 +0900 Subject: [PATCH 01/11] Create blank.yml --- .github/workflows/blank.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/blank.yml diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml new file mode 100644 index 0000000..18a6a3e --- /dev/null +++ b/.github/workflows/blank.yml @@ -0,0 +1,36 @@ +# This is a basic workflow to help you get started with Actions + +name: CI + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the "main" branch + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v3 + + # Runs a single command using the runners shell + - name: Run a one-line script + run: echo Hello, world! + + # Runs a set of commands using the runners shell + - name: Run a multi-line script + run: | + echo Add other actions to build, + echo test, and deploy your project. From cf7b07afe3530f8a9509c0da6684a7e1d3288703 Mon Sep 17 00:00:00 2001 From: duswnwn <96100633+duswnwn@users.noreply.github.com> Date: Mon, 10 Apr 2023 16:15:10 +0900 Subject: [PATCH 02/11] Update blank.yml --- .github/workflows/blank.yml | 90 ++++++++++++++++++++++++++----------- 1 file changed, 65 insertions(+), 25 deletions(-) diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml index 18a6a3e..b9255fd 100644 --- a/.github/workflows/blank.yml +++ b/.github/workflows/blank.yml @@ -1,36 +1,76 @@ -# This is a basic workflow to help you get started with Actions +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle -name: CI +name: Deployment -# Controls when the workflow will run on: - # Triggers the workflow on push or pull request events but only for the "main" branch + workflow_dispatch: push: branches: [ "main" ] - pull_request: - branches: [ "main" ] - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: +permissions: + contents: read -# A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - # This workflow contains a single job called "build" build: - # The type of runner that the job will run on runs-on: ubuntu-latest - - # Steps represent a sequence of tasks that will be executed as part of the job steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v3 - - # Runs a single command using the runners shell - - name: Run a one-line script - run: echo Hello, world! - - # Runs a set of commands using the runners shell - - name: Run a multi-line script - run: | - echo Add other actions to build, - echo test, and deploy your project. + - name: Checkout + uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - name: Build with Gradle + uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1 + with: + arguments: build + - uses: actions/upload-artifact@v3 + with: + name: jar + path: build/libs + + send-jar: + needs: build + runs-on: ubuntu-latest + steps: + - name: Download jar + uses: actions/download-artifact@v3 + with: + name: jar + - name: Send jar to remote server + uses: appleboy/scp-action@master + with: + host: 34.64.160.140 + username: duswnwn2717 + source: "real_coding_server-0.0.1-SNAPSHOT.jar" + target: "/home/adulkid.kaya" + key: ${{ secrets.PRIVATE_KEY }} + + run-app: + needs: send-jar + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Move deploy.sh + uses: appleboy/scp-action@master + with: + host: 34.64.160.140 + username: duswnwn2717 + source: "deploy.sh" + target: "/home/{나의 userName}" + key: ${{ secrets.PRIVATE_KEY }} + - name: Execute script + uses: appleboy/ssh-action@master + with: + username: 34.64.160.140 + host: duswnwn2717 + key: ${{ secrets.PRIVATE_KEY }} + script_stop: true + script: cd /home/{나의 userName} && chmod +x deploy.sh && ./deploy.sh From 8fe8804e0dd852b358d74cca71f8257672ca6dd1 Mon Sep 17 00:00:00 2001 From: duswnwn <96100633+duswnwn@users.noreply.github.com> Date: Mon, 10 Apr 2023 16:22:45 +0900 Subject: [PATCH 03/11] Rename blank.yml to development.yml --- .github/workflows/{blank.yml => development.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{blank.yml => development.yml} (100%) diff --git a/.github/workflows/blank.yml b/.github/workflows/development.yml similarity index 100% rename from .github/workflows/blank.yml rename to .github/workflows/development.yml From 3084195778691bea0dd58fbf527ba0c38049c6e0 Mon Sep 17 00:00:00 2001 From: duswnwn <96100633+duswnwn@users.noreply.github.com> Date: Mon, 10 Apr 2023 16:25:09 +0900 Subject: [PATCH 04/11] Update development.yml --- .github/workflows/development.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml index b9255fd..16dc24c 100644 --- a/.github/workflows/development.yml +++ b/.github/workflows/development.yml @@ -49,7 +49,7 @@ jobs: host: 34.64.160.140 username: duswnwn2717 source: "real_coding_server-0.0.1-SNAPSHOT.jar" - target: "/home/adulkid.kaya" + target: "/home/duswnwn2717" key: ${{ secrets.PRIVATE_KEY }} run-app: @@ -73,4 +73,4 @@ jobs: host: duswnwn2717 key: ${{ secrets.PRIVATE_KEY }} script_stop: true - script: cd /home/{나의 userName} && chmod +x deploy.sh && ./deploy.sh + script: cd /home/duswnwn2717 && chmod +x deploy.sh && ./deploy.sh From 8cbc681b2ae630b6cc2ce3044997e35820db5f8a Mon Sep 17 00:00:00 2001 From: duswnwn <96100633+duswnwn@users.noreply.github.com> Date: Mon, 10 Apr 2023 16:29:44 +0900 Subject: [PATCH 05/11] Update development.yml --- .github/workflows/development.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml index 16dc24c..5d59686 100644 --- a/.github/workflows/development.yml +++ b/.github/workflows/development.yml @@ -64,7 +64,7 @@ jobs: host: 34.64.160.140 username: duswnwn2717 source: "deploy.sh" - target: "/home/{나의 userName}" + target: "/home/duswnwn2717" key: ${{ secrets.PRIVATE_KEY }} - name: Execute script uses: appleboy/ssh-action@master From 9507a851b38396922fa7e53f098c1262c01b2f98 Mon Sep 17 00:00:00 2001 From: duswnwn <96100633+duswnwn@users.noreply.github.com> Date: Mon, 10 Apr 2023 16:35:06 +0900 Subject: [PATCH 06/11] Delete deployment.yml --- .github/workflows/deployment.yml | 76 -------------------------------- 1 file changed, 76 deletions(-) delete mode 100644 .github/workflows/deployment.yml diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml deleted file mode 100644 index 2be1220..0000000 --- a/.github/workflows/deployment.yml +++ /dev/null @@ -1,76 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. -# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle - -name: Deployment - -on: - workflow_dispatch: - push: - branches: [ "main" ] - -permissions: - contents: read - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - - name: Build with Gradle - uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1 - with: - arguments: build - - uses: actions/upload-artifact@v3 - with: - name: jar - path: build/libs - - send-jar: - needs: build - runs-on: ubuntu-latest - steps: - - name: Download jar - uses: actions/download-artifact@v3 - with: - name: jar - - name: Send jar to remote server - uses: appleboy/scp-action@master - with: - host: {나의 public ip} - username: {나의 userName} - source: "real_coding_server-0.0.1-SNAPSHOT.jar" - target: "/home/{나의 userName}" - key: ${{ secrets.PRIVATE_KEY }} - - run-app: - needs: send-jar - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Move deploy.sh - uses: appleboy/scp-action@master - with: - host: {나의 public ip} - username: {나의 userName} - source: "deploy.sh" - target: "/home/{나의 userName}" - key: ${{ secrets.PRIVATE_KEY }} - - name: Execute script - uses: appleboy/ssh-action@master - with: - username: {나의 userName} - host: {나의 public ip} - key: ${{ secrets.PRIVATE_KEY }} - script_stop: true - script: cd /home/{나의 userName} && chmod +x deploy.sh && ./deploy.sh From 0d5d4362b1e6cbccc1e7396ba366766499e6179e Mon Sep 17 00:00:00 2001 From: duswnwn <96100633+duswnwn@users.noreply.github.com> Date: Mon, 10 Apr 2023 16:37:27 +0900 Subject: [PATCH 07/11] deployment.yml --- .github/workflows/development.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml index 5d59686..9dab4e9 100644 --- a/.github/workflows/development.yml +++ b/.github/workflows/development.yml @@ -70,7 +70,7 @@ jobs: uses: appleboy/ssh-action@master with: username: 34.64.160.140 - host: duswnwn2717 + host: duswnwn2717 key: ${{ secrets.PRIVATE_KEY }} script_stop: true script: cd /home/duswnwn2717 && chmod +x deploy.sh && ./deploy.sh From b50138ae33a085ecf6e76b0e303ce3afd81eb820 Mon Sep 17 00:00:00 2001 From: duswnwn <96100633+duswnwn@users.noreply.github.com> Date: Mon, 10 Apr 2023 16:42:51 +0900 Subject: [PATCH 08/11] Update development.yml --- .github/workflows/development.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml index 9dab4e9..5d59686 100644 --- a/.github/workflows/development.yml +++ b/.github/workflows/development.yml @@ -70,7 +70,7 @@ jobs: uses: appleboy/ssh-action@master with: username: 34.64.160.140 - host: duswnwn2717 + host: duswnwn2717 key: ${{ secrets.PRIVATE_KEY }} script_stop: true script: cd /home/duswnwn2717 && chmod +x deploy.sh && ./deploy.sh From 5daa343631aded3f31aef400c103c75bc32c4b44 Mon Sep 17 00:00:00 2001 From: duswnwn <96100633+duswnwn@users.noreply.github.com> Date: Mon, 10 Apr 2023 16:46:53 +0900 Subject: [PATCH 09/11] Update development.yml --- .github/workflows/development.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml index 5d59686..c06cf39 100644 --- a/.github/workflows/development.yml +++ b/.github/workflows/development.yml @@ -69,8 +69,8 @@ jobs: - name: Execute script uses: appleboy/ssh-action@master with: - username: 34.64.160.140 - host: duswnwn2717 + username: duswnwn2717 + host: 34.64.160.140 key: ${{ secrets.PRIVATE_KEY }} script_stop: true script: cd /home/duswnwn2717 && chmod +x deploy.sh && ./deploy.sh From 97408926533e594736a26af1185a81a229efded2 Mon Sep 17 00:00:00 2001 From: duswnwn Date: Mon, 17 Apr 2023 21:04:49 +0900 Subject: [PATCH 10/11] feature/202102680 --- .../controller/ProjectController.java | 45 +++++++++++++++++ .../service/ProjectService.java | 48 +++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 src/main/java/com/cnu/real_coding_server/controller/ProjectController.java create mode 100644 src/main/java/com/cnu/real_coding_server/service/ProjectService.java diff --git a/src/main/java/com/cnu/real_coding_server/controller/ProjectController.java b/src/main/java/com/cnu/real_coding_server/controller/ProjectController.java new file mode 100644 index 0000000..d40aa21 --- /dev/null +++ b/src/main/java/com/cnu/real_coding_server/controller/ProjectController.java @@ -0,0 +1,45 @@ +package com.cnu.real_coding_server.controller; + +import com.cnu.real_coding_server.entity.Project; +import com.cnu.real_coding_server.model.request.ProjectRequest; +import com.cnu.real_coding_server.service.ProjectService; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@RestController +@RequestMapping("/projects") +@RequiredArgsConstructor +public class ProjectController { + private final ProjectService projectService; + + @GetMapping + public ResponseEntity createProject(@RequestBody ProjectRequest projectRequest) { + return ResponseEntity.ok(projectService.createProject(projectRequest)); + } + + @GetMapping + public ResponseEntity> getProjects() { + return ResponseEntity.ok(projectService.getProjects()); + } + + @GetMapping("/{projectId}") + public ResponseEntity getProject(@PathVariable("projectId") Integer projectId) { + return ResponseEntity.ok(projectService.getProject(projectId).orElse(null)); + } + + @PutMapping("/{projectId}") + public ResponseEntity updateProject(@PathVariable("projectId")Integer projectId, + @RequestBody ProjectRequest projectRequest) { + return ResponseEntity.ok(projectService.updateProject(projectId, projectRequest).orElse(null)); + } + + @DeleteMapping("/{projectId}") + public ResponseEntity deleteProject(@PathVariable("projectId") Integer projectId) { + projectService.deleteProject(projectId); + + return ResponseEntity.noContent().build(); + } +} diff --git a/src/main/java/com/cnu/real_coding_server/service/ProjectService.java b/src/main/java/com/cnu/real_coding_server/service/ProjectService.java new file mode 100644 index 0000000..9d91f2f --- /dev/null +++ b/src/main/java/com/cnu/real_coding_server/service/ProjectService.java @@ -0,0 +1,48 @@ +package com.cnu.real_coding_server.service; + +import com.cnu.real_coding_server.entity.Post; +import com.cnu.real_coding_server.entity.Project; +import com.cnu.real_coding_server.model.request.PostRequest; +import com.cnu.real_coding_server.model.request.ProjectRequest; +import com.cnu.real_coding_server.repository.ProjectRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Optional; + +@Service +@RequiredArgsConstructor +public class ProjectService { + + private final ProjectRepository projectRepository; + + public Project createProject(ProjectRequest projectRequest) { + return projectRepository.save(projectRequest.toEntity()); + } + + public List getProjects() { + return projectRepository.findAll(); + } + + public Optional getProject(Integer postId) { + return projectRepository.findById(postId); + } + + public Optional updateProject(Integer postId, ProjectRequest projectRequest) { + return projectRepository.findById(postId) + .map(project -> { + project.setTitle(projectRequest.getTitle()); + project.setSummary(projectRequest.getSummary()); + project.setDescription(projectRequest.getDescription());; + project.setStartDate(projectRequest.getStartDate()); + project.setEndDate(projectRequest.getEndDate());; + project.setIsInProgress(projectRequest.getIsInProgress()); + return projectRepository.save(project); + }); + } + public void deleteProject(Integer postId) { + projectRepository.findById(postId) + .ifPresent(projectRepository::delete); + } +} From 2b2ba29b92a99564a95315205fec2f5194b4c6ed Mon Sep 17 00:00:00 2001 From: duswnwn Date: Mon, 17 Apr 2023 21:14:05 +0900 Subject: [PATCH 11/11] feature/202102680 --- .../cnu/real_coding_server/controller/ProjectController.java | 3 +-- .../com/cnu/real_coding_server/service/ProjectService.java | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/cnu/real_coding_server/controller/ProjectController.java b/src/main/java/com/cnu/real_coding_server/controller/ProjectController.java index d40aa21..de3c958 100644 --- a/src/main/java/com/cnu/real_coding_server/controller/ProjectController.java +++ b/src/main/java/com/cnu/real_coding_server/controller/ProjectController.java @@ -31,8 +31,7 @@ public ResponseEntity getProject(@PathVariable("projectId") Integer pro } @PutMapping("/{projectId}") - public ResponseEntity updateProject(@PathVariable("projectId")Integer projectId, - @RequestBody ProjectRequest projectRequest) { + public ResponseEntity updateProject(@PathVariable("projectId")Integer projectId, @RequestBody ProjectRequest projectRequest) { return ResponseEntity.ok(projectService.updateProject(projectId, projectRequest).orElse(null)); } diff --git a/src/main/java/com/cnu/real_coding_server/service/ProjectService.java b/src/main/java/com/cnu/real_coding_server/service/ProjectService.java index 9d91f2f..8ad1de9 100644 --- a/src/main/java/com/cnu/real_coding_server/service/ProjectService.java +++ b/src/main/java/com/cnu/real_coding_server/service/ProjectService.java @@ -38,6 +38,7 @@ public Optional updateProject(Integer postId, ProjectRequest projectReq project.setStartDate(projectRequest.getStartDate()); project.setEndDate(projectRequest.getEndDate());; project.setIsInProgress(projectRequest.getIsInProgress()); + return projectRepository.save(project); }); }