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
32 changes: 15 additions & 17 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
name: Deploy to ECR and EC2
name: CI/CD Pipeline

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
branches: [ main, develop ]

jobs:

deploy:
name: Deploy to EC2
runs-on: ubuntu-latest
# develop ๋˜๋Š” main์— ํ‘ธ์‹œ๋  ๋•Œ๋งŒ ์‹คํ–‰
if: github.event_name == 'push'

steps:
- name: Checkout code
Expand Down Expand Up @@ -43,17 +45,10 @@ jobs:
username: ubuntu
key: ${{ secrets.EC2_SSH_KEY }}
script: |
# ECR ๋กœ๊ทธ์ธ
aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin ${{ steps.login-ecr.outputs.registry }}

# ์ตœ์‹  ์ด๋ฏธ์ง€ pull
docker pull ${{ steps.login-ecr.outputs.registry }}/stitch-api:latest

# ๊ธฐ์กด ์ปจํ…Œ์ด๋„ˆ ์ค‘์ง€ ๋ฐ ์ œ๊ฑฐ
docker stop stitch-api-container || true
docker rm stitch-api-container || true

# ์ƒˆ ์ปจํ…Œ์ด๋„ˆ ์‹คํ–‰
docker run -d \
--name stitch-api-container \
-p 8080:8080 \
Expand All @@ -72,8 +67,6 @@ jobs:
-e SPRING_MAIL_PASSWORD="${{ secrets.SPRING_MAIL_PASSWORD }}" \
-e UNIVCERT_API_KEY="${{ secrets.UNIVCERT_API_KEY }}" \
${{ steps.login-ecr.outputs.registry }}/stitch-api:latest

# ์ปจํ…Œ์ด๋„ˆ ์‹œ์ž‘ ํ™•์ธ
sleep 10
docker logs stitch-api-container --tail 20

Expand All @@ -84,9 +77,14 @@ jobs:
username: ubuntu
key: ${{ secrets.EC2_SSH_KEY }}
script: |
# ์ปจํ…Œ์ด๋„ˆ ์ƒํƒœ ํ™•์ธ
docker ps -f name=stitch-api-container

# ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์‹œ์ž‘ ๋Œ€๊ธฐ ๋ฐ ๋กœ๊ทธ ํ™•์ธ
sleep 30
docker logs stitch-api-container --tail 10
docker logs stitch-api-container --tail 10
PUBLIC_IP=$(curl -s ifconfig.me)
echo "======================================"
echo "๐Ÿš€ Deployment Completed!"
echo "======================================"
echo "Branch: ${{ github.ref_name }}"
echo "Swagger UI: http://${PUBLIC_IP}:8080/swagger-ui.html"
echo "Website: https://stitch-study.site"
echo "======================================"
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class CampusController {
private final CampusService campusService;

@Operation(summary = "์บ ํผ์Šค ๋ชฉ๋ก ์กฐํšŒ", description = "๋ชจ๋“  ์บ ํผ์Šค์˜ ๋ชฉ๋ก์„ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค.")
@GetMapping("/list")
@GetMapping
public CommonResponse<List<CampusListResponse>> getCampusList(){
List<CampusListResponse> campusListResponse = campusService.getAllCampuses();
return CommonResponse.ok(campusListResponse);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@


import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;
import se.sowl.stitchapi.common.CommonResponse;
import se.sowl.stitchapi.major.dto.request.MajorRequest;
import se.sowl.stitchapi.major.dto.response.MajorDetailResponse;
import se.sowl.stitchapi.major.dto.response.MajorListResponse;
import se.sowl.stitchapi.major.dto.response.MajorResponse;
import se.sowl.stitchapi.major.service.MajorService;
import se.sowl.stitchdomain.user.domain.CustomOAuth2User;

import java.util.List;

Expand All @@ -24,25 +24,31 @@ public class MajorController {
private final MajorService majorService;

@Operation(summary = "์ „๊ณต ๋ชฉ๋ก ์กฐํšŒ")
@GetMapping("/list")
@GetMapping
public CommonResponse<List<MajorListResponse>> getMajorList() {
List<MajorListResponse> majorList = majorService.getAllMajors();
return CommonResponse.ok(majorList);
}

@Operation(summary = "์ „๊ณต ์ƒ์„ธ ์กฐํšŒ")
@GetMapping("/detail")
@GetMapping("/{majorId}")
public CommonResponse<MajorDetailResponse> getMajorDetail(
@Parameter(description = "์ „๊ณต ID", required = true)
@RequestParam("majorId") Long majorId) {
@PathVariable Long majorId
) {
MajorDetailResponse response = majorService.getMajorDetail(majorId);
return CommonResponse.ok(response);
}

@Operation(summary = "์ „๊ณต ์„ ํƒ")
@PostMapping("/select")
public CommonResponse<MajorResponse> selectMajor(@RequestBody MajorRequest request) {
MajorResponse response = majorService.selectMajor(request);
@PutMapping("/{majorId}")
public CommonResponse<MajorResponse> selectMajor(
@PathVariable Long majorId,
@AuthenticationPrincipal CustomOAuth2User currentUser
) {
MajorResponse response = majorService.selectMajor(
majorId,
currentUser.getUserId()
);
return CommonResponse.ok(response);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.springframework.transaction.annotation.Transactional;
import se.sowl.stitchapi.exception.MajorException;
import se.sowl.stitchapi.exception.UserException;
import se.sowl.stitchapi.major.dto.request.MajorRequest;
import se.sowl.stitchapi.major.dto.response.MajorDetailResponse;
import se.sowl.stitchapi.major.dto.response.MajorListResponse;
import se.sowl.stitchapi.major.dto.response.MajorResponse;
Expand Down Expand Up @@ -43,8 +42,8 @@ public MajorDetailResponse getMajorDetail(Long majorId){


@Transactional
public MajorResponse selectMajor(MajorRequest request) {
User user = userRepository.findById(request.getUserId())
public MajorResponse selectMajor(Long majorId, Long userId) {
User user = userRepository.findById(userId)
.orElseThrow(UserException.UserNotFoundException::new);

if (!user.isCampusCertified()) {
Expand All @@ -54,7 +53,7 @@ public MajorResponse selectMajor(MajorRequest request) {
UserCamInfo userCamInfo = userCamInfoRepository.findByUser(user)
.orElseThrow(UserException.UserCamInfoNotFoundException::new);

Major newMajor = findMajorById(request.getMajorId());
Major newMajor = findMajorById(majorId);


// ์ƒˆ ์ „๊ณต ์„ค์ •
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
package se.sowl.stitchapi.notification.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;
import se.sowl.stitchapi.common.CommonResponse;
import se.sowl.stitchapi.notification.dto.NotificationListResponse;
import se.sowl.stitchapi.notification.dto.NotificationResponse;
import se.sowl.stitchapi.notification.service.NotificationService;
import se.sowl.stitchdomain.user.domain.CustomOAuth2User;

import java.util.List;

@RestController
@RequestMapping("/api/notifications")
@RequiredArgsConstructor
@Tag(name = "Notification", description = "์•Œ๋ฆผ ๊ด€๋ จ API")
public class NotificationController {

private final NotificationService notificationService;
Expand All @@ -21,11 +26,14 @@ public class NotificationController {
* - ์ตœ์‹ ์ˆœ์œผ๋กœ ์ •๋ ฌ๋œ ์•Œ๋ฆผ ๋ชฉ๋ก์„ ๋ฐ˜ํ™˜
* - ์ฝ์Œ/์•ˆ์ฝ์Œ ์ƒํƒœ ํฌํ•จ
*/
@GetMapping("/list")
@Operation(summary = "์‚ฌ์šฉ์ž์˜ ์•Œ๋ฆผ ๋ชฉ๋ก ์กฐํšŒ", description = "์ตœ์‹ ์ˆœ์œผ๋กœ ์ •๋ ฌ๋œ ์•Œ๋ฆผ ๋ชฉ๋ก์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.")
@GetMapping
public CommonResponse<List<NotificationListResponse>> getUserNotifications(
@RequestParam("userCamInfoId") Long userCamInfoId
@AuthenticationPrincipal CustomOAuth2User currentUser
){
List<NotificationListResponse> responses = notificationService.getUserNotifications(userCamInfoId);
List<NotificationListResponse> responses = notificationService.getUserNotifications(
currentUser.getUserCamInfoId()
);
return CommonResponse.ok(responses);
}

Expand All @@ -34,11 +42,14 @@ public CommonResponse<List<NotificationListResponse>> getUserNotifications(
* - ์•Œ๋ฆผ ๋ฑƒ์ง€ ํ‘œ์‹œ์šฉ
* - ํ—ค๋”๋‚˜ ๋„ค๋น„๊ฒŒ์ด์…˜ ๋ฐ”์—์„œ ํ™œ์šฉ
*/
@Operation(summary = "์ฝ์ง€ ์•Š์€ ์•Œ๋ฆผ ๊ฐœ์ˆ˜ ์กฐํšŒ", description = "์•Œ๋ฆผ ๋ฑƒ์ง€ ํ‘œ์‹œ์šฉ")
@GetMapping("/unread-count")
public CommonResponse<Integer> getUnreadNotificationCount(
@RequestParam("userCamInfoId") Long userCamInfoId
@AuthenticationPrincipal CustomOAuth2User currentUser
){
int count = notificationService.getUnreadNotificationCount(userCamInfoId);
int count = notificationService.getUnreadNotificationCount(
currentUser.getUserCamInfoId()
);
return CommonResponse.ok(count);
}

Expand All @@ -47,12 +58,16 @@ public CommonResponse<Integer> getUnreadNotificationCount(
* - ์•Œ๋ฆผ ํด๋ฆญ ์‹œ ์ƒ์„ธ ์ •๋ณด ํ™•์ธ
* - ๊ถŒํ•œ ๊ฒ€์ฆ ํฌํ•จ (๋ณธ์ธ ์•Œ๋ฆผ๋งŒ ์กฐํšŒ ๊ฐ€๋Šฅ)
*/
@GetMapping("/detail")
@Operation(summary = "ํŠน์ • ์•Œ๋ฆผ ์ƒ์„ธ ์กฐํšŒ", description = "์•Œ๋ฆผ ํด๋ฆญ ์‹œ ์ƒ์„ธ ์ •๋ณด ํ™•์ธ (๋ณธ์ธ ์•Œ๋ฆผ๋งŒ ์กฐํšŒ ๊ฐ€๋Šฅ)")
@GetMapping("/{notificationId}")
public CommonResponse<NotificationResponse> getNotificationDetail(
@RequestParam("notificationId") Long notificationId,
@RequestParam("userCamInfoId") Long userCamInfoId
@PathVariable Long notificationId,
@AuthenticationPrincipal CustomOAuth2User currentUser
){
NotificationResponse response = notificationService.getNotificationDetail(notificationId, userCamInfoId);
NotificationResponse response = notificationService.getNotificationDetail(
notificationId,
currentUser.getUserCamInfoId()
);
return CommonResponse.ok(response);
}

Expand All @@ -61,12 +76,16 @@ public CommonResponse<NotificationResponse> getNotificationDetail(
* - ํŠน์ • ์•Œ๋ฆผ ํ•˜๋‚˜๋ฅผ ์ฝ์Œ ์ƒํƒœ๋กœ ๋ณ€๊ฒฝ
* - ์•Œ๋ฆผ ํด๋ฆญ ์‹œ ์ž๋™์œผ๋กœ ์ฝ์Œ ์ฒ˜๋ฆฌ๋˜๋„๋ก ํ™œ์šฉ
*/
@PostMapping("/read")
@Operation(summary = "๊ฐœ๋ณ„ ์•Œ๋ฆผ ์ฝ์Œ ์ฒ˜๋ฆฌ", description = "ํŠน์ • ์•Œ๋ฆผ ํ•˜๋‚˜๋ฅผ ์ฝ์Œ ์ƒํƒœ๋กœ ๋ณ€๊ฒฝ")
@PutMapping("/{notificationId}/read")
public CommonResponse<NotificationResponse> markOneRead(
@RequestParam("notificationId") Long notificationId,
@RequestParam("userCamInfoId") Long userCamInfoId
@PathVariable Long notificationId,
@AuthenticationPrincipal CustomOAuth2User currentUser
){
NotificationResponse response = notificationService.markOneAsRead(notificationId, userCamInfoId);
NotificationResponse response = notificationService.markOneAsRead(
notificationId,
currentUser.getUserCamInfoId()
);
return CommonResponse.ok(response);
}

Expand All @@ -75,11 +94,12 @@ public CommonResponse<NotificationResponse> markOneRead(
* - "๋ชจ๋‘ ์ฝ์Œ" ๋ฒ„ํŠผ ๊ธฐ๋Šฅ
* - ์ฝ์ง€ ์•Š์€ ๋ชจ๋“  ์•Œ๋ฆผ์„ ์ผ๊ด„ ์ฝ์Œ ์ฒ˜๋ฆฌ
*/
@PostMapping("/read/all")
@Operation(summary = "๋ชจ๋“  ์•Œ๋ฆผ ์ฝ์Œ ์ฒ˜๋ฆฌ", description = "์ฝ์ง€ ์•Š์€ ๋ชจ๋“  ์•Œ๋ฆผ์„ ์ผ๊ด„ ์ฝ์Œ ์ฒ˜๋ฆฌ")
@PutMapping("/read-all")
public CommonResponse<Void> markAllRead(
@RequestParam("userCamInfoId") Long userCamInfoId
@AuthenticationPrincipal CustomOAuth2User currentUser
){
notificationService.markAllAsRead(userCamInfoId);
notificationService.markAllAsRead(currentUser.getUserCamInfoId());
return CommonResponse.ok(null);
}

Expand All @@ -88,12 +108,16 @@ public CommonResponse<Void> markAllRead(
* - ๊ฐœ๋ณ„ ์•Œ๋ฆผ์„ ์™„์ „ํžˆ ์‚ญ์ œ
* - ์•Œ๋ฆผ ๋ชฉ๋ก์—์„œ ์ œ๊ฑฐํ•˜๊ณ  ์‹ถ์„ ๋•Œ ์‚ฌ์šฉ
*/
@DeleteMapping("/delete")
@Operation(summary = "์•Œ๋ฆผ ์‚ญ์ œ", description = "๊ฐœ๋ณ„ ์•Œ๋ฆผ์„ ์™„์ „ํžˆ ์‚ญ์ œ")
@DeleteMapping("/{notificationId}")
public CommonResponse<Void> deleteNotification(
@RequestParam("notificationId") Long notificationId,
@RequestParam("userCamInfoId") Long userCamInfoId
@PathVariable Long notificationId,
@AuthenticationPrincipal CustomOAuth2User currentUser
){
notificationService.deleteNotification(notificationId, userCamInfoId);
notificationService.deleteNotification(
notificationId,
currentUser.getUserCamInfoId()
);
return CommonResponse.ok(null);
}

Expand All @@ -103,6 +127,7 @@ public CommonResponse<Void> deleteNotification(
* - ์Šคํ„ฐ๋”” ๋ฆฌ๋”/๊ด€๋ฆฌ์ž์—๊ฒŒ ์ „์†ก
* - ์‹ค์‹œ๊ฐ„ SSE ์•Œ๋ฆผ๊ณผ ํ•จ๊ป˜ DB ์ €์žฅ
*/
@Operation(summary = "์Šคํ„ฐ๋”” ๊ฐ€์ž… ์‹ ์ฒญ ์•Œ๋ฆผ ์ƒ์„ฑ", description = "๋‚ด๋ถ€ API - Service์—์„œ ํ˜ธ์ถœ")
@PostMapping("/study-apply")
public CommonResponse<NotificationResponse> createStudyApplyNotification(
@RequestParam("receiverId") Long receiverId,
Expand All @@ -118,6 +143,7 @@ public CommonResponse<NotificationResponse> createStudyApplyNotification(
* - ์‹ ์ฒญ์ž์—๊ฒŒ ์ „์†ก
* - ์Šน์ธ ์™„๋ฃŒ ํ›„ ์ž๋™์œผ๋กœ ํ˜ธ์ถœ
*/
@Operation(summary = "์Šคํ„ฐ๋”” ๊ฐ€์ž… ์Šน์ธ ์•Œ๋ฆผ ์ƒ์„ฑ", description = "๋‚ด๋ถ€ API - Service์—์„œ ํ˜ธ์ถœ")
@PostMapping("/study-approve")
public CommonResponse<NotificationResponse> createStudyApproveNotification(
@RequestParam("studyMemberId") Long studyMemberId
Expand All @@ -132,6 +158,7 @@ public CommonResponse<NotificationResponse> createStudyApproveNotification(
* - ์‹ ์ฒญ์ž์—๊ฒŒ ์ „์†ก
* - ๊ฑฐ์ ˆ ์ฒ˜๋ฆฌ ํ›„ ์ž๋™์œผ๋กœ ํ˜ธ์ถœ
*/
@Operation(summary = "์Šคํ„ฐ๋”” ๊ฐ€์ž… ๊ฑฐ์ ˆ ์•Œ๋ฆผ ์ƒ์„ฑ", description = "๋‚ด๋ถ€ API - Service์—์„œ ํ˜ธ์ถœ")
@PostMapping("/study-reject")
public CommonResponse<NotificationResponse> createStudyRejectNotification(
@RequestParam("studyMemberId") Long studyMemberId
Expand All @@ -146,6 +173,7 @@ public CommonResponse<NotificationResponse> createStudyRejectNotification(
* - ๊ฒŒ์‹œ๊ธ€ ์ž‘์„ฑ์ž์—๊ฒŒ ์ „์†ก (์ž์‹ ์ด ๋‹จ ๋Œ“๊ธ€ ์ œ์™ธ)
* - ๋Œ“๊ธ€ ์ž‘์„ฑ ํ›„ ์ž๋™์œผ๋กœ ํ˜ธ์ถœ
*/
@Operation(summary = "์ƒˆ ๋Œ“๊ธ€ ์•Œ๋ฆผ ์ƒ์„ฑ", description = "๋‚ด๋ถ€ API - Service์—์„œ ํ˜ธ์ถœ")
@PostMapping("/study-comment")
public CommonResponse<NotificationResponse> createNewCommentNotification(
@RequestParam("commentId") Long commentId
Expand Down
Loading