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

review: 다섯 번째 리뷰 PR #65

Merged
merged 32 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d02aeb8
feat: 활동 조회 기능 완성 및 단위테스트 추가 (#15)
5win Sep 23, 2024
3b98b12
weekly: 4주차 작업 병합 (#24)
5win Sep 28, 2024
6fd1997
feat: 봉사 기관 관련 기능 및 단위테스트 추가 (#29)
5win Oct 8, 2024
4d4de84
feat: 시도, 시군구 API 및 시도, 시군구 필터링 기능 추가 (#31)
5win Oct 11, 2024
fce94f8
Merge pull request #32 from kakao-tech-campus-2nd-step3/week6
5win Oct 11, 2024
8e484de
Merge pull request #33 from kakao-tech-campus-2nd-step3/develop
5win Oct 11, 2024
1a4ed52
Merge branch 'review' into Master
5win Oct 11, 2024
98f0921
infra: Github actions를 사용한 CI (#36)
5win Oct 16, 2024
9d88769
Merge pull request #38 from kakao-tech-campus-2nd-step3/week7
5win Oct 19, 2024
149d6fc
feat: 봉사 활동 기록 기능 구현 (#39)
Awhn Oct 25, 2024
cbf6965
Merge pull request #40 from kakao-tech-campus-2nd-step3/week8
5win Oct 25, 2024
577ac51
Merge pull request #41 from kakao-tech-campus-2nd-step3/develop
5win Oct 25, 2024
6f5e976
fix: 아바타 저장 시 오류 해결 (#44)
Awhn Oct 29, 2024
e9b3e9a
fix: 요구사항 변경에 따른 선택적 무한 스크롤 (#43)
Awhn Oct 29, 2024
6a4687f
infra: 배포 CI 파이프라인 (#48)
5win Oct 29, 2024
f0045bf
feat: 카카오 로그인 구현 및 아바타, 히스토리와 연동 (#45)
5win Oct 30, 2024
674ff15
feat: 카테고리 목록 반환 API (#49)
5win Oct 30, 2024
dddbd18
Merge pull request #50 from kakao-tech-campus-2nd-step3/week9
5win Oct 30, 2024
1a8873a
Merge pull request #51 from kakao-tech-campus-2nd-step3/develop
5win Oct 30, 2024
8782d3b
fix: CI 파이프라인 yml파일 수정 (#52)
5win Oct 30, 2024
49d71d4
fix: CI 파이프라인 yml파일 수정 (#53)
5win Oct 30, 2024
9ab0c94
infra: CD 파이프라인 추가 및 CI 수정 (#56)
5win Oct 31, 2024
0fc860d
Merge pull request #57 from kakao-tech-campus-2nd-step3/week9
5win Oct 31, 2024
5e24962
infra: S3 업로드 방식 cp로 변경
5win Oct 31, 2024
3133b36
Merge pull request #58 from kakao-tech-campus-2nd-step3/week9
5win Oct 31, 2024
3998124
Merge pull request #54 from kakao-tech-campus-2nd-step3/develop
5win Oct 31, 2024
3192bbe
infra: 프로덕션 환경 파일 및 배포 스크립트 수정 (#60)
5win Oct 31, 2024
fd59423
infra: MySQL 연동 및 테스트 (#61)
5win Nov 1, 2024
67d6bd1
feat: 데이터 업데이트 기능 구현 (#62)
Awhn Nov 1, 2024
0567956
Merge pull request #63 from kakao-tech-campus-2nd-step3/week9
5win Nov 1, 2024
dc7038b
Merge pull request #64 from kakao-tech-campus-2nd-step3/develop
5win Nov 1, 2024
4006ec3
Merge branch 'review' into master
5win Nov 1, 2024
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
26 changes: 26 additions & 0 deletions .github/workflows/prod-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Prod-CD

on:
push:
branches: [ "master" ]

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2

- name: Code Deploy
run: |
aws deploy create-deployment \
--application-name gamsa-codedeploy \
--deployment-config-name CodeDeployDefault.AllAtOnce \
--deployment-group-name gamsa-deploy-group \
--s3-location bucket=gamja-bongsa,bundleType=tgz,key=deploy.tar.gz
43 changes: 43 additions & 0 deletions .github/workflows/prod-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Prod-CI

on:
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0

- name: Build with Gradle Wrapper
run: ./gradlew build

- name: archive build directory
run: |
mkdir deploy
cp scripts/*.sh deploy
cp appspec.yml deploy
cp build/libs/*.jar deploy
tar cvfz deploy.tar.gz deploy

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2

- name: upload to S3
run: |
aws s3 cp deploy.tar.gz s3://gamja-bongsa
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,9 @@ nb-configuration.xml
## Miscellaneous
##############################
*.log

##############################
## Production
##############################
src/main/resources/application-prod-db.yml
src/main/resources/application-jwt.yml
18 changes: 18 additions & 0 deletions appspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 0.0
os: linux
files:
- source: /
destination: /home/ubuntu/deploy
overwrite: yes

permissions:
- object: /
pattern: "**"
owner: ubuntu
group: ubuntu

hooks:
ApplicationStart:
- location: deploy.sh
timeout: 60
runas: ubuntu
10 changes: 8 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ repositories {
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'com.opencsv:opencsv:5.5.2'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'

Expand All @@ -34,6 +34,12 @@ dependencies {
annotationProcessor 'jakarta.persistence:jakarta.persistence-api'
implementation 'org.hibernate.validator:hibernate-validator'

// jwt
implementation 'io.jsonwebtoken:jjwt-api:0.12.6'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.12.6'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.12.6'

implementation 'com.mysql:mysql-connector-j:9.1.0'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.h2database:h2'
annotationProcessor 'org.projectlombok:lombok'
Expand All @@ -44,4 +50,4 @@ dependencies {

tasks.named('test') {
useJUnitPlatform()
}
}
32 changes: 32 additions & 0 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

REPOSITORY=/home/ubuntu/deploy
APP_NAME=gamsa

cd $REPOSITORY

echo "> 현재 구동 중인 애플리케이션 pid 확인"
CURRENT_PID=$(lsof -i :8080 -t)

echo "> 현재 구동 중인 애플리케이션 pid: $CURRENT_PID"
if [ -z "$CURRENT_PID" ]; then
echo "> 구동 중인 애플리케이션이 없습니다."
else
echo "> kill -15 $CURRENT_PID"
kill -15 $CURRENT_PID
sleep 5
fi

echo "> 새 애플리케이션 배포"
JAR_NAME=$(ls -tr $REPOSITORY/ | grep jar | head -n 1)

echo "> JAR Name: $JAR_NAME"

echo "> $JAR_NAME에 실행권한 추가"
chmod +x $JAR_NAME

echo "> $JAR_NAME 실행"
nohup java -jar \
-Dspring.config.location=/home/ubuntu/prod/application-prod-db.yml,/home/ubuntu/prod/application-jwt.yml \
-Dspring.profiles.active=prod \
$REPOSITORY/$JAR_NAME 2>&1 &
6 changes: 4 additions & 2 deletions src/main/java/com/gamsa/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableScheduling;

@ConfigurationPropertiesScan
@EnableJpaAuditing
@EnableScheduling
@SpringBootApplication
public class Application {

public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}

}
26 changes: 26 additions & 0 deletions src/main/java/com/gamsa/activity/constant/Category.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.gamsa.activity.constant;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

Expand All @@ -15,4 +17,28 @@ public enum Category {
OTHER_ACTIVITIES("기타 활동");

private final String name;

@JsonCreator
public static Category fromValues(String value) {
for (Category category : Category.values()) {
if (category.getName().equals(value)) {
return category;
}
}
throw new IllegalArgumentException("Unknown value: " + value);
}

public static Category fromValuesForSlice(String value) {
for (Category category : Category.values()) {
if (category.getName().equals(value)) {
return category;
}
}
return null; // QueryDSL 에서는 null일 경우 필터링에서 제외하므로 null 반환 허용
}

@JsonValue
public String toValue() {
return this.name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ public class ActivityController {

@GetMapping
public Slice<ActivityFindSliceResponse> findSlice(
@RequestParam(required = false) Category category,
@RequestParam(required = false) String category,
@RequestParam(required = false) Integer sidoGunguCode,
@RequestParam(required = false) Integer sidoCode,
@RequestParam(defaultValue = "false") boolean teenPossibleOnly,
@RequestParam(defaultValue = "false") boolean beforeDeadlineOnly,
Pageable pageable) {

ActivityFilterRequest request = ActivityFilterRequest.builder()
.category(category)
.category(Category.fromValuesForSlice(category))
.sidoGunguCode(sidoGunguCode)
.sidoCode(sidoCode)
.teenPossibleOnly(teenPossibleOnly)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.gamsa.activity.controller;

import com.gamsa.activity.constant.Category;
import java.util.List;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/activities/categories")
public class CategoryController {

@GetMapping
public List<Category> findAllCategories() {
return List.of(Category.values());
}
}
4 changes: 4 additions & 0 deletions src/main/java/com/gamsa/activity/domain/District.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import lombok.Builder;
import lombok.Getter;

import java.math.BigDecimal;

@Getter
@Builder
public class District {
Expand All @@ -11,5 +13,7 @@ public class District {
private int sidoCode;
private String sidoName;
private String gunguName;
private BigDecimal latitude;
private BigDecimal longitude;
private boolean sido;
}
62 changes: 62 additions & 0 deletions src/main/java/com/gamsa/activity/dto/ActivityApiResponse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.gamsa.activity.dto;

import com.gamsa.activity.constant.Category;
import lombok.Builder;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.time.LocalDateTime;

@Getter
@Builder
@RequiredArgsConstructor
public class ActivityApiResponse {

private final Long actId;
private final String actTitle;
private final String actLocation;
private final String description;
private final LocalDateTime noticeStartDate;
private final LocalDateTime noticeEndDate;
private final LocalDateTime actStartDate;
private final LocalDateTime actEndDate;
private final int actStartTime;
private final int actEndTime;
private final int recruitTotalNum;
private final boolean adultPossible;
private final boolean teenPossible;
private final boolean groupPossible;
private final int actWeek;
private final String actManager;
private final String actPhone;
private final String url;
private final Category category;
private final String instituteName;
private final Integer sidoGunguCode;

public ActivitySaveRequest toSaveRequest(long instituteId) {
return ActivitySaveRequest.builder()
.actId(actId)
.actTitle(actTitle)
.actLocation(actLocation)
.description(description)
.noticeStartDate(noticeStartDate)
.noticeEndDate(noticeEndDate)
.actStartDate(actStartDate)
.actEndDate(actEndDate)
.actStartTime(actStartTime)
.actEndTime(actEndTime)
.recruitTotalNum(recruitTotalNum)
.adultPossible(adultPossible)
.teenPossible(teenPossible)
.groupPossible(groupPossible)
.actWeek(actWeek)
.actManager(actManager)
.actPhone(actPhone)
.url(url)
.category(category)
.instituteId(instituteId)
.sidoGunguCode(sidoGunguCode)
.build();
}
}
Loading
Loading