Skip to content

Commit

Permalink
Merge pull request #17 from Central-MakeUs/feature/8
Browse files Browse the repository at this point in the history
Feature/8: Member κ΄€λ ¨ API 개발-1
  • Loading branch information
yxhwxn authored Jul 29, 2024
2 parents e7c36e2 + db18445 commit 8c518a4
Show file tree
Hide file tree
Showing 32 changed files with 867 additions and 146 deletions.
176 changes: 84 additions & 92 deletions .github/workflows/dev_deploy_docker_beanstalk.yml
Original file line number Diff line number Diff line change
@@ -1,92 +1,84 @@
#name: suppin dev Docker Beanstalk CI/CD # Workflow 이름
#
#on:
# push:
# branches:
# - dev
# pull_request:
# branches:
# - dev
# types: [closed]
# workflow_dispatch: # (2).μˆ˜λ™ 싀행도 κ°€λŠ₯ν•˜λ„λ‘
#
#jobs:
# build:
# runs-on: ubuntu-latest # (3).OSν™˜κ²½
# if: github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true)
#
#
# steps:
# - name: Checkout current repository
# uses: actions/checkout@v2
#
# - name: Set up JDK 17
# uses: actions/setup-java@v1
# with:
# java-version: 17
#
# - name: Grant execute permission for gradlew
# run: chmod +x ./gradlew
# shell: bash
#
# - name: Build with Gradle
# run: ./gradlew clean build
# shell: bash
#
# - 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: Login to Amazon ECR
# id: login-ecr
# uses: aws-actions/amazon-ecr-login@v1
#
# - name: Build, tag, and push image to Amazon ECR
# id: build-image
# env:
# ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
# ECR_REPOSITORY: tree-dev
# IMAGE_TAG: latest
# run: |
# # Docker 이미지 λΉŒλ“œ
# docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
#
# # λΉŒλ“œν•œ 이미지λ₯Ό Amazon ECR둜 ν‘Έμ‹œ
# docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
#
# # λΉŒλ“œλœ μ΄λ―Έμ§€μ˜ 정보 좜λ ₯
# echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
#
# - name: Get current time
# uses: 1466587594/get-current-time@v2
# id: current-time
# with:
# format: YYYYMMDD_HH-mm-ss
# utcOffset: "+09:00"
#
# - name: Generate deployment package
# run: |
# mkdir -p deploy
# cp -r .ebextensions deploy/.ebextensions
# cp Dockerrun.aws.json deploy/Dockerrun.aws.json
# cp -r .platform deploy/.platform
# cd deploy && zip -r deploy.zip .
#
# - name: Beanstalk Deploy
# uses: einaregilsson/beanstalk-deploy@v14
# with:
# aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# application_name: suppin-dev
# environment_name: suppin-dev-env
# version_label: github-action-${{ steps.current-time.outputs.formattedTime }}
# region: ap-northeast-2
# deployment_package: deploy/deploy.zip
# wait_for_deployment: false
#
#
#
#
name: suppin dev Docker Beanstalk CI/CD # Workflow 이름

on:

jobs:
build:
runs-on: ubuntu-latest # (3).OSν™˜κ²½
if: github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true)


steps:
- name: Checkout current repository
uses: actions/checkout@v2

- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17

- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
shell: bash

- name: Build with Gradle
run: ./gradlew clean build
shell: bash

- 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: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: tree-dev
IMAGE_TAG: latest
run: |
# Docker 이미지 λΉŒλ“œ
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
# λΉŒλ“œν•œ 이미지λ₯Ό Amazon ECR둜 ν‘Έμ‹œ
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
# λΉŒλ“œλœ μ΄λ―Έμ§€μ˜ 정보 좜λ ₯
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
- name: Get current time
uses: 1466587594/get-current-time@v2
id: current-time
with:
format: YYYYMMDD_HH-mm-ss
utcOffset: "+09:00"

- name: Generate deployment package
run: |
mkdir -p deploy
cp -r .ebextensions deploy/.ebextensions
cp Dockerrun.aws.json deploy/Dockerrun.aws.json
cp -r .platform deploy/.platform
cd deploy && zip -r deploy.zip .
- name: Beanstalk Deploy
uses: einaregilsson/beanstalk-deploy@v14
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
application_name: suppin-dev
environment_name: suppin-dev-env
version_label: github-action-${{ steps.current-time.outputs.formattedTime }}
region: ap-northeast-2
deployment_package: deploy/deploy.zip
wait_for_deployment: false




57 changes: 31 additions & 26 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,49 +1,54 @@
plugins {
id 'java'
id 'org.springframework.boot' version '2.7.7'
id 'io.spring.dependency-management' version '1.1.4'
id 'java'
id 'org.springframework.boot' version '3.2.8'
id 'io.spring.dependency-management' version '1.1.6'
}

group = 'com.cmc'
version = '0.0.1-SNAPSHOT'

java {
sourceCompatibility = '17'
targetCompatibility = '17'
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
sourceCompatibility = '17'
targetCompatibility = '17'
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

configurations {
compileOnly {
extendsFrom annotationProcessor
}
compileOnly {
extendsFrom annotationProcessor
}
}

repositories {
mavenCentral()
mavenCentral()
}

dependencies {
implementation 'javax.servlet:javax.servlet-api:4.0.1'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springdoc:springdoc-openapi-ui:1.6.11'
implementation 'org.springframework.boot:spring-boot-starter-validation'

compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'com.mysql:mysql-connector-j'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.1.0'

// JWT dependencies
implementation 'io.jsonwebtoken:jjwt-api:0.12.2'
implementation 'io.jsonwebtoken:jjwt-impl:0.12.2'
implementation 'io.jsonwebtoken:jjwt-jackson:0.12.2'

compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'com.mysql:mysql-connector-j'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

tasks.named('test') {
useJUnitPlatform()
useJUnitPlatform()
}

jar {
enabled = false
enabled = false
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.cmc.suppin.global.domain.BaseDateTimeEntity;
import com.cmc.suppin.survey.domain.Survey;
import jakarta.persistence.*;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -18,8 +18,11 @@ public class AnonymousParticipant extends BaseDateTimeEntity {
@JoinColumn(name = "survey_id")
private Survey survey;

@Column(columnDefinition = "VARCHAR(255)", nullable = false)
private String sessionId;
@Column(columnDefinition = "VARCHAR(13)", nullable = false)
private String phoneNumber;

@Column(nullable = false)
private Boolean isAgreed;

@OneToMany(mappedBy = "anonymousParticipant")
private List<Answer> answerList = new ArrayList<>();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/cmc/suppin/answer/domain/Answer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.cmc.suppin.global.domain.BaseDateTimeEntity;
import com.cmc.suppin.survey.domain.Question;
import jakarta.persistence.*;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.cmc.suppin.answer.domain;

import com.cmc.suppin.survey.domain.QuestionOption;
import jakarta.persistence.*;

import javax.persistence.*;

@Entity
public class AnswerOption {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/cmc/suppin/comment/domain/Comment.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.cmc.suppin.event.domain.Event;
import com.cmc.suppin.global.domain.BaseDateTimeEntity;
import jakarta.persistence.*;

import javax.persistence.*;

@Entity
public class Comment extends BaseDateTimeEntity {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/cmc/suppin/event/domain/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import com.cmc.suppin.global.enums.EventType;
import com.cmc.suppin.member.domain.Member;
import com.cmc.suppin.survey.domain.Survey;
import jakarta.persistence.*;

import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.cmc.suppin.global.domain;

import jakarta.persistence.Column;
import jakarta.persistence.EntityListeners;
import jakarta.persistence.MappedSuperclass;
import lombok.Getter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.Column;
import javax.persistence.EntityListeners;
import javax.persistence.MappedSuperclass;
import java.time.LocalDateTime;

@EntityListeners(AuditingEntityListener.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
package com.cmc.suppin.global.exception;

import com.cmc.suppin.global.exception.status.ErrorStatus;
import com.cmc.suppin.global.presentation.ApiResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.ConstraintViolationException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.context.request.ServletWebRequest;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
import com.cmc.suppin.global.exception.status.ErrorStatus;
import com.cmc.suppin.global.presentation.ApiResponse;

import javax.servlet.http.HttpServletRequest;
import javax.validation.ConstraintViolationException;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Optional;

@Slf4j
@RestControllerAdvice(annotations = {RestController.class})
Expand All @@ -34,6 +31,7 @@ public ResponseEntity<Object> validation(ConstraintViolationException e, WebRequ
return handleExceptionInternalConstraint(e, ErrorStatus.valueOf(errorMessage), HttpHeaders.EMPTY, request);
}

/*
@Override
public ResponseEntity<Object> handleMethodArgumentNotValid(
MethodArgumentNotValidException e, HttpHeaders headers, HttpStatus status, WebRequest request) {
Expand All @@ -49,6 +47,8 @@ public ResponseEntity<Object> handleMethodArgumentNotValid(
return handleExceptionInternalArgs(e, HttpHeaders.EMPTY, ErrorStatus.valueOf("_BAD_REQUEST"), request, errors);
}
*/


@org.springframework.web.bind.annotation.ExceptionHandler
public ResponseEntity<Object> exception(Exception e, WebRequest request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public enum ErrorStatus implements BaseErrorCode {
TEMP_EXCEPTION(HttpStatus.BAD_REQUEST, "TEMP4001", "ν…ŒμŠ€νŠΈ"),

// Member
MEMBER_NICKNAME_DUPLICATED(HttpStatus.BAD_REQUEST, "MEMBER4001", "μ€‘λ³΅λœ λ‹‰λ„€μž„ μž…λ‹ˆλ‹€."),
MEMBER_USERID_DUPLICATED(HttpStatus.BAD_REQUEST, "MEMBER4001", "μ€‘λ³΅λœ 아이디 μž…λ‹ˆλ‹€."),
MEMBER_PASSWORD_ERROR(HttpStatus.BAD_REQUEST, "MEMBER4002", "λΉ„λ°€λ²ˆν˜Έκ°€ 잘λͺ»λ˜μ—ˆμŠ΅λ‹ˆλ‹€."),

//JWT
Expand Down
Loading

0 comments on commit 8c518a4

Please sign in to comment.