Skip to content

Commit

Permalink
Merge pull request #83 from kakao-tech-campus-2nd-step3/develop
Browse files Browse the repository at this point in the history
deploy: 11주차 작업 내용 중간 배포
  • Loading branch information
5win authored Nov 12, 2024
2 parents 51c8232 + f7ba990 commit 1ca5531
Show file tree
Hide file tree
Showing 63 changed files with 1,320 additions and 1,055 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/dev-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read

steps:
- uses: actions/checkout@v4
Expand All @@ -22,5 +20,11 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0

- name: Set YML
run: |
echo $DATA_KEY_YML | base64 --decode > src/main/resources/application-data.yml
env:
DATA_KEY_YML: ${{ secrets.APPLICATION_DATA_YML }}

- name: Build with Gradle Wrapper
run: ./gradlew build
6 changes: 6 additions & 0 deletions .github/workflows/prod-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0

- name: Set YML
run: |
echo $DATA_KEY_YML | base64 --decode > src/main/resources/application-data.yml
env:
DATA_KEY_YML: ${{ secrets.APPLICATION_DATA_YML }}

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

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,4 @@ nb-configuration.xml
##############################
src/main/resources/application-prod-db.yml
src/main/resources/application-jwt.yml
src/main/resources/application-data.yml
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ dependencies {
implementation 'com.opencsv:opencsv:5.5.2'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'jakarta.persistence:jakarta.persistence-api:3.1.0'
implementation 'com.opencsv:opencsv:5.5.2'

implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta'
annotationProcessor 'com.querydsl:querydsl-apt:5.0.0:jakarta'
Expand Down
2 changes: 1 addition & 1 deletion scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ 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.config.location=/home/ubuntu/prod/application-prod-db.yml,/home/ubuntu/prod/application-jwt.yml,/home/ubuntu/prod/application-data.yml \
-Dspring.profiles.active=prod \
$REPOSITORY/$JAR_NAME 2>&1 &
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@
import com.gamsa.activity.constant.Category;
import com.gamsa.activity.dto.ActivityDetailResponse;
import com.gamsa.activity.dto.ActivityFilterRequest;
import com.gamsa.activity.dto.ActivityFindDistanceOrderRequest;
import com.gamsa.activity.dto.ActivityFindSliceResponse;
import com.gamsa.activity.dto.ActivitySaveRequest;
import com.gamsa.activity.service.ActivityService;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
Expand All @@ -33,27 +30,24 @@ public Slice<ActivityFindSliceResponse> findSlice(
@RequestParam(required = false) Integer sidoCode,
@RequestParam(defaultValue = "false") boolean teenPossibleOnly,
@RequestParam(defaultValue = "false") boolean beforeDeadlineOnly,
@RequestParam(required = false) String keyword,
@RequestBody(required = false) ActivityFindDistanceOrderRequest distanceOrderRequest,
Pageable pageable) {

ActivityFilterRequest request = ActivityFilterRequest.builder()
ActivityFilterRequest filterRequest = ActivityFilterRequest.builder()
.category(Category.fromValuesForSlice(category))
.sidoGunguCode(sidoGunguCode)
.sidoCode(sidoCode)
.teenPossibleOnly(teenPossibleOnly)
.beforeDeadlineOnly(beforeDeadlineOnly)
.keyword(keyword)
.build();

return activityService.findSlice(request, pageable);
return activityService.findSlice(filterRequest, distanceOrderRequest, pageable);
}

@GetMapping("{activity-id}")
public ActivityDetailResponse findById(@PathVariable("activity-id") Long activityId) {
return activityService.findById(activityId);
}

@PostMapping
public ResponseEntity<String> save(@RequestBody ActivitySaveRequest saveRequest) {
activityService.save(saveRequest);
return new ResponseEntity<>(HttpStatus.CREATED);
}
}
62 changes: 0 additions & 62 deletions src/main/java/com/gamsa/activity/dto/ActivityApiResponse.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import com.gamsa.activity.constant.Category;
import com.gamsa.activity.domain.Activity;
import com.gamsa.review.dto.QuestionResponse;
import com.gamsa.review.domain.Question;
import lombok.Builder;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -31,6 +31,8 @@ public class ActivityDetailResponse {
private final boolean adultPossible;
private final boolean teenPossible;
private final boolean groupPossible;
private final BigDecimal latitude;
private final BigDecimal longitude;
private final int actWeek;
private final String actManager;
private final String actPhone;
Expand All @@ -39,7 +41,7 @@ public class ActivityDetailResponse {
private final InstituteDetailResponse institute;
private final DistrictDetailResponse sidoGungu;

public static ActivityDetailResponse from(Activity activity, Map<QuestionResponse, BigDecimal> scores) {
public static ActivityDetailResponse from(Activity activity, Map<Question, BigDecimal> scores) {
return ActivityDetailResponse.builder()
.actId(activity.getActId())
.actTitle(activity.getActTitle())
Expand All @@ -55,6 +57,8 @@ public static ActivityDetailResponse from(Activity activity, Map<QuestionRespons
.adultPossible(activity.isAdultPossible())
.teenPossible(activity.isTeenPossible())
.groupPossible(activity.isGroupPossible())
.latitude(activity.getLatitude())
.longitude(activity.getLongitude())
.actWeek(activity.getActWeek())
.actManager(activity.getActManager())
.actPhone(activity.getActPhone())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ public class ActivityFilterRequest {

// 마감되지 않은 활동만
private final boolean beforeDeadlineOnly;

// 키워드 검색
private final String keyword;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.gamsa.activity.dto;

import java.math.BigDecimal;
import lombok.Builder;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@Builder
@RequiredArgsConstructor
public class ActivityFindDistanceOrderRequest {

private final BigDecimal latitude;
private final BigDecimal longitude;
private final int distanceKm;

}
32 changes: 19 additions & 13 deletions src/main/java/com/gamsa/activity/dto/ActivityFindSliceResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import com.gamsa.activity.constant.Category;
import com.gamsa.activity.domain.Activity;
import java.time.LocalDateTime;
import lombok.Builder;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.math.BigDecimal;
import java.time.LocalDateTime;

@Getter
@Builder
@RequiredArgsConstructor
Expand All @@ -21,22 +23,26 @@ public class ActivityFindSliceResponse {
private final LocalDateTime actEndDate;
private final int actStartTime;
private final int actEndTime;
private final BigDecimal latitude;
private final BigDecimal longitude;
private final int recruitTotalNum;
private final Category category;

public static ActivityFindSliceResponse from(Activity activity) {
return ActivityFindSliceResponse.builder()
.actId(activity.getActId())
.actTitle(activity.getActTitle())
.actLocation(activity.getActLocation())
.noticeStartDate(activity.getNoticeStartDate())
.noticeEndDate(activity.getNoticeEndDate())
.actStartDate(activity.getActStartDate())
.actEndDate(activity.getActEndDate())
.actStartTime(activity.getActStartTime())
.actEndTime(activity.getActEndTime())
.recruitTotalNum(activity.getRecruitTotalNum())
.category(activity.getCategory())
.build();
.actId(activity.getActId())
.actTitle(activity.getActTitle())
.actLocation(activity.getActLocation())
.noticeStartDate(activity.getNoticeStartDate())
.noticeEndDate(activity.getNoticeEndDate())
.actStartDate(activity.getActStartDate())
.actEndDate(activity.getActEndDate())
.actStartTime(activity.getActStartTime())
.actEndTime(activity.getActEndTime())
.latitude(activity.getLatitude())
.longitude(activity.getLongitude())
.recruitTotalNum(activity.getRecruitTotalNum())
.category(activity.getCategory())
.build();
}
}
11 changes: 8 additions & 3 deletions src/main/java/com/gamsa/activity/dto/ActivitySaveRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.math.BigDecimal;
import java.time.LocalDateTime;

@Getter
Expand All @@ -29,15 +30,17 @@ public class ActivitySaveRequest {
private final boolean adultPossible;
private final boolean teenPossible;
private final boolean groupPossible;
private final BigDecimal latitude;
private final BigDecimal longitude;
private final int actWeek;
private final String actManager;
private final String actPhone;
private final String url;
private final Category category;
private final Long instituteId;
private final String instituteName;
private final Integer sidoGunguCode;

public Activity toModel(Institute institute, District sidoGungu) {
public Activity toModel(Institute institute, District district) {
return Activity.builder()
.actId(actId)
.actTitle(actTitle)
Expand All @@ -53,13 +56,15 @@ public Activity toModel(Institute institute, District sidoGungu) {
.adultPossible(adultPossible)
.teenPossible(teenPossible)
.groupPossible(groupPossible)
.longitude(longitude)
.latitude(latitude)
.actWeek(actWeek)
.actManager(actManager)
.actPhone(actPhone)
.url(url)
.category(category)
.institute(institute)
.sidoGungu(sidoGungu)
.sidoGungu(district)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package com.gamsa.activity.dto;

import com.gamsa.activity.domain.District;
import com.gamsa.activity.domain.Institute;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.math.BigDecimal;
import java.util.Map;
Expand All @@ -22,13 +19,14 @@ public class InstituteApiResponse {
private String phone;

public InstituteSaveRequest toSaveRequest(Map<String, BigDecimal> coordinates) {

return InstituteSaveRequest.builder()
.name(name)
.location(location)
.sidoCode(sidoCode)
.sidoGunguCode(sidoGunguCode)
.longitude(coordinates.get("longitude"))
.latitude(coordinates.get("latitude"))
.longitude(coordinates.getOrDefault("longitude", new BigDecimal(1)))
.latitude(coordinates.getOrDefault("latitude", new BigDecimal(1)))
.phone(phone)
.build();
}
Expand Down
Loading

0 comments on commit 1ca5531

Please sign in to comment.