Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refac/issue #112 #114

Merged
merged 10 commits into from
Oct 1, 2024
Merged
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
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
Loading