Skip to content

Commit

Permalink
Merge pull request #181 from Modagbul/develop
Browse files Browse the repository at this point in the history
fix: 소모임 가입할 때 소모임 삭제 여부 확인
  • Loading branch information
minsu20 authored Jan 3, 2024
2 parents 93b354e + 119bc5f commit 1d5987f
Show file tree
Hide file tree
Showing 8 changed files with 195 additions and 114 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/CI-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,33 @@ jobs:
restore-keys: |
${{ runner.os }}-gradle-
# 설정 파일 생성
- run: |
mkdir ./src/main/resources
cd ./src/main/resources
touch ./application.yml
echo "${{env.APPLICATION}}" > ./application.yml
touch ./firebase-key.json
echo "${{env.GOOGLE_APPLICATION_CREDENTIALS}}" | base64 --decode > ./firebase-key.json
touch ./apple-key.p8
echo "${{env.APPLE_KEY}}" > ./apple-key.p8
# 설정 파일을 작업공간에 저장
- uses: actions/upload-artifact@v2
with:
name: application.yml
path: ./src/main/resources/application.yml

- uses: actions/upload-artifact@v2
with:
name: firebase-key.json
path: ./src/main/resources/firebase-key.json

- uses: actions/upload-artifact@v2
with:
name: apple-key.p8
path: ./src/main/resources/apple-key.p8

# gradlew 권한 설정
- name: Grant execute permission for gradlew
run: chmod +x gradlew
Expand All @@ -55,3 +82,4 @@ jobs:
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
27 changes: 27 additions & 0 deletions .github/workflows/CI-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,33 @@ jobs:
restore-keys: |
${{ runner.os }}-gradle-
# 설정 파일 생성
- run: |
mkdir ./src/main/resources
cd ./src/main/resources
touch ./application.yml
echo "${{env.APPLICATION}}" > ./application.yml
touch ./firebase-key.json
echo "${{env.GOOGLE_APPLICATION_CREDENTIALS}}" | base64 --decode > ./firebase-key.json
touch ./apple-key.p8
echo "${{env.APPLE_KEY}}" > ./apple-key.p8
# 설정 파일을 작업공간에 저장
- uses: actions/upload-artifact@v2
with:
name: application.yml
path: ./src/main/resources/application.yml

- uses: actions/upload-artifact@v2
with:
name: firebase-key.json
path: ./src/main/resources/firebase-key.json

- uses: actions/upload-artifact@v2
with:
name: apple-key.p8
path: ./src/main/resources/apple-key.p8

# gradlew 권한 설정
- name: Grant execute permission for gradlew
run: chmod +x gradlew
Expand Down
228 changes: 114 additions & 114 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -1,114 +1,114 @@
name: CI/CD

on:
push:
branches: [ "main" ]

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
env:
working-directory: ./
APPLICATION: ${{ secrets.APPLICATION }}
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
APPLE_KEY: ${{ secrets.APPLE_KEY }}

steps:
# 소스 코드 체크아웃
- uses: actions/checkout@v2

# JDK 11 설정
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'

# Gradle 패키지 캐시
- name: Cache Gradle packages
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
# 설정 파일 생성
- run: |
mkdir ./src/main/resources
cd ./src/main/resources
touch ./application.yml
echo "${{env.APPLICATION}}" > ./application.yml
touch ./firebase-key.json
echo "${{env.GOOGLE_APPLICATION_CREDENTIALS}}" | base64 --decode > ./firebase-key.json
touch ./apple-key.p8
echo "${{env.APPLE_KEY}}" > ./apple-key.p8
# 설정 파일을 작업공간에 저장
- uses: actions/upload-artifact@v2
with:
name: application.yml
path: ./src/main/resources/application.yml

- uses: actions/upload-artifact@v2
with:
name: firebase-key.json
path: ./src/main/resources/firebase-key.json

- uses: actions/upload-artifact@v2
with:
name: apple-key.p8
path: ./src/main/resources/apple-key.p8

# gradlew 권한 설정
- name: Grant execute permission for gradlew
run: chmod +x gradlew
working-directory: ${{ env.working-directory }}

# Gradle로 빌드
- name: Build with Gradle
run: ./gradlew build
working-directory: ${{ env.working-directory }}

# Gradle 캐시 정리
- name: Cleanup Gradle Cache
if: ${{ always() }}
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
# Docker 이미지 빌드 및 푸시
- name: Docker build
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build --no-cache -t ${{ secrets.DOCKER_USERNAME }}/moing:green .
docker build --no-cache -t ${{ secrets.DOCKER_USERNAME }}/moing:blue .
docker push ${{ secrets.DOCKER_USERNAME }}/moing:green
docker push ${{ secrets.DOCKER_USERNAME }}/moing:blue
# EC2로 deploy.sh 전송
- name: Deploy deploy.sh to EC2
uses: appleboy/scp-action@master
with:
host: ${{ secrets.EC2_SERVER_HOST }}
username: ec2-user
key: ${{ secrets.PRIVATE_KEY }}
source: "./deploy.sh"
target: "/home/ec2-user/"

# 배포 스크립트 실행
- name: Deploy on EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_SERVER_HOST }}
username: ec2-user
key: ${{ secrets.PRIVATE_KEY }}
envs: GITHUB_SHA
script: |
chmod +x /home/ec2-user/deploy.sh
/home/ec2-user/deploy.sh
#name: CI/CD
#
#on:
# push:
# branches: [ "main" ]
#
#permissions:
# contents: read
#
#jobs:
# build:
# runs-on: ubuntu-latest
# env:
# working-directory: ./
# APPLICATION: ${{ secrets.APPLICATION }}
# GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
# APPLE_KEY: ${{ secrets.APPLE_KEY }}
#
# steps:
# # 소스 코드 체크아웃
# - uses: actions/checkout@v2
#
# # JDK 11 설정
# - name: Set up JDK 11
# uses: actions/setup-java@v2
# with:
# java-version: '11'
# distribution: 'adopt'
#
# # Gradle 패키지 캐시
# - name: Cache Gradle packages
# uses: actions/cache@v2
# with:
# path: |
# ~/.gradle/caches
# ~/.gradle/wrapper
# key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
# restore-keys: |
# ${{ runner.os }}-gradle-
#
# # 설정 파일 생성
# - run: |
# mkdir ./src/main/resources
# cd ./src/main/resources
# touch ./application.yml
# echo "${{env.APPLICATION}}" > ./application.yml
# touch ./firebase-key.json
# echo "${{env.GOOGLE_APPLICATION_CREDENTIALS}}" | base64 --decode > ./firebase-key.json
# touch ./apple-key.p8
# echo "${{env.APPLE_KEY}}" > ./apple-key.p8
#
# # 설정 파일을 작업공간에 저장
# - uses: actions/upload-artifact@v2
# with:
# name: application.yml
# path: ./src/main/resources/application.yml
#
# - uses: actions/upload-artifact@v2
# with:
# name: firebase-key.json
# path: ./src/main/resources/firebase-key.json
#
# - uses: actions/upload-artifact@v2
# with:
# name: apple-key.p8
# path: ./src/main/resources/apple-key.p8
#
# # gradlew 권한 설정
# - name: Grant execute permission for gradlew
# run: chmod +x gradlew
# working-directory: ${{ env.working-directory }}
#
# # Gradle로 빌드
# - name: Build with Gradle
# run: ./gradlew build
# working-directory: ${{ env.working-directory }}
#
# # Gradle 캐시 정리
# - name: Cleanup Gradle Cache
# if: ${{ always() }}
# run: |
# rm -f ~/.gradle/caches/modules-2/modules-2.lock
# rm -f ~/.gradle/caches/modules-2/gc.properties
#
# # Docker 이미지 빌드 및 푸시
# - name: Docker build
# run: |
# docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
# docker build --no-cache -t ${{ secrets.DOCKER_USERNAME }}/moing:green .
# docker build --no-cache -t ${{ secrets.DOCKER_USERNAME }}/moing:blue .
# docker push ${{ secrets.DOCKER_USERNAME }}/moing:green
# docker push ${{ secrets.DOCKER_USERNAME }}/moing:blue
#
# # EC2로 deploy.sh 전송
# - name: Deploy deploy.sh to EC2
# uses: appleboy/scp-action@master
# with:
# host: ${{ secrets.EC2_SERVER_HOST }}
# username: ec2-user
# key: ${{ secrets.PRIVATE_KEY }}
# source: "./deploy.sh"
# target: "/home/ec2-user/"
#
# # 배포 스크립트 실행
# - name: Deploy on EC2
# uses: appleboy/ssh-action@master
# with:
# host: ${{ secrets.EC2_SERVER_HOST }}
# username: ec2-user
# key: ${{ secrets.PRIVATE_KEY }}
# envs: GITHUB_SHA
# script: |
# chmod +x /home/ec2-user/deploy.sh
# /home/ec2-user/deploy.sh
4 changes: 4 additions & 0 deletions src/docs/asciidoc/Overview.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@
| 소모임을 가입할 때
| 소모임을 이미 가입함

| `T0005`
| 소모임을 가입할 때
| 소모임이 삭제됨

|===

=== MyPage ErrorCode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.moing.backend.domain.team.application.dto.response.CreateTeamResponse;
import com.moing.backend.domain.team.domain.entity.Team;
import com.moing.backend.domain.team.domain.service.TeamGetService;
import com.moing.backend.domain.team.exception.DeletedTeamException;
import com.moing.backend.domain.teamMember.domain.service.TeamMemberSaveService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
Expand All @@ -25,4 +26,5 @@ public CreateTeamResponse signInTeam(String socialId, Long teamId){
teamMemberSaveService.addTeamMember(team, member);
return new CreateTeamResponse(team.getTeamId());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.moing.backend.domain.team.exception;

import com.moing.backend.global.response.ErrorCode;
import org.springframework.http.HttpStatus;

public class DeletedTeamException extends TeamException{
public DeletedTeamException(){
super(ErrorCode.DELETED_TEAM_ERROR,
HttpStatus.NOT_FOUND);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.moing.backend.domain.team.domain.entity.Team;
import com.moing.backend.domain.team.exception.AlreadyJoinTeamException;
import com.moing.backend.domain.team.exception.AlreadyWithdrawTeamException;
import com.moing.backend.domain.team.exception.DeletedTeamException;
import com.moing.backend.domain.teamMember.domain.entity.TeamMember;
import com.moing.backend.domain.teamMember.domain.repository.TeamMemberRepository;
import com.moing.backend.global.annotation.DomainService;
Expand All @@ -20,6 +21,8 @@ public class TeamMemberSaveService {
public void addTeamMember(Team team, Member member) {
Optional<TeamMember> teamMember = teamMemberRepository.findTeamMemberByTeamAndMember(team, member);

checkDeletion(team);

if (teamMember.isPresent()) {
handleExistingMember(teamMember.get());
} else {
Expand All @@ -43,4 +46,9 @@ private void addNewTeamMember(Team team, Member member) {
this.teamMemberRepository.save(newMember);
}

private void checkDeletion(Team team){
if(team.isDeleted())
throw new DeletedTeamException();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public enum ErrorCode {
NOT_AUTH_BY_TEAM_ERROR("T0002","권한이 없습니다."),
ALREADY_WITHDRAW_ERROR("T0003","이미 탈퇴한 회원입니다."),
ALREADY_JOIN_ERROR("T0004","이미 가입한 회원입니다."),
DELETED_TEAM_ERROR("T0005", "삭제된 소모임입니다."),

//마이페이지 관련 에러 코드
INVALID_ALARM_ERROR("MP0001","유효하지 않는 알람 입력값입니다"),
Expand Down

0 comments on commit 1d5987f

Please sign in to comment.