diff --git "a/.github/ISSUE_TEMPLATE/\352\270\260\353\212\245-\354\232\224\354\262\255-\354\235\264\354\212\210-\355\205\234\355\224\214\353\246\277.md" "b/.github/ISSUE_TEMPLATE/\352\270\260\353\212\245-\354\232\224\354\262\255-\354\235\264\354\212\210-\355\205\234\355\224\214\353\246\277.md" new file mode 100644 index 00000000..3b00327a --- /dev/null +++ "b/.github/ISSUE_TEMPLATE/\352\270\260\353\212\245-\354\232\224\354\262\255-\354\235\264\354\212\210-\355\205\234\355\224\214\353\246\277.md" @@ -0,0 +1,21 @@ +--- +name: 기능 요청 이슈 템플릿 +about: 기능 요청 이슈 템플릿입니다. +title: '' +labels: '' +assignees: '' + +--- + +Add a title +관련 이슈 제목 작성 ex. 인프라 초기 세팅 +--------------------------------------------------------------- +## Description +- 어떤 이슈인지 설명하는 란 입니다. +## To Do +- [ ] 프론트 CI 속도 개선 +- [ ] 백엔드 CD gradle 파일 캐시 개선 +- [ ] AI는 모델 경량화 개선 작업 + +## ETC +- 행복하다 diff --git "a/.github/ISSUE_TEMPLATE/\353\262\204\352\267\270-\353\246\254\355\217\254\355\212\270-\354\235\264\354\212\210-\355\205\234\355\224\214\353\246\277.md" "b/.github/ISSUE_TEMPLATE/\353\262\204\352\267\270-\353\246\254\355\217\254\355\212\270-\354\235\264\354\212\210-\355\205\234\355\224\214\353\246\277.md" new file mode 100644 index 00000000..81f1a989 --- /dev/null +++ "b/.github/ISSUE_TEMPLATE/\353\262\204\352\267\270-\353\246\254\355\217\254\355\212\270-\354\235\264\354\212\210-\355\205\234\355\224\214\353\246\277.md" @@ -0,0 +1,36 @@ +--- +name: 버그 리포트 이슈 템플릿 +about: 버그 리포트 이슈 템플릿입니다. +title: '' +labels: '' +assignees: '' + +--- + +## 🐛 버그 리포트 (Bug Report) + +### 📋 개요 (Summary) +발생한 버그에 대한 간략한 설명을 적어주세요. + +### 🔍 재현 절차 (Steps to Reproduce) +버그를 재현할 수 있는 방법을 단계별로 설명해주세요: +1. 첫 번째 단계 +2. 두 번째 단계 +3. ... + +### 🖥️ 예상 동작 (Expected Behavior) +정상적으로 동작했을 때 어떤 결과가 나와야 하나요? + +### ❌ 실제 동작 (Actual Behavior) +버그로 인해 실제로 발생한 결과를 적어주세요. + +### 🖼️ 스크린샷 (Screenshots) +문제를 보여줄 수 있는 스크린샷이 있으면 첨부해주세요. + +### 💻 환경 (Environment) +- OS: [e.g., Windows 10] +- 브라우저: [e.g., Chrome 91] +- 기타: [e.g., Node.js 14] + +### 🔗 관련된 이슈들 (Related Issues) +- 이 버그와 관련된 이슈 번호가 있다면 적어주세요. (예: `#123`) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..7acc4d32 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,9 @@ +pr제목 -> 관련 이슈 #4 + +📌 관련 이슈 +--- + 프론트 CI 속도 개선 + +✨ PR 내용 +--- + 프론트 CI 속도 개선했음! diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..c2065bc2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,37 @@ +HELP.md +.gradle +build/ +!gradle/wrapper/gradle-wrapper.jar +!**/src/main/**/build/ +!**/src/test/**/build/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ diff --git a/build.gradle b/build.gradle new file mode 100644 index 00000000..1d4848cc --- /dev/null +++ b/build.gradle @@ -0,0 +1,66 @@ +plugins { + id 'java' + id 'org.springframework.boot' version '3.3.3' + id 'io.spring.dependency-management' version '1.1.6' + id "com.diffplug.spotless" version '6.25.0' +} + +group = 'com.ordertogether' +version = '0.0.1-SNAPSHOT' + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(21) + } +} + +repositories { + mavenCentral() +} + +apply { + from('./tasks/update-git-hooks.gradle') +} + +dependencies { + /** spring boot starter */ + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' + implementation 'org.springframework.boot:spring-boot-starter-security' + implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' + implementation 'org.springframework.boot:spring-boot-starter-web' + + testImplementation 'org.springframework.boot:spring-boot-starter-test' + testImplementation 'org.springframework.security:spring-security-test' + + /** thymeleaf and spring security integration */ + implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6' + + /** lombok */ + compileOnly 'org.projectlombok:lombok' + annotationProcessor 'org.projectlombok:lombok' + testCompileOnly 'org.projectlombok:lombok' + testAnnotationProcessor 'org.projectlombok:lombok' + + developmentOnly 'org.springframework.boot:spring-boot-devtools' + + runtimeOnly 'com.h2database:h2' + runtimeOnly 'com.mysql:mysql-connector-j' + + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' +} + +spotless { + java { + importOrder() + indentWithTabs(2) + indentWithSpaces(4) + removeUnusedImports() + googleJavaFormat() + trimTrailingWhitespace() + endWithNewline() + } +} + +tasks.named('test') { + useJUnitPlatform() +} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..a4b76b95 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..0aaefbca --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 00000000..f5feea6d --- /dev/null +++ b/gradlew @@ -0,0 +1,252 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 00000000..9d21a218 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,94 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/scripts/pre-commit b/scripts/pre-commit new file mode 100644 index 00000000..706c7654 --- /dev/null +++ b/scripts/pre-commit @@ -0,0 +1,13 @@ +#!/bin/bash + +#1. 변경된 파일들 이름만 추출하여 저장 +stagedFiles=$(git diff --staged --name-only) +#2. SpotlessApply 실행 +echo "Running spotlessApply. Formatting code..." +./gradlew spotlessApply +#3. 변경사항이 발생한 파일들 다시 git add +for file in $stagedFiles; do + if test -f "$file"; then + git add "$file" + fi +done \ No newline at end of file diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 00000000..84dbb72b --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'Team14_BE' diff --git a/src/main/java/com/ordertogether/team14_be/Team14BeApplication.java b/src/main/java/com/ordertogether/team14_be/Team14BeApplication.java new file mode 100644 index 00000000..fb2e4776 --- /dev/null +++ b/src/main/java/com/ordertogether/team14_be/Team14BeApplication.java @@ -0,0 +1,14 @@ +package com.ordertogether.team14_be; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.data.jpa.repository.config.EnableJpaAuditing; + +@EnableJpaAuditing +@SpringBootApplication +public class Team14BeApplication { + + public static void main(String[] args) { + SpringApplication.run(Team14BeApplication.class, args); + } +} diff --git a/src/main/java/com/ordertogether/team14_be/memebr/persistence/entity/Member.java b/src/main/java/com/ordertogether/team14_be/memebr/persistence/entity/Member.java new file mode 100644 index 00000000..fbc161b7 --- /dev/null +++ b/src/main/java/com/ordertogether/team14_be/memebr/persistence/entity/Member.java @@ -0,0 +1,66 @@ +package com.ordertogether.team14_be.memebr.persistence.entity; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +@Entity +public class Member { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "email") + private String email; + + @Column(name = "point") + private int point; + + @Column(name = "phone_number") + private String phoneNumber; + + @Column(name = "delivery_name") + private String deliveryName; + + @Column(name = "platform") + private String platform; + + protected Member() {} + + public Member(String email, int point, String phoneNumber, String deliveryName, + String platform) { + this.email = email; + this.point = point; + this.phoneNumber = phoneNumber; + this.deliveryName = deliveryName; + this.platform = platform; + } + + public Long getId() { + return id; + } + + public String getEmail() { + return email; + } + + public int getPoint() { + return point; + } + + public String getPhoneNumber() { + return phoneNumber; + } + + public String getDeliveryName() { + return deliveryName; + } + + public String getPlatform() { + return platform; + } + +} diff --git a/src/main/java/com/ordertogether/team14_be/payment/domain/BaseEntity.java b/src/main/java/com/ordertogether/team14_be/payment/domain/BaseEntity.java new file mode 100644 index 00000000..af808584 --- /dev/null +++ b/src/main/java/com/ordertogether/team14_be/payment/domain/BaseEntity.java @@ -0,0 +1,40 @@ +package com.ordertogether.team14_be.payment.domain; + +import jakarta.persistence.Column; +import jakarta.persistence.EntityListeners; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.MappedSuperclass; +import java.time.LocalDateTime; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; +import lombok.experimental.SuperBuilder; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +@MappedSuperclass +@EntityListeners(AuditingEntityListener.class) +@SuperBuilder +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@ToString +@Getter +public abstract class BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(nullable = false, updatable = false) + @CreatedDate + private LocalDateTime createdAt; + + @Column(nullable = false) + @LastModifiedDate + private LocalDateTime updatedAt; +} diff --git a/src/main/java/com/ordertogether/team14_be/payment/domain/PaymentEvent.java b/src/main/java/com/ordertogether/team14_be/payment/domain/PaymentEvent.java new file mode 100644 index 00000000..5097603e --- /dev/null +++ b/src/main/java/com/ordertogether/team14_be/payment/domain/PaymentEvent.java @@ -0,0 +1,33 @@ +package com.ordertogether.team14_be.payment.domain; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; +import lombok.experimental.SuperBuilder; + +@Entity +@Getter +@SuperBuilder +@ToString +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class PaymentEvent extends BaseEntity { + + @Column(nullable = false) + private Long buyerId; // 구매자 식별자 + + @Column(nullable = false) + private String orderId; + + private String orderName; + + @Column(nullable = false) + private String paymentKey; // PSP 결제 식별자 + + @Builder.Default private Boolean isPaymentDone = false; +} diff --git a/src/main/java/com/ordertogether/team14_be/payment/domain/PaymentOrder.java b/src/main/java/com/ordertogether/team14_be/payment/domain/PaymentOrder.java new file mode 100644 index 00000000..47f7c92c --- /dev/null +++ b/src/main/java/com/ordertogether/team14_be/payment/domain/PaymentOrder.java @@ -0,0 +1,45 @@ +package com.ordertogether.team14_be.payment.domain; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.FetchType; +import jakarta.persistence.ManyToOne; +import java.math.BigDecimal; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; +import lombok.experimental.SuperBuilder; + +@Entity +@Getter +@SuperBuilder +@ToString +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class PaymentOrder extends BaseEntity { + + @Column(nullable = false) + private Long sellerId; // 판매자 식별자 + + @ManyToOne(fetch = FetchType.LAZY) + private Product productId; + + @Column(nullable = false) + private String orderId; + + @Column(precision = 10, scale = 2) + private BigDecimal amount; // 결제 금액 + + @Enumerated(EnumType.STRING) + @Builder.Default + private PaymentOrderStatus paymentOrderStatus = PaymentOrderStatus.READY; + + @Builder.Default private Byte retryCount = 0; // 재시도 횟수 + + @Builder.Default private Byte retryThreshold = 5; // 재시도 허용 임계값 +} diff --git a/src/main/java/com/ordertogether/team14_be/payment/domain/PaymentOrderStatus.java b/src/main/java/com/ordertogether/team14_be/payment/domain/PaymentOrderStatus.java new file mode 100644 index 00000000..d09a7769 --- /dev/null +++ b/src/main/java/com/ordertogether/team14_be/payment/domain/PaymentOrderStatus.java @@ -0,0 +1,9 @@ +package com.ordertogether.team14_be.payment.domain; + +/** 결제 상태 */ +public enum PaymentOrderStatus { + READY, + EXECUTING, + SUCCESS, + FAIL; +} diff --git a/src/main/java/com/ordertogether/team14_be/payment/domain/Product.java b/src/main/java/com/ordertogether/team14_be/payment/domain/Product.java new file mode 100644 index 00000000..eb4326ce --- /dev/null +++ b/src/main/java/com/ordertogether/team14_be/payment/domain/Product.java @@ -0,0 +1,26 @@ +package com.ordertogether.team14_be.payment.domain; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import java.math.BigDecimal; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; +import lombok.experimental.SuperBuilder; + +@Entity +@Getter +@SuperBuilder +@ToString +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class Product extends BaseEntity { + + @Column(nullable = false) + private String name; + + @Column(nullable = false) + private BigDecimal price; +} diff --git a/src/main/java/com/ordertogether/team14_be/spot/controller/SpotController.java b/src/main/java/com/ordertogether/team14_be/spot/controller/SpotController.java new file mode 100644 index 00000000..902a8fa6 --- /dev/null +++ b/src/main/java/com/ordertogether/team14_be/spot/controller/SpotController.java @@ -0,0 +1,53 @@ +package com.ordertogether.team14_be.spot.controller; + +import com.ordertogether.team14_be.spot.dto.SpotDto; +import com.ordertogether.team14_be.spot.service.SpotService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.math.BigDecimal; +import java.util.List; + +@RestController +public class SpotController { + + private final SpotService spotService; + + @Autowired + public SpotController(SpotService spotService) { + this.spotService = spotService; + } + + //Spot 전체 조회하기 + @GetMapping("/api/v1/spot/{lat}/{lng}") + public ResponseEntity> getSpot(@PathVariable BigDecimal lat, @PathVariable BigDecimal lng) { + return ResponseEntity.ok(spotService.getSpot(lat, lng)); + } + + //Spot 생성하기 + @PostMapping("/api/v1/spot") + public ResponseEntity createSpot(@RequestBody SpotDto spotDto) { + return ResponseEntity.ok(spotService.createSpot(spotDto)); + } + + //Spot 상세 조회하기 + @GetMapping("/api/v1/spot/{id}") + public ResponseEntity getSpot(@PathVariable Long id) { + return ResponseEntity.ok(spotService.getSpot(id)); + } + + //Spot 수정하기 + @PutMapping("/api/v1/spot") + public ResponseEntity updateSpot(@RequestBody SpotDto spotDto) { + return ResponseEntity.ok(spotService.updateSpot(spotDto)); + } + + //Spot 삭제하기 + @DeleteMapping("/api/v1/spot/{id}") + public ResponseEntity deleteSpot(@PathVariable Long id) { + spotService.deleteSpot(id); + return ResponseEntity.ok().build(); + } + +} diff --git a/src/main/java/com/ordertogether/team14_be/spot/dto/SpotDto.java b/src/main/java/com/ordertogether/team14_be/spot/dto/SpotDto.java new file mode 100644 index 00000000..61f6047a --- /dev/null +++ b/src/main/java/com/ordertogether/team14_be/spot/dto/SpotDto.java @@ -0,0 +1,43 @@ +package com.ordertogether.team14_be.spot.dto; + +import com.ordertogether.team14_be.spot.entity.Spot; +import jakarta.persistence.Column; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; + +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Getter +public class SpotDto { + private Long id; + @Column(precision = 10, scale = 8) + private BigDecimal lat; + @Column(precision = 11, scale = 8) + private BigDecimal lng; + private String category; + private String store_name; + private int minimum_order_amount; + private String together_order_link; + private String pick_up_location; + private String delivery_status; + + public Spot toEntity() { + return Spot.builder() + .id(id) + .lat(lat) + .lng(lng) + .category(category) + .store_name(store_name) + .minimum_order_amount(minimum_order_amount) + .together_order_link(together_order_link) + .pick_up_location(pick_up_location) + .delivery_status(delivery_status) + .build(); + } + +} diff --git a/src/main/java/com/ordertogether/team14_be/spot/entity/Spot.java b/src/main/java/com/ordertogether/team14_be/spot/entity/Spot.java new file mode 100644 index 00000000..edbcf92f --- /dev/null +++ b/src/main/java/com/ordertogether/team14_be/spot/entity/Spot.java @@ -0,0 +1,36 @@ +package com.ordertogether.team14_be.spot.entity; + +import jakarta.persistence.*; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; + +@Entity +@Builder +@AllArgsConstructor +@NoArgsConstructor +@Getter +public class Spot { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(precision = 10, scale = 8) + private BigDecimal lat; + + @Column(precision = 11, scale = 8) + private BigDecimal lng; + private String category; + private String store_name; + private Integer minimum_order_amount; + + @Lob + @Column(columnDefinition = "MEDIUMTEXT") + private String together_order_link; + private String pick_up_location; + private String delivery_status; + +} diff --git a/src/main/java/com/ordertogether/team14_be/spot/repository/SpotRepository.java b/src/main/java/com/ordertogether/team14_be/spot/repository/SpotRepository.java new file mode 100644 index 00000000..13649a86 --- /dev/null +++ b/src/main/java/com/ordertogether/team14_be/spot/repository/SpotRepository.java @@ -0,0 +1,13 @@ +package com.ordertogether.team14_be.spot.repository; + +import com.ordertogether.team14_be.spot.entity.Spot; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.math.BigDecimal; +import java.util.List; + +@Repository +public interface SpotRepository extends JpaRepository { + List findByLatAndLng(BigDecimal lat, BigDecimal lng); +} diff --git a/src/main/java/com/ordertogether/team14_be/spot/service/SpotService.java b/src/main/java/com/ordertogether/team14_be/spot/service/SpotService.java new file mode 100644 index 00000000..225b29d3 --- /dev/null +++ b/src/main/java/com/ordertogether/team14_be/spot/service/SpotService.java @@ -0,0 +1,72 @@ +package com.ordertogether.team14_be.spot.service; + +import com.ordertogether.team14_be.spot.dto.SpotDto; +import com.ordertogether.team14_be.spot.entity.Spot; +import com.ordertogether.team14_be.spot.repository.SpotRepository; +import jakarta.persistence.EntityNotFoundException; +import java.math.BigDecimal; +import java.util.List; +import java.util.stream.Collectors; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class SpotService { + + private final SpotRepository spotRepository; + + @Autowired + public SpotService(SpotRepository spotRepository) { + this.spotRepository = spotRepository; + } + + // Spot 전체 조회하기 + public List getSpot(BigDecimal lat, BigDecimal lng) { + return spotRepository.findByLatAndLng(lat, lng).stream() + .map(this::toDto) + .collect(Collectors.toList()); + } + + public SpotDto createSpot(SpotDto spotDto) { + Spot spot = spotDto.toEntity(); + return toDto(spotRepository.save(spot)); + } + + // Spot 상세 조회하기 + public SpotDto getSpot(Long id) { + Spot spot = + spotRepository + .findById(id) + .orElseThrow(() -> new EntityNotFoundException("Spot not found")); + return toDto(spot); + } + + public SpotDto updateSpot(SpotDto spotDto) { + Spot spot = spotRepository.save(spotDto.toEntity()); + return toDto(spot); + } + + public void deleteSpot(Long id) { + spotRepository.deleteById(id); + } + + // Service Layer에서 toDto만들어서 매핑시키기 + public SpotDto toDto(Spot spotInStream) { + Spot spot = + spotRepository + .findById(spotInStream.getId()) + .orElseThrow(() -> new EntityNotFoundException("Spot not found")); + + return SpotDto.builder() + .id(spot.getId()) + .lat(spot.getLat()) + .lng(spot.getLng()) + .category(spot.getCategory()) + .store_name(spot.getStore_name()) + .minimum_order_amount(spot.getMinimum_order_amount()) + .together_order_link(spot.getTogether_order_link()) + .pick_up_location(spot.getPick_up_location()) + .delivery_status(spot.getDelivery_status()) + .build(); + } +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 00000000..45727403 --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,25 @@ +spring: + application: + name: Team14_BE + + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + username: root + password: + url: jdbc:mysql://localhost:3306/delivery_sharing + + jpa: + hibernate: + ddl-auto: create + properties: + hibernate: + format_sql: true + +logging: + level: + org: + hibernate: + SQL: debug + orm: + jdbc: + bind: trace \ No newline at end of file diff --git a/src/test/java/com/ordertogether/team14_be/Team14BeApplicationTests.java b/src/test/java/com/ordertogether/team14_be/Team14BeApplicationTests.java new file mode 100644 index 00000000..bc7fc754 --- /dev/null +++ b/src/test/java/com/ordertogether/team14_be/Team14BeApplicationTests.java @@ -0,0 +1,11 @@ +package com.ordertogether.team14_be; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class Team14BeApplicationTests { + + @Test + void contextLoads() {} +} diff --git a/tasks/update-git-hooks.gradle b/tasks/update-git-hooks.gradle new file mode 100644 index 00000000..f48f1c0c --- /dev/null +++ b/tasks/update-git-hooks.gradle @@ -0,0 +1,7 @@ +//pre-commit 스크립트 실행 권한 부여 +tasks.register('updateGitHooks', Copy) { + from './scripts/pre-commit' + into './.git/hooks' + fileMode 0775 +} +compileJava.dependsOn('updateGitHooks') \ No newline at end of file