Skip to content

Commit

Permalink
Refac/issue #112 docker 환경변수 주입하도록 수정, 컨벤션 맞춰 수정(#114)
Browse files Browse the repository at this point in the history
* Refac: yml 분리 규칙 변경(프로필 -> 기능)

* Fix: 테스트 워크플로, 환경변수 수정

* Fix: dev 서버 배포 워크플로 수정

* Fix: main 서버 배포 워크플로 수정

* Refac: PK 네이밍 규칙 통일

* Refac: User 관련 예외처리 코드 통일

* Refac: 지원서(admin) 관련 예외처리 코드 통일

* Refac: response dto(member, team) 클래스 위치 변경

* Fix: dto getter 추가

* Feat: health check 엔드포인트 생성
  • Loading branch information
kwonssshyeon authored Oct 1, 2024
1 parent bb0c4ae commit b5b0abf
Show file tree
Hide file tree
Showing 32 changed files with 278 additions and 178 deletions.
20 changes: 4 additions & 16 deletions .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@ name: Deploy dev branch
on:
push:
branches: [ "dev" ]


jobs:
build:
runs-on: ubuntu-latest

permissions:
contents: read

Expand All @@ -28,14 +25,6 @@ jobs:
java-version: '17'
distribution: 'temurin'

# set up application file
- name: Create application.yml
run: |
mkdir -p ./src/main/resources
cd ./src/main/resources
echo "${{ secrets.APPLICATION }}" > application.yml
echo "${{ secrets.APPLICATION_PROD }}" > application-prod.yml
# apply caching
- name: Gradle Caching
uses: actions/cache@v3
Expand All @@ -51,7 +40,7 @@ jobs:
- name: Setup Gradle
run: |
chmod +x ./gradlew
./gradlew clean build -x test -Pprofile=prod
./gradlew clean build -x test -Pprofile=dev
# login dockerhub
- name: docker login
Expand Down Expand Up @@ -83,9 +72,8 @@ jobs:
key: ${{ secrets.PRIVATE_KEY }}
port: ${{ secrets.PORT }}
script: |
sudo docker stop ${{ secrets.DOCKER_IMAGENAME }}
sudo docker rm ${{ secrets.DOCKER_IMAGENAME }}
sudo docker rmi ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_IMAGENAME }}
sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_IMAGENAME }}
sudo docker stop ${{ secrets.DOCKER_IMAGENAME }} 2>/dev/null || true
sudo docker rm ${{ secrets.DOCKER_IMAGENAME }}
sudo docker-compose -f docker-compose.yml up -d
sudo docker system prune -f
sudo docker-compose -f docker-compose.yml up -d
18 changes: 3 additions & 15 deletions .github/workflows/deploy-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@ name: Deploy main branch
on:
push:
branches: [ "main" ]


jobs:
build:
runs-on: ubuntu-latest

permissions:
contents: read

Expand All @@ -28,14 +25,6 @@ jobs:
java-version: '17'
distribution: 'temurin'

# set up application file
- name: Create application.yml
run: |
mkdir -p ./src/main/resources
cd ./src/main/resources
echo "${{ secrets.APPLICATION }}" > application.yml
echo "${{ secrets.APPLICATION_MAIN }}" > application-main.yml
# apply caching
- name: Gradle Caching
uses: actions/cache@v3
Expand All @@ -51,7 +40,7 @@ jobs:
- name: Setup Gradle
run: |
chmod +x ./gradlew
./gradlew clean build -x test -Pprofile=main
./gradlew clean build -x test -Pprofile=prod
# login dockerhub
- name: docker login
Expand Down Expand Up @@ -83,9 +72,8 @@ jobs:
key: ${{ secrets.MAIN_PRIVATE_KEY }}
port: ${{ secrets.PORT }}
script: |
sudo docker stop ${{ secrets.DOCKER_IMAGENAME }}
sudo docker rm ${{ secrets.DOCKER_IMAGENAME }}
sudo docker rmi ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_IMAGENAME }}
sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_IMAGENAME }}
sudo docker stop ${{ secrets.DOCKER_IMAGENAME }} 2>/dev/null || true
sudo docker rm ${{ secrets.DOCKER_IMAGENAME }}
sudo docker-compose -f docker-compose.yml up -d
sudo docker system prune -f
13 changes: 1 addition & 12 deletions .github/workflows/test-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@ name: Test dev branch
on:
pull_request:
branches: [ "dev" ]


jobs:
test:
runs-on: ubuntu-latest

permissions: write-all

# set up java
Expand All @@ -27,14 +24,6 @@ jobs:
java-version: '17'
distribution: 'temurin'

# set up application file
- name: Create application.yml
run: |
mkdir -p ./src/main/resources
cd ./src/main/resources
echo "${{ secrets.APPLICATION }}" > application.yml
echo "${{ secrets.APPLICATION_TEST }}" > application-test.yml
# apply caching
- name: Gradle Caching
uses: actions/cache@v3
Expand All @@ -50,7 +39,7 @@ jobs:
- name: Setup Gradle
run: |
chmod +x ./gradlew
./gradlew clean build -Pprofile=test
./gradlew clean build
- name: Publish Test Result
uses: EnricoMi/publish-unit-test-result-action@v1
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,5 @@ out/
### VS Code ###
.vscode/

/src/main/resources/**/*.yml
src/main/resources/static/index.html
.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.gdsc_knu.official_homepage.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HealthCheckController {
@GetMapping("/check")
public String healthCheck(){
return "status up";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.gdsc_knu.official_homepage.authentication.jwt.JwtMemberDetail;
import com.gdsc_knu.official_homepage.dto.member.MemberRequest;
import com.gdsc_knu.official_homepage.dto.member.MemberResponse;
import com.gdsc_knu.official_homepage.dto.member.TeamInfoResponse;
import com.gdsc_knu.official_homepage.entity.Member;
import com.gdsc_knu.official_homepage.entity.enumeration.Role;
import com.gdsc_knu.official_homepage.entity.enumeration.Track;
Expand Down Expand Up @@ -32,7 +31,7 @@ public void additionalInfo(@TokenMember JwtMemberDetail jwtMemberDetail,

@GetMapping()
@Operation(summary="사용자 정보 조회 API")
public ResponseEntity<MemberResponse> getMemberInfo(@TokenMember JwtMemberDetail jwtMemberDetail){
public ResponseEntity<MemberResponse.Main> getMemberInfo(@TokenMember JwtMemberDetail jwtMemberDetail){
return ResponseEntity.ok().body(memberInfoService.getMemberInfo(jwtMemberDetail.getId()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import com.gdsc_knu.official_homepage.annotation.TokenMember;
import com.gdsc_knu.official_homepage.authentication.jwt.JwtMemberDetail;
import com.gdsc_knu.official_homepage.dto.member.TeamInfoResponse;
import com.gdsc_knu.official_homepage.dto.member.MemberResponse;
import com.gdsc_knu.official_homepage.dto.team.TeamResponse;
import com.gdsc_knu.official_homepage.service.MemberInfoService;
import com.gdsc_knu.official_homepage.service.TeamService;
import com.gdsc_knu.official_homepage.service.team.TeamService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
Expand All @@ -25,14 +25,14 @@ public class TeamController {
@GetMapping("/{teamId}/member")
@Operation(summary = "팀원 정보 조회 API",
description = "해당 팀의 팀원목록(유저 ID, 이름, 직렬)을 반환합니다. (미배치된 팀은 조회되지 않습니다.)")
public ResponseEntity<List<TeamResponse.MemberInfo>> getTeamMembers(@PathVariable("teamId") Long teamId) {
public ResponseEntity<List<MemberResponse.WithTrack>> getTeamMembers(@PathVariable("teamId") Long teamId) {
return ResponseEntity.ok().body(teamService.getTeamMember(teamId));
}

@GetMapping()
@Operation(summary="현재 로그인한 사용자가 속한 팀 정보 조회 API",
description = "현재 로그인한 사용자가 속한 팀 정보(팀 ID, 팀 이름) 리스트를 반환합니다.")
public ResponseEntity<List<TeamInfoResponse>> getMemberTeamInfo(@TokenMember JwtMemberDetail jwtMemberDetail){
public ResponseEntity<List<TeamResponse.Main>> getMemberTeamInfo(@TokenMember JwtMemberDetail jwtMemberDetail){
return ResponseEntity.ok().body(memberInfoService.getMemberTeamInfo(jwtMemberDetail.getId()));
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.gdsc_knu.official_homepage.dto.admin.memberStatus;

import com.gdsc_knu.official_homepage.dto.member.TeamInfoResponse;
import com.gdsc_knu.official_homepage.dto.team.TeamResponse;
import com.gdsc_knu.official_homepage.entity.Member;
import com.gdsc_knu.official_homepage.entity.enumeration.Role;
import com.gdsc_knu.official_homepage.entity.enumeration.Track;
Expand All @@ -22,7 +22,7 @@ public class AdminMemberResponse {
private String studentNumber;
private String email;
private String phoneNumber;
private List<TeamInfoResponse> teams;
private List<TeamResponse.Main> teams;
private Role role;

public static AdminMemberResponse from(Member member) {
Expand All @@ -34,7 +34,7 @@ public static AdminMemberResponse from(Member member) {
.email(member.getEmail())
.phoneNumber(member.getPhoneNumber())
.teams(member.getTeams().stream()
.map(TeamInfoResponse::from)
.map(TeamResponse.Main::from)
.toList())
.role(member.getRole())
.build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.gdsc_knu.official_homepage.dto.admin.team;

import com.gdsc_knu.official_homepage.dto.member.TeamInfoResponse;
import com.gdsc_knu.official_homepage.dto.team.TeamResponse;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -19,7 +19,7 @@ public static class Team {
private Long id;
private String teamName;
@Builder.Default
private List<TeamInfoResponse> subTeams = new ArrayList<>();
private List<TeamResponse.Main> subTeams = new ArrayList<>();
}

@Getter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,57 @@
package com.gdsc_knu.official_homepage.dto.member;

import com.gdsc_knu.official_homepage.dto.team.TeamResponse;
import com.gdsc_knu.official_homepage.entity.Member;
import com.gdsc_knu.official_homepage.entity.enumeration.Role;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.List;

@Getter
@NoArgsConstructor
public class MemberResponse {
private String name;
private String profileUrl;
private int age;
private String major;
private String studentNumber;
private String email;
private Role role;
private List<TeamInfoResponse> teamInfos;
public MemberResponse(Member member, List<TeamInfoResponse> teamInfos){
this.name = member.getName();
this.profileUrl = member.getProfileUrl();
this.age = member.getAge();
this.major = member.getMajor();
this.studentNumber = member.getStudentNumber();
this.email = member.getEmail();
this.role = member.getRole();
this.teamInfos = teamInfos;
@Getter
@Builder
@AllArgsConstructor
public static class Main {
private String name;
private String profileUrl;
private int age;
private String major;
private String studentNumber;
private String email;
private Role role;
private List<TeamResponse.Main> teamInfos;
public static MemberResponse.Main from (Member member) {
return Main.builder()
.name(member.getName())
.profileUrl(member.getProfileUrl())
.age(member.getAge())
.major(member.getMajor())
.studentNumber(member.getStudentNumber())
.email(member.getEmail())
.role(member.getRole())
.teamInfos(member.getTeams().stream()
.map(TeamResponse.Main::from)
.toList())
.build();
}
}

@Getter
@Builder
@AllArgsConstructor
public static class WithTrack {
private Long id;
private String name;
private String track;

public static WithTrack from(Member member) {
return WithTrack.builder()
.id(member.getId())
.name(member.getName())
.track(member.getTrack().name())
.build();
}
}
}

This file was deleted.

This file was deleted.

Loading

0 comments on commit b5b0abf

Please sign in to comment.