Skip to content
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
56 changes: 56 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Deploy to GCP

on:
push:
branches:
- main
paths-ignore:
- '.github/workflows/**'

jobs:
deploy:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4

# CI에서 생성한 JAR 파일 다운로드
- name: Download JAR Artifact
uses: actions/download-artifact@v4
with:
name: application-jar
path: build/libs/

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build & Push Docker Image
uses: docker/build-push-action@v6
with:
push: true
context: .
tags: ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:latest

- name: Authenticate to GCP
uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.SERVICE_ACCOUNT_EMAIL }}

- name: Deploy to GCP Compute Engine
uses: google-github-actions/ssh-compute@v1
with:
instance_name: ${{ secrets.GCP_INSTANCE_NAME }}
zone: ${{ secrets.GCP_INSTANCE_ZONE }}
ssh_private_key: ${{ secrets.GCP_SSH_PRIVATE_KEY }}
command: |
cd /app/${{ github.repository }}
sudo curl -o docker-compose.yml https://raw.githubusercontent.com/${{ github.repository }}/main/docker-compose.yml
sudo docker-compose down
sudo docker-compose up -d ${{ secrets.DOCKER_IMAGE_NAME }}
sudo docker image prune -a -f
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Java CI with Gradle

on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
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@v4

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

# 빌드 결과물을 아티팩트로 업로드 (JAR 파일)
- name: Upload JAR Artifact
uses: actions/upload-artifact@v4
with:
name: application-jar
path: build/libs/*.jar
104 changes: 0 additions & 104 deletions .github/workflows/gradle.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.example.Jinus.utility.ListCardResponse;
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.RestController;

import java.util.ArrayList;
Expand All @@ -18,6 +19,7 @@
import java.util.Map;

@RestController
@RequestMapping("/api/v2/spring")
public class CafeteriaControllerV2 {

private final UserServiceV2 userServiceV2;
Expand All @@ -33,20 +35,14 @@ public CafeteriaControllerV2(
this.cafeteriaServiceV2 = cafeteriaServiceV2;
}


// 사용자 존재 여부에 따라 응답
@PostMapping("/api/spring/cafeteria/v2")
@PostMapping("/cafeteria")
public String responseCafeteriaOrCampusListCard(@RequestBody RequestDto requestDto) {
// userId로 campusId 찾기
String userId = requestDto.getUserRequest().getUser().getId();
int campusId = userServiceV2.getUserCampusId(userId);
int sysCampusId = requestDto.getAction().getClientExtra().getSys_campus_id();

// 사용자가 존재 & 식당 블록에서 캠퍼스 눌렀을 때 -> 식당 리스트
if (campusId != -1 && sysCampusId != -1) {
return cafeteriaServiceV2.makeCafeteriaListCard(campusId);
} else { // 사용자가 존재 X & 식당 블록에서 더보기 버튼 눌렀을 때 -> 캠퍼스 리스트
return campusServiceV2.makeCampusListCard();
}
return cafeteriaServiceV2.campusOrCafeteria(campusId, sysCampusId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.example.Jinus.controller.v2;

import com.example.Jinus.dto.request.RequestDto;
import com.example.Jinus.service.v2.cafeteria.DietServiceV2;
import lombok.RequiredArgsConstructor;
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.RestController;

@RestController
@RequestMapping("/api/v2/spring")
@RequiredArgsConstructor
public class DietControllerV2 {
private final DietServiceV2 dietServiceV2;

@PostMapping("/dish")
public String handleRequest(@RequestBody RequestDto requestDto) {
return dietServiceV2.requestHandler(requestDto);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
import com.example.Jinus.dto.request.RequestDto;
import com.example.Jinus.dto.response.*;
import com.example.Jinus.entity.notice.NoticeCategoryEntity;
import com.example.Jinus.service.v2.notice.NoticeCategoryServiceV2;
import com.example.Jinus.service.v2.notice.CategoryServiceV2;
import com.example.Jinus.service.v2.notice.NoticeServiceV2;
import com.example.Jinus.service.v2.userInfo.DepartmentServiceV2;
import com.example.Jinus.service.v2.userInfo.UserServiceV2;
import com.example.Jinus.utility.JsonUtils;
import com.example.Jinus.utility.TextCardResponse;
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.RestController;

import java.util.ArrayList;
Expand All @@ -19,15 +20,16 @@
import static java.lang.String.valueOf;

@RestController
@RequestMapping("/api/v2/spring")
public class NoticeControllerV2 {

private final NoticeServiceV2 noticeServiceV2;
private final NoticeCategoryServiceV2 noticeCategoryServiceV2;
private final CategoryServiceV2 noticeCategoryServiceV2;
private final DepartmentServiceV2 departmentServiceV2;
private final UserServiceV2 userServiceV2;

public NoticeControllerV2(NoticeServiceV2 noticeServiceV2,
NoticeCategoryServiceV2 noticeCategoryServiceV2,
CategoryServiceV2 noticeCategoryServiceV2,
DepartmentServiceV2 departmentServiceV2,
UserServiceV2 userServiceV2) {
this.noticeServiceV2 = noticeServiceV2;
Expand All @@ -37,15 +39,15 @@ public NoticeControllerV2(NoticeServiceV2 noticeServiceV2,
}

// 학교 공지사항 조회
@PostMapping("/api/spring/main-notice/v2")
@PostMapping("/main-notice")
public String getMainNotice() {
int departmentId = 117; // 학교 공지사항 id
String departmentEng = "main"; // 학과 영문명
return existUserReturnNotice(departmentEng, departmentId);
}

// 학과 공지사항 조회
@PostMapping("/api/spring/department-notice/v2")
@PostMapping("/department-notice")
public String responseDepartmentNotice(@RequestBody RequestDto requestDto) {
String userId = requestDto.getUserRequest().getUser().getId();
int departmentId = userServiceV2.getUserDepartmentId(userId);
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/com/example/Jinus/dto/request/HandleRequestDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.example.Jinus.dto.request;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class HandleRequestDto {
private final String kakaoId;
private final String campusName;
private final String day;
private final String period;
private final String cafeteriaName;

public HandleRequestDto(String kakaoId, String campusName, String day, String period, String cafeteriaName) {
this.kakaoId = kakaoId;
this.campusName = campusName;
this.day = day;
this.period = period;
this.cafeteriaName = cafeteriaName;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.time.LocalDateTime;
import java.sql.Date;

@Entity
@Getter
Expand All @@ -20,11 +20,8 @@ public class CafeteriaDietEntity {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int dietId;

@Column(name = "date", columnDefinition = "TIMESTAMP WITH TIME ZONE")
private LocalDateTime dateTime; // 날짜 + 시간 + 시간대

// @Column(name = "date")
// private LocalTime date;
@Column(name = "date")
private Date dietDate;

@Column(name = "day")
private String day_of_week;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import java.util.HashMap;
import java.util.List;
import java.util.Optional;

public interface CafeteriaRepositoryV2 extends JpaRepository<CafeteriaEntity, Integer> {
// 사용자 campusId와 동일한 식당이름과 url 찾기
Expand All @@ -16,6 +17,10 @@ public interface CafeteriaRepositoryV2 extends JpaRepository<CafeteriaEntity, In
// campusId와 식당이름으로 cafeteriaId 찾기
@Query("SELECT c.id FROM CafeteriaEntity c " +
"WHERE c.campusId = :campusId AND c.cafeteriaNameKo = :cafeteriaName")
int findCafeteriaId(@Param("cafeteriaName") String cafeteriaName,
@Param("campusId") int campusId);
Optional<Integer> findCafeteriaId(@Param("cafeteriaName") String cafeteriaName,
@Param("campusId") int campusId);

// cafeteriaId로 imgUrl 찾기
@Query("SELECT c.thumbnailUrl FROM CafeteriaEntity c WHERE c.id = :cafeteriaId")
String findImgUrlByCafeteriaId(@Param("cafeteriaId")int cafeteriaId);
}
Loading