Skip to content

Commit

Permalink
Merge pull request #136 from GDG-on-Campus-KNU/dev
Browse files Browse the repository at this point in the history
Release: v2.0.0
  • Loading branch information
kwonssshyeon authored Nov 20, 2024
2 parents 6c422b2 + 30da5ac commit eb0730b
Show file tree
Hide file tree
Showing 89 changed files with 2,885 additions and 621 deletions.
20 changes: 2 additions & 18 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,4 @@ jobs:
key: ${{ secrets.PRIVATE_KEY }}
port: ${{ secrets.PORT }}
script: |
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
./deploy.sh
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
18 changes: 6 additions & 12 deletions .github/workflows/test-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ name: Test dev branch
on:
pull_request:
branches: [ "dev" ]


jobs:
test:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
contents: read
checks: write

permissions: write-all

# set up java
steps:
Expand All @@ -27,14 +29,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 +44,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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ out/
### VS Code ###
.vscode/

/src/main/resources/**/*.yml
src/main/resources/static/index.html
src/main/resources/images/**
.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableScheduling;

@SpringBootApplication
@EnableJpaAuditing
@EnableCaching
@EnableScheduling
public class OfficialHomepageApplication {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
Expand All @@ -29,7 +30,9 @@ public class SecurityConfig {


private static final String[] WHITE_LIST = {
"/**",
"/api/post/{postId:\\d+}/comment/**",
"/api/post/trending",
"/api/post/**"
};
private static final String[] MEMBER_AUTHENTICATION_LIST = {

Expand All @@ -53,6 +56,7 @@ protected SecurityFilterChain filterChain(HttpSecurity httpSecurity, HandlerMapp
)
.authorizeHttpRequests(authorizeRequest -> authorizeRequest
.requestMatchers(CORE_AUTHENTICATION_LIST).hasRole("CORE")
.requestMatchers(HttpMethod.GET, WHITE_LIST).permitAll()
.anyRequest().permitAll()
);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.gdsc_knu.official_homepage.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.support.TransactionTemplate;

@Configuration
public class TxTemplateConfig {
public final TransactionTemplate transactionTemplate;

public TxTemplateConfig(PlatformTransactionManager transactionManager) {
this.transactionTemplate = new TransactionTemplate(transactionManager);
}

}
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,44 +4,42 @@
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.service.MemberInfoService;
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;
import com.gdsc_knu.official_homepage.service.MemberService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "Member", description = "사용자 정보 관련 API")
@Tag(name = "User", description = "사용자 정보 관련 API")
@RestController
@RequestMapping("api/user")
@RequiredArgsConstructor
public class MemberController {
private final MemberInfoService memberInfoService;
@PostMapping("additional-info")
private final MemberService memberService;
@PutMapping()
@Operation(summary="신규가입 추가정보 입력 API")
public void additionalInfo(@TokenMember JwtMemberDetail jwtMemberDetail,
@RequestBody MemberRequest.Append request){
memberInfoService.addMemberInfo(jwtMemberDetail.getId(),request);
memberService.addMemberInfo(jwtMemberDetail.getId(),request);
}

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

@PutMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary="사용자 정보 수정 API")
public void updateMemberInfo(@TokenMember JwtMemberDetail jwtMemberDetail,
@ModelAttribute MemberRequest.Update request){
memberInfoService.updateMemberInfo(jwtMemberDetail.getId(), request);
@PatchMapping()
@Operation(summary="직렬, 권한 변경 편의 API (❗개발 API 아님❗)")
public ResponseEntity<Member> getMember(@RequestParam(required = true) Track track,
@RequestParam(required = true) Role role,
@RequestParam(name = "email") String email) {
return ResponseEntity.ok().body(memberService.getMemberAdmin(email, track, role));
}


}

This file was deleted.

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.MemberService;
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 @@ -20,19 +20,19 @@
@RequiredArgsConstructor
public class TeamController {
private final TeamService teamService;
private final MemberInfoService memberInfoService;
private final MemberService memberService;

@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){
return ResponseEntity.ok().body(memberInfoService.getMemberTeamInfo(jwtMemberDetail.getId()));
public ResponseEntity<List<TeamResponse.Main>> getMemberTeamInfo(@TokenMember JwtMemberDetail jwtMemberDetail){
return ResponseEntity.ok().body(memberService.getMemberTeamInfo(jwtMemberDetail.getId()));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.gdsc_knu.official_homepage.controller.admin;

import com.gdsc_knu.official_homepage.dto.member.MemberResponse;
import com.gdsc_knu.official_homepage.entity.enumeration.Track;
import com.gdsc_knu.official_homepage.service.discord.DiscordClient;
import com.gdsc_knu.official_homepage.service.admin.AdminMemberService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
@RequiredArgsConstructor
public class AdminMemberCheckController {
private final AdminMemberService adminMemberService;
private final DiscordClient discordClient;

@GetMapping("members")
public String getHtml(Model model) {
model.addAttribute("tracks", Track.values());
return "members";
}

@GetMapping("api/member/check")
public String getMemberByTrack(@RequestParam Track track, Model model) {
List<MemberResponse.WithTrack> response = adminMemberService.getMembersByTrack(track);
model.addAttribute("tracks", Track.values());
model.addAttribute("defaultTrack", track);
model.addAttribute("members", response);
return "members";
}

@PostMapping("api/member/check/attendance")
public ResponseEntity<String> check(@RequestParam List<String> memberNames,
@RequestParam Track track) {
discordClient.sendAttendance(memberNames, track.name());
return ResponseEntity.ok().body("출첵 완료!");
}
}
Loading

0 comments on commit eb0730b

Please sign in to comment.