From c2c4a161e806c90f730c9a8ad7bbc844760cbb20 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sat, 13 Jul 2024 23:46:17 +0900 Subject: [PATCH 001/212] =?UTF-8?q?setting:=EC=8A=A4=ED=94=84=EB=A7=81=20?= =?UTF-8?q?=EB=B6=80=ED=8A=B8=20=EC=84=B8=ED=8C=85=20-=20#1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 40 +++ build.gradle | 28 ++ gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 43453 bytes gradle/wrapper/gradle-wrapper.properties | 7 + gradlew | 249 ++++++++++++++++++ gradlew.bat | 92 +++++++ settings.gradle | 1 + .../refreshrator/RefreshratorApplication.java | 13 + .../RefreshratorApplicationTests.java | 13 + 9 files changed, 443 insertions(+) create mode 100644 .gitignore create mode 100644 build.gradle create mode 100644 gradle/wrapper/gradle-wrapper.jar create mode 100644 gradle/wrapper/gradle-wrapper.properties create mode 100644 gradlew create mode 100644 gradlew.bat create mode 100644 settings.gradle create mode 100644 src/main/java/com/hackathonteam1/refreshrator/RefreshratorApplication.java create mode 100644 src/test/java/com/hackathonteam1/refreshrator/RefreshratorApplicationTests.java diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d61011e --- /dev/null +++ b/.gitignore @@ -0,0 +1,40 @@ +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/ + +### IntelliJ IDEA ### +application.properties \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..e41f84e --- /dev/null +++ b/build.gradle @@ -0,0 +1,28 @@ +plugins { + id 'java' + id 'org.springframework.boot' version '3.3.1' + id 'io.spring.dependency-management' version '1.1.5' +} + +group = 'com.hackathonteam1' +version = '0.0.1-SNAPSHOT' + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(17) + } +} + +repositories { + mavenCentral() +} + +dependencies { + implementation 'org.springframework.boot:spring-boot-starter-web' + testImplementation 'org.springframework.boot:spring-boot-starter-test' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' +} + +tasks.named('test') { + useJUnitPlatform() +} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..e6441136f3d4ba8a0da8d277868979cfbc8ad796 GIT binary patch literal 43453 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 yu?e%!_ptzGB|8GrCfu%p?(_ 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
NnX)EH+Nua)3Y(c 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 '} + 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 "${APP_HOME:-./}" > /dev/null && pwd -P ) || 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 0000000..25da30d --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,92 @@ +@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 + +@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/settings.gradle b/settings.gradle new file mode 100644 index 0000000..0d73b8d --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'refreshrator' diff --git a/src/main/java/com/hackathonteam1/refreshrator/RefreshratorApplication.java b/src/main/java/com/hackathonteam1/refreshrator/RefreshratorApplication.java new file mode 100644 index 0000000..fbb4d27 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/RefreshratorApplication.java @@ -0,0 +1,13 @@ +package com.hackathonteam1.refreshrator; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class RefreshratorApplication { + + public static void main(String[] args) { + SpringApplication.run(RefreshratorApplication.class, args); + } + +} diff --git a/src/test/java/com/hackathonteam1/refreshrator/RefreshratorApplicationTests.java b/src/test/java/com/hackathonteam1/refreshrator/RefreshratorApplicationTests.java new file mode 100644 index 0000000..32dba6c --- /dev/null +++ b/src/test/java/com/hackathonteam1/refreshrator/RefreshratorApplicationTests.java @@ -0,0 +1,13 @@ +package com.hackathonteam1.refreshrator; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class RefreshratorApplicationTests { + + @Test + void contextLoads() { + } + +} From da5bc34f7113a00731dc7e8a63514fbbff84e013 Mon Sep 17 00:00:00 2001 From: jher235 Date: Mon, 15 Jul 2024 20:49:25 +0900 Subject: [PATCH 002/212] =?UTF-8?q?feat:=20.gitmessage.txt=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=B6=94=EA=B0=80=20-=20#4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitmessage.txt | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .gitmessage.txt diff --git a/.gitmessage.txt b/.gitmessage.txt new file mode 100644 index 0000000..bb2c529 --- /dev/null +++ b/.gitmessage.txt @@ -0,0 +1,50 @@ +################ +# <타입>: <제목> - <이슈번호> 의 형식으로 제목을 아래 공백줄에 작성 +# 제목은 50자 이내 / 변경사항이 "무엇"인지 명확히 작성 / 끝에 마침표 금지 +# 예) feat: 로그인 기능 추가 - #2 +# 바로 아래 공백은 제목과 본문의 분리를 위함 +################ +# 본문(구체적인 내용)을 아랫줄에 작성 +# 여러 줄의 메시지를 작성할 땐 "-"로 구분 (한 줄은 72자 이내) +################ +#feat +#새로운 기능 추가 +# +#fix +#버그 수정 +# +#design +#CSS 등 사용자 UI 디자인 변경 +# +#!BREAKING CHANGE +#커다란 API 변경의 경우 +# +#!HOTFIX +#급하게 치명적인 버그를 고쳐야하는 경우 +# +#style +#코드 포맷 변경, 세미 콜론 누락, 코드 수정이 없는 경우 +# +#refactor +#프로덕션 코드 리팩토링 +# +#comment +#필요한 주석 추가 및 변경 +# +#docs +#문서 수정 +# +#test +#테스트 추가, 테스트 리팩토링(프로덕션 코드 변경 X) +# +#setting +#패키지 설치, 개발 설정 +# +#chore +#빌드 테스트 업데이트, 패키지 매니저를 설정하는 경우(프로덕션 코드 변경 X) +# +#rename +#파일 혹은 폴더명을 수정하거나 옮기는 작업만인 경우 +# +#remove +#파일을 삭제하는 작업만 수행한 경우 \ No newline at end of file From 855654ce1b0d734daaa7be71683d771c0a2ae9c8 Mon Sep 17 00:00:00 2001 From: jher235 Date: Mon, 15 Jul 2024 21:07:28 +0900 Subject: [PATCH 003/212] =?UTF-8?q?=EC=9D=98=EC=A1=B4=EC=84=B1=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/build.gradle b/build.gradle index e41f84e..91964fe 100644 --- a/build.gradle +++ b/build.gradle @@ -21,6 +21,18 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' testImplementation 'org.springframework.boot:spring-boot-starter-test' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' + + compileOnly 'org.projectlombok:lombok:1.18.32' + annotationProcessor 'org.projectlombok:lombok:1.18.32' + + testCompileOnly 'org.projectlombok:lombok:1.18.32' + testAnnotationProcessor 'org.projectlombok:lombok:1.18.32' + + implementation 'org.springframework.boot:spring-boot-starter-validation' + + implementation 'org.springframework.boot:spring-boot-starter-data-jpa'//JPA + implementation 'org.springframework.boot:spring-boot-starter-jdbc'//JDBC + runtimeOnly 'com.mysql:mysql-connector-j'//MySQL } tasks.named('test') { From ceae620725073dbc811d57aeaad4f04d5b6b5dee Mon Sep 17 00:00:00 2001 From: jher235 Date: Tue, 16 Jul 2024 11:15:42 +0900 Subject: [PATCH 004/212] =?UTF-8?q?feature:BaseEntity=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?=20-=20#3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/RefreshratorApplication.java | 2 ++ .../refreshrator/entity/BaseEntity.java | 27 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/entity/BaseEntity.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/RefreshratorApplication.java b/src/main/java/com/hackathonteam1/refreshrator/RefreshratorApplication.java index fbb4d27..3ea5522 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/RefreshratorApplication.java +++ b/src/main/java/com/hackathonteam1/refreshrator/RefreshratorApplication.java @@ -2,8 +2,10 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.data.jpa.repository.config.EnableJpaAuditing; @SpringBootApplication +@EnableJpaAuditing public class RefreshratorApplication { public static void main(String[] args) { diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/BaseEntity.java b/src/main/java/com/hackathonteam1/refreshrator/entity/BaseEntity.java new file mode 100644 index 0000000..398f7e1 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/BaseEntity.java @@ -0,0 +1,27 @@ +package com.hackathonteam1.refreshrator.entity; + +import jakarta.persistence.*; +import lombok.Getter; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + + +import java.time.LocalDateTime; +import java.util.UUID; + +@MappedSuperclass// 상속을 받는 Entity 클래스에게 매핑 정보만 제공 +@Getter +@EntityListeners(AuditingEntityListener.class)// AuditingEntityListener는 엔티티의 생성 및 갱신 시간을 자동으로 설정하는 역할을 한다. +public class BaseEntity { + //PK 생성 + @Id + @GeneratedValue(strategy = GenerationType.AUTO, generator = "uuid2") + @Column(updatable = false, unique = true, nullable = false) + private UUID id; + @CreatedDate + private LocalDateTime createdAt; + @LastModifiedDate + private LocalDateTime updatedAt; +} + From 4ddf2f81b388a83a95a471845c8bf3eed717b1bd Mon Sep 17 00:00:00 2001 From: jher235 Date: Tue, 16 Jul 2024 12:20:31 +0900 Subject: [PATCH 005/212] =?UTF-8?q?feature:=20user=20=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=20=EC=9E=91=EC=84=B1=20-#3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/entity/User.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/entity/User.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/User.java b/src/main/java/com/hackathonteam1/refreshrator/entity/User.java new file mode 100644 index 0000000..1f50ba5 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/User.java @@ -0,0 +1,41 @@ +package com.hackathonteam1.refreshrator.entity; + +import jakarta.persistence.*; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.hibernate.validator.internal.util.stereotypes.Lazy; + +import java.util.List; + +@Getter +@AllArgsConstructor +@NoArgsConstructor +@Builder +@Entity(name = "user") +public class User extends BaseEntity{ + + @Column(unique = true, nullable = false) + private String email; + + @Column(nullable = false) + private String name; + + @Column(nullable = false) + private String password; + + @Column(nullable = false) + private String nickName; + + @OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) + private List fridgeItems; + + @OneToMany(mappedBy = "user", cascade = CascadeType.PERSIST, fetch = FetchType.LAZY) + private List recipes; + + @OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) + private List likes; + + +} From 42d30bc7ba28aae3a62629f6cd8c14a318f11b68 Mon Sep 17 00:00:00 2001 From: jher235 Date: Tue, 16 Jul 2024 16:58:11 +0900 Subject: [PATCH 006/212] =?UTF-8?q?feature:=20fridge=20=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=20=EC=9E=91=EC=84=B1=20-=20#3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/entity/Fridge.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/entity/Fridge.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/Fridge.java b/src/main/java/com/hackathonteam1/refreshrator/entity/Fridge.java new file mode 100644 index 0000000..bb4740b --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/Fridge.java @@ -0,0 +1,23 @@ +package com.hackathonteam1.refreshrator.entity; + +import jakarta.persistence.CascadeType; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.OneToMany; +import lombok.*; + +import java.util.List; + +//fridge와 user는 단방향. +@Entity(name = "fridge") +@Builder +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +public class Fridge extends BaseEntity{ + + @OneToMany(mappedBy = "fridge", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) + private List fridgeItem; + +} From 141843e8487db2b654f254bf808ee88e4bed8037 Mon Sep 17 00:00:00 2001 From: jher235 Date: Tue, 16 Jul 2024 16:58:30 +0900 Subject: [PATCH 007/212] =?UTF-8?q?feature:=20fridgeItem=20=EC=97=94?= =?UTF-8?q?=ED=8B=B0=ED=8B=B0=20=EC=9E=91=EC=84=B1=20-=20#3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/entity/FridgeItem.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/entity/FridgeItem.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/FridgeItem.java b/src/main/java/com/hackathonteam1/refreshrator/entity/FridgeItem.java new file mode 100644 index 0000000..e2d3ee4 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/FridgeItem.java @@ -0,0 +1,43 @@ +package com.hackathonteam1.refreshrator.entity; + +import jakarta.persistence.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.time.LocalDate; + +@Entity(name = "fridge_item") +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +public class FridgeItem extends BaseEntity{ + + @ManyToOne(optional = false, fetch = FetchType.LAZY) + private Fridge fridge; + + @ManyToOne(optional = false, fetch = FetchType.EAGER) + private Ingredient ingredient; + + @Column() + private LocalDate expiredDate; + + @Column + private int quantity; + + @Column(nullable = false) + @Enumerated(EnumType.STRING) + private Storage storage; + + @Column + private String memo; + + @Column + private boolean expired; + + public enum Storage{ + STORE_AT_ROOM_TEMPERATURE, REFRIGERATED, FROZEN; + } +} From a3366600eb6bb6cdd5f16301bc01a24fc11696c8 Mon Sep 17 00:00:00 2001 From: jher235 Date: Tue, 16 Jul 2024 16:58:41 +0900 Subject: [PATCH 008/212] =?UTF-8?q?feature:=20image=20=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=20=EC=9E=91=EC=84=B1=20-=20#3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/entity/Image.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/entity/Image.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/Image.java b/src/main/java/com/hackathonteam1/refreshrator/entity/Image.java new file mode 100644 index 0000000..ce1a15d --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/Image.java @@ -0,0 +1,28 @@ +package com.hackathonteam1.refreshrator.entity; + + +import jakarta.persistence.*; +import lombok.*; +import org.hibernate.validator.internal.util.stereotypes.Lazy; + +import java.util.UUID; + +@Entity(name = "image") +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +@Builder +@ToString(exclude = "recipe") +public class Image { + + @Id + private UUID id; + + @Column(nullable = false) + private String fileName; //id(uuid)+기존 파일이름 + + @OneToOne(fetch = FetchType.LAZY, optional = false, mappedBy = "image_id") + private Recipe recipe; + +} From d34442cb3c50bc51faad4162aa30d104880d82c0 Mon Sep 17 00:00:00 2001 From: jher235 Date: Tue, 16 Jul 2024 16:59:04 +0900 Subject: [PATCH 009/212] =?UTF-8?q?feature:=20ingredient=20=EC=97=94?= =?UTF-8?q?=ED=8B=B0=ED=8B=B0=20=EC=9E=91=EC=84=B1=20-=20#3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/entity/Ingredient.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/entity/Ingredient.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/Ingredient.java b/src/main/java/com/hackathonteam1/refreshrator/entity/Ingredient.java new file mode 100644 index 0000000..c67fee5 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/Ingredient.java @@ -0,0 +1,26 @@ +package com.hackathonteam1.refreshrator.entity; + +import jakarta.persistence.*; +import lombok.*; + +import java.time.LocalDate; +import java.util.List; + +@Entity +@Builder +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +public class Ingredient extends BaseEntity{ + + @Column(nullable = false) + private String name; + + @OneToMany(cascade = CascadeType.PERSIST, mappedBy = "ingredient", fetch = FetchType.LAZY) + private List fridgeItems; + + @OneToMany(cascade = CascadeType.PERSIST, mappedBy = "ingredient", fetch = FetchType.LAZY) + private List ingredientRecipes; + +} From 01e9284e7fb6d9e84aad324c853c0f94b25b065d Mon Sep 17 00:00:00 2001 From: jher235 Date: Tue, 16 Jul 2024 16:59:19 +0900 Subject: [PATCH 010/212] =?UTF-8?q?feature:=20ingredientRecipe=20=EC=97=94?= =?UTF-8?q?=ED=8B=B0=ED=8B=B0=20=EC=9E=91=EC=84=B1=20-=20#3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/entity/IngredientRecipe.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/entity/IngredientRecipe.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/IngredientRecipe.java b/src/main/java/com/hackathonteam1/refreshrator/entity/IngredientRecipe.java new file mode 100644 index 0000000..6fa5d7f --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/IngredientRecipe.java @@ -0,0 +1,22 @@ +package com.hackathonteam1.refreshrator.entity; + +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.ManyToOne; +import lombok.*; + +@Entity(name = "ingredient_recipe") +@Builder +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +public class IngredientRecipe extends BaseEntity{ + + @ManyToOne(optional = false, fetch = FetchType.EAGER) + private Ingredient ingredient; + + @ManyToOne(optional = false, fetch = FetchType.LAZY) + private Recipe recipe; + +} From 0823280ff266ae56bcae5741b82aab474103a990 Mon Sep 17 00:00:00 2001 From: jher235 Date: Tue, 16 Jul 2024 16:59:29 +0900 Subject: [PATCH 011/212] =?UTF-8?q?feature:=20recipe=20=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=20=EC=9E=91=EC=84=B1=20-=20#3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/entity/Recipe.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/entity/Recipe.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/Recipe.java b/src/main/java/com/hackathonteam1/refreshrator/entity/Recipe.java new file mode 100644 index 0000000..d4a3911 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/Recipe.java @@ -0,0 +1,32 @@ +package com.hackathonteam1.refreshrator.entity; + +import jakarta.persistence.*; +import lombok.*; + +import java.util.List; + +@Entity(name = "recipe") +@Builder +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +public class Recipe extends BaseEntity{ + + @Column(nullable = false) + private String name; + + @Column(nullable = false) + private String cookingStep; + + @ManyToOne(fetch = FetchType.LAZY, optional = false) + private User user; + + @OneToMany(mappedBy = "recipe", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) + private List recipeLikes; + + @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) + @JoinColumn(name = "image_id") + private Image image; + +} From cca4028470e5d4a42d7f657d228018dc3a6d8f44 Mon Sep 17 00:00:00 2001 From: jher235 Date: Tue, 16 Jul 2024 16:59:43 +0900 Subject: [PATCH 012/212] =?UTF-8?q?feature:=20recipeLike=20=EC=97=94?= =?UTF-8?q?=ED=8B=B0=ED=8B=B0=20=EC=9E=91=EC=84=B1=20-=20#3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/entity/RecipeLike.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/entity/RecipeLike.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/RecipeLike.java b/src/main/java/com/hackathonteam1/refreshrator/entity/RecipeLike.java new file mode 100644 index 0000000..c7a14c7 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/RecipeLike.java @@ -0,0 +1,20 @@ +package com.hackathonteam1.refreshrator.entity; + +import jakarta.persistence.Entity; +import jakarta.persistence.ManyToOne; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Entity(name = "like") +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +public class RecipeLike extends BaseEntity{ + + @ManyToOne(optional = true) + private User user; + +} From 73acf31bef702eb4726cb233d7894161f87b42ec Mon Sep 17 00:00:00 2001 From: jher235 Date: Tue, 16 Jul 2024 17:00:40 +0900 Subject: [PATCH 013/212] =?UTF-8?q?feature:=20user=20=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=20=EC=88=98=EC=A0=95=20-=20#3=20user=EC=97=94?= =?UTF-8?q?=ED=8B=B0=ED=8B=B0=EC=97=90=EC=84=9C=20fridge=EB=A5=BC=20?= =?UTF-8?q?=EA=B0=96=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hackathonteam1/refreshrator/entity/User.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/User.java b/src/main/java/com/hackathonteam1/refreshrator/entity/User.java index 1f50ba5..12b4243 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/entity/User.java +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/User.java @@ -5,7 +5,6 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -import org.hibernate.validator.internal.util.stereotypes.Lazy; import java.util.List; @@ -28,14 +27,14 @@ public class User extends BaseEntity{ @Column(nullable = false) private String nickName; - @OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) - private List fridgeItems; + @OneToOne(mappedBy = "user") + @JoinColumn(name = "fridge_id") + private Fridge fridge; @OneToMany(mappedBy = "user", cascade = CascadeType.PERSIST, fetch = FetchType.LAZY) private List recipes; @OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) - private List likes; - + private List recipeLikes; } From 66e614f1286ee88d89b6d33dd11ce10375802c3d Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 17 Jul 2024 17:22:59 +0900 Subject: [PATCH 014/212] =?UTF-8?q?feature:=20Fridge=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=20=EC=88=98=EC=A0=95=20-#3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hackathonteam1/refreshrator/entity/Fridge.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/Fridge.java b/src/main/java/com/hackathonteam1/refreshrator/entity/Fridge.java index bb4740b..a5358d9 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/entity/Fridge.java +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/Fridge.java @@ -1,10 +1,8 @@ package com.hackathonteam1.refreshrator.entity; -import jakarta.persistence.CascadeType; -import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; -import jakarta.persistence.OneToMany; +import jakarta.persistence.*; import lombok.*; +import org.springframework.data.repository.cdi.Eager; import java.util.List; @@ -20,4 +18,8 @@ public class Fridge extends BaseEntity{ @OneToMany(mappedBy = "fridge", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) private List fridgeItem; + @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) + @JoinColumn(name = "user_id") + private User user; + } From 5583fbb855f1cb4cf946ddfe594a52ca144c72d6 Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 17 Jul 2024 19:07:30 +0900 Subject: [PATCH 015/212] =?UTF-8?q?feat:=20FridgeItem=20=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=20=EC=88=98=EC=A0=95=20-#3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hackathonteam1/refreshrator/entity/FridgeItem.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/FridgeItem.java b/src/main/java/com/hackathonteam1/refreshrator/entity/FridgeItem.java index e2d3ee4..5f5c703 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/entity/FridgeItem.java +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/FridgeItem.java @@ -16,12 +16,14 @@ public class FridgeItem extends BaseEntity{ @ManyToOne(optional = false, fetch = FetchType.LAZY) + @JoinColumn(name = "fridge_id", nullable = false) private Fridge fridge; - @ManyToOne(optional = false, fetch = FetchType.EAGER) + @ManyToOne(fetch = FetchType.EAGER, optional = false) + @JoinColumn(name = "ingredient_id", nullable = false) private Ingredient ingredient; - @Column() + @Column(nullable = false) private LocalDate expiredDate; @Column @@ -34,9 +36,6 @@ public class FridgeItem extends BaseEntity{ @Column private String memo; - @Column - private boolean expired; - public enum Storage{ STORE_AT_ROOM_TEMPERATURE, REFRIGERATED, FROZEN; } From 0e9edc8ac650079fe0b317c6fd1c372420a92181 Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 17 Jul 2024 19:07:40 +0900 Subject: [PATCH 016/212] =?UTF-8?q?feat:=20Image=20=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=20=EC=88=98=EC=A0=95=20-#3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hackathonteam1/refreshrator/entity/Image.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/Image.java b/src/main/java/com/hackathonteam1/refreshrator/entity/Image.java index ce1a15d..6d7ecf8 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/entity/Image.java +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/Image.java @@ -14,15 +14,9 @@ @NoArgsConstructor @Builder @ToString(exclude = "recipe") -public class Image { - - @Id - private UUID id; +public class Image extends BaseEntity{ @Column(nullable = false) - private String fileName; //id(uuid)+기존 파일이름 - - @OneToOne(fetch = FetchType.LAZY, optional = false, mappedBy = "image_id") - private Recipe recipe; + private String url; //aws s3의 url } From 48319f3f3c0516fa39ba0e1e7fa693b419995cc9 Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 17 Jul 2024 19:07:56 +0900 Subject: [PATCH 017/212] =?UTF-8?q?feat:=20Ingredient=20=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=20=EC=88=98=EC=A0=95=20-#3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hackathonteam1/refreshrator/entity/Ingredient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/Ingredient.java b/src/main/java/com/hackathonteam1/refreshrator/entity/Ingredient.java index c67fee5..3265e01 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/entity/Ingredient.java +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/Ingredient.java @@ -20,7 +20,7 @@ public class Ingredient extends BaseEntity{ @OneToMany(cascade = CascadeType.PERSIST, mappedBy = "ingredient", fetch = FetchType.LAZY) private List fridgeItems; - @OneToMany(cascade = CascadeType.PERSIST, mappedBy = "ingredient", fetch = FetchType.LAZY) + @OneToMany(cascade = CascadeType.ALL, mappedBy = "ingredient", fetch = FetchType.LAZY) private List ingredientRecipes; } From eff0eadaa4670124edd3ed720b9f99bbf18f6775 Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 17 Jul 2024 19:08:21 +0900 Subject: [PATCH 018/212] =?UTF-8?q?feat:=20IngredientRecipe=20=EC=97=94?= =?UTF-8?q?=ED=8B=B0=ED=8B=B0=20=EC=88=98=EC=A0=95=20-#3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/entity/IngredientRecipe.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/IngredientRecipe.java b/src/main/java/com/hackathonteam1/refreshrator/entity/IngredientRecipe.java index 6fa5d7f..afb5324 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/entity/IngredientRecipe.java +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/IngredientRecipe.java @@ -1,8 +1,6 @@ package com.hackathonteam1.refreshrator.entity; -import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; -import jakarta.persistence.ManyToOne; +import jakarta.persistence.*; import lombok.*; @Entity(name = "ingredient_recipe") @@ -14,9 +12,11 @@ public class IngredientRecipe extends BaseEntity{ @ManyToOne(optional = false, fetch = FetchType.EAGER) + @JoinColumn(name = "ingredient_id", nullable = false) private Ingredient ingredient; @ManyToOne(optional = false, fetch = FetchType.LAZY) + @JoinColumn(name = "recipe_id", nullable = false) private Recipe recipe; } From 33deaba59ffc1be19c2779766b39d637b3b756bb Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 17 Jul 2024 19:08:44 +0900 Subject: [PATCH 019/212] =?UTF-8?q?feat:=20RecipeLike=20=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=20=EC=88=98=EC=A0=95=20-#3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hackathonteam1/refreshrator/entity/RecipeLike.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/RecipeLike.java b/src/main/java/com/hackathonteam1/refreshrator/entity/RecipeLike.java index c7a14c7..269b472 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/entity/RecipeLike.java +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/RecipeLike.java @@ -1,6 +1,8 @@ package com.hackathonteam1.refreshrator.entity; import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; import lombok.AllArgsConstructor; import lombok.Getter; @@ -14,7 +16,12 @@ @AllArgsConstructor public class RecipeLike extends BaseEntity{ - @ManyToOne(optional = true) + @ManyToOne(optional = false, fetch = FetchType.LAZY) + @JoinColumn(name = "user_id", nullable = false) private User user; + @ManyToOne(optional = false, fetch = FetchType.LAZY) + @JoinColumn(name = "recipe_id", nullable = false) + private Recipe recipe; + } From c5ebeba0b28d6c68d6bf1ca1b7dbb47b34e70e51 Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 17 Jul 2024 19:09:09 +0900 Subject: [PATCH 020/212] =?UTF-8?q?feat:=20User=20=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=20=EC=88=98=EC=A0=95=20-#3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hackathonteam1/refreshrator/entity/User.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/User.java b/src/main/java/com/hackathonteam1/refreshrator/entity/User.java index 12b4243..c667835 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/entity/User.java +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/User.java @@ -24,13 +24,6 @@ public class User extends BaseEntity{ @Column(nullable = false) private String password; - @Column(nullable = false) - private String nickName; - - @OneToOne(mappedBy = "user") - @JoinColumn(name = "fridge_id") - private Fridge fridge; - @OneToMany(mappedBy = "user", cascade = CascadeType.PERSIST, fetch = FetchType.LAZY) private List recipes; From 8f77b4a1bef09bcb20134a89b9015945df9183c8 Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 17 Jul 2024 22:11:08 +0900 Subject: [PATCH 021/212] =?UTF-8?q?feat:=20ErrorCode=20=EC=83=9D=EC=84=B1?= =?UTF-8?q?=20-#7=20################=20#=20<=ED=83=80=EC=9E=85>:=20=20-=20<=EC=9D=B4=EC=8A=88=EB=B2=88=ED=98=B8?= =?UTF-8?q?>=20=EC=9D=98=20=ED=98=95=EC=8B=9D=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EC=A0=9C=EB=AA=A9=EC=9D=84=20=EC=95=84=EB=9E=98=20=EA=B3=B5?= =?UTF-8?q?=EB=B0=B1=EC=A4=84=EC=97=90=20=EC=9E=91=EC=84=B1=20#=20?= =?UTF-8?q?=EC=A0=9C=EB=AA=A9=EC=9D=80=2050=EC=9E=90=20=EC=9D=B4=EB=82=B4?= =?UTF-8?q?=20/=20=EB=B3=80=EA=B2=BD=EC=82=AC=ED=95=AD=EC=9D=B4=20"?= =?UTF-8?q?=EB=AC=B4=EC=97=87"=EC=9D=B8=EC=A7=80=20=EB=AA=85=ED=99=95?= =?UTF-8?q?=ED=9E=88=20=EC=9E=91=EC=84=B1=20/=20=EB=81=9D=EC=97=90=20?= =?UTF-8?q?=EB=A7=88=EC=B9=A8=ED=91=9C=20=EA=B8=88=EC=A7=80=20#=20?= =?UTF-8?q?=EC=98=88)=20feat:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=B6=94=EA=B0=80=20-=20#2=20#=20=EB=B0=94?= =?UTF-8?q?=EB=A1=9C=20=EC=95=84=EB=9E=98=20=EA=B3=B5=EB=B0=B1=EC=9D=80=20?= =?UTF-8?q?=EC=A0=9C=EB=AA=A9=EA=B3=BC=20=EB=B3=B8=EB=AC=B8=EC=9D=98=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC=EB=A5=BC=20=EC=9C=84=ED=95=A8=20############?= =?UTF-8?q?####=20#=20=EB=B3=B8=EB=AC=B8(=EA=B5=AC=EC=B2=B4=EC=A0=81?= =?UTF-8?q?=EC=9D=B8=20=EB=82=B4=EC=9A=A9)=EC=9D=84=20=EC=95=84=EB=9E=AB?= =?UTF-8?q?=EC=A4=84=EC=97=90=20=EC=9E=91=EC=84=B1=20#=20=EC=97=AC?= =?UTF-8?q?=EB=9F=AC=20=EC=A4=84=EC=9D=98=20=EB=A9=94=EC=8B=9C=EC=A7=80?= =?UTF-8?q?=EB=A5=BC=20=EC=9E=91=EC=84=B1=ED=95=A0=20=EB=95=90=20"-"?= =?UTF-8?q?=EB=A1=9C=20=EA=B5=AC=EB=B6=84=20(=ED=95=9C=20=EC=A4=84?= =?UTF-8?q?=EC=9D=80=2072=EC=9E=90=20=EC=9D=B4=EB=82=B4)=20###############?= =?UTF-8?q?#=20#feat=20#=EC=83=88=EB=A1=9C=EC=9A=B4=20=EA=B8=B0=EB=8A=A5?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80=20#=20#fix=20#=EB=B2=84=EA=B7=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20#=20#design=20#CSS=20=EB=93=B1=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=EC=9E=90=20UI=20=EB=94=94=EC=9E=90=EC=9D=B8=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20#=20#!BREAKING=20CHANGE=20#=EC=BB=A4?= =?UTF-8?q?=EB=8B=A4=EB=9E=80=20API=20=EB=B3=80=EA=B2=BD=EC=9D=98=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20#=20#!HOTFIX=20#=EA=B8=89=ED=95=98?= =?UTF-8?q?=EA=B2=8C=20=EC=B9=98=EB=AA=85=EC=A0=81=EC=9D=B8=20=EB=B2=84?= =?UTF-8?q?=EA=B7=B8=EB=A5=BC=20=EA=B3=A0=EC=B3=90=EC=95=BC=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20#=20#style=20#=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=ED=8F=AC=EB=A7=B7=20=EB=B3=80=EA=B2=BD,=20?= =?UTF-8?q?=EC=84=B8=EB=AF=B8=20=EC=BD=9C=EB=A1=A0=20=EB=88=84=EB=9D=BD,?= =?UTF-8?q?=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95=EC=9D=B4=20=EC=97=86?= =?UTF-8?q?=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20#=20#refactor=20#=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EB=8D=95=EC=85=98=20=EC=BD=94=EB=93=9C=20=EB=A6=AC?= =?UTF-8?q?=ED=8C=A9=ED=86=A0=EB=A7=81=20#=20#comment=20#=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EC=A3=BC=EC=84=9D=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20=EB=B3=80=EA=B2=BD=20#=20#docs=20#=EB=AC=B8?= =?UTF-8?q?=EC=84=9C=20=EC=88=98=EC=A0=95=20#=20#test=20#=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=B6=94=EA=B0=80,=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81(=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EB=8D=95=EC=85=98=20=EC=BD=94=EB=93=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20X)=20#=20#setting=20#=ED=8C=A8=ED=82=A4=EC=A7=80=20?= =?UTF-8?q?=EC=84=A4=EC=B9=98,=20=EA=B0=9C=EB=B0=9C=20=EC=84=A4=EC=A0=95?= =?UTF-8?q?=20#=20#chore=20#=EB=B9=8C=EB=93=9C=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8,=20=ED=8C=A8?= =?UTF-8?q?=ED=82=A4=EC=A7=80=20=EB=A7=A4=EB=8B=88=EC=A0=80=EB=A5=BC=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=ED=95=98=EB=8A=94=20=EA=B2=BD=EC=9A=B0(?= =?UTF-8?q?=ED=94=84=EB=A1=9C=EB=8D=95=EC=85=98=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20X)=20#=20#rename=20#=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=ED=98=B9=EC=9D=80=20=ED=8F=B4=EB=8D=94=EB=AA=85=EC=9D=84=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=ED=95=98=EA=B1=B0=EB=82=98=20=EC=98=AE?= =?UTF-8?q?=EA=B8=B0=EB=8A=94=20=EC=9E=91=EC=97=85=EB=A7=8C=EC=9D=B8=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20#=20#remove=20#=ED=8C=8C=EC=9D=BC=EC=9D=84?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C=ED=95=98=EB=8A=94=20=EC=9E=91=EC=97=85?= =?UTF-8?q?=EB=A7=8C=20=EC=88=98=ED=96=89=ED=95=9C=20=EA=B2=BD=EC=9A=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/errorcode/ErrorCode.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java new file mode 100644 index 0000000..4d27006 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java @@ -0,0 +1,38 @@ +package com.hackathonteam1.refreshrator.exception.errorcode; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum ErrorCode { + + //BadRequestException + SIZE("4000", "길이가 유효하지 않습니다."), + PATTERN("4001","형식에 맞지 않습니다."), + NOT_BLANK("4002", "필수값이 공백입니다."), + LENGTH("4003", "길이가 유효하지 않습니다."), + EMAIL("4004", "이메일 형식이 유효하지 않습니다."); + + //AuthorizedException + + //ForbiddenException + + //NotFoundException + + //ConflictException + + private final String code; + private final String message; + + public static ErrorCode resolveValidationErrorCode(String code){ + return switch (code){ + case "Size" -> SIZE; + case "Pattern" -> PATTERN; + case "NotBlank" -> NOT_BLANK; + case "Length" -> LENGTH; + case "Email" -> EMAIL; + default -> throw new IllegalArgumentException("Unexpected value: "+ code); + }; + } +} From 121b8b4daf809502a92d9271d68f601823e6faa2 Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 17 Jul 2024 22:11:32 +0900 Subject: [PATCH 022/212] =?UTF-8?q?feat:=20ErrorResponseDto=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20-#7=20################=20#=20<=ED=83=80=EC=9E=85>:?= =?UTF-8?q?=20<=EC=A0=9C=EB=AA=A9>=20-=20<=EC=9D=B4=EC=8A=88=EB=B2=88?= =?UTF-8?q?=ED=98=B8>=20=EC=9D=98=20=ED=98=95=EC=8B=9D=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EC=A0=9C=EB=AA=A9=EC=9D=84=20=EC=95=84=EB=9E=98=20=EA=B3=B5?= =?UTF-8?q?=EB=B0=B1=EC=A4=84=EC=97=90=20=EC=9E=91=EC=84=B1=20#=20?= =?UTF-8?q?=EC=A0=9C=EB=AA=A9=EC=9D=80=2050=EC=9E=90=20=EC=9D=B4=EB=82=B4?= =?UTF-8?q?=20/=20=EB=B3=80=EA=B2=BD=EC=82=AC=ED=95=AD=EC=9D=B4=20"?= =?UTF-8?q?=EB=AC=B4=EC=97=87"=EC=9D=B8=EC=A7=80=20=EB=AA=85=ED=99=95?= =?UTF-8?q?=ED=9E=88=20=EC=9E=91=EC=84=B1=20/=20=EB=81=9D=EC=97=90=20?= =?UTF-8?q?=EB=A7=88=EC=B9=A8=ED=91=9C=20=EA=B8=88=EC=A7=80=20#=20?= =?UTF-8?q?=EC=98=88)=20feat:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=B6=94=EA=B0=80=20-=20#2=20#=20=EB=B0=94?= =?UTF-8?q?=EB=A1=9C=20=EC=95=84=EB=9E=98=20=EA=B3=B5=EB=B0=B1=EC=9D=80=20?= =?UTF-8?q?=EC=A0=9C=EB=AA=A9=EA=B3=BC=20=EB=B3=B8=EB=AC=B8=EC=9D=98=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC=EB=A5=BC=20=EC=9C=84=ED=95=A8=20############?= =?UTF-8?q?####=20#=20=EB=B3=B8=EB=AC=B8(=EA=B5=AC=EC=B2=B4=EC=A0=81?= =?UTF-8?q?=EC=9D=B8=20=EB=82=B4=EC=9A=A9)=EC=9D=84=20=EC=95=84=EB=9E=AB?= =?UTF-8?q?=EC=A4=84=EC=97=90=20=EC=9E=91=EC=84=B1=20#=20=EC=97=AC?= =?UTF-8?q?=EB=9F=AC=20=EC=A4=84=EC=9D=98=20=EB=A9=94=EC=8B=9C=EC=A7=80?= =?UTF-8?q?=EB=A5=BC=20=EC=9E=91=EC=84=B1=ED=95=A0=20=EB=95=90=20"-"?= =?UTF-8?q?=EB=A1=9C=20=EA=B5=AC=EB=B6=84=20(=ED=95=9C=20=EC=A4=84?= =?UTF-8?q?=EC=9D=80=2072=EC=9E=90=20=EC=9D=B4=EB=82=B4)=20###############?= =?UTF-8?q?#=20#feat=20#=EC=83=88=EB=A1=9C=EC=9A=B4=20=EA=B8=B0=EB=8A=A5?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80=20#=20#fix=20#=EB=B2=84=EA=B7=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20#=20#design=20#CSS=20=EB=93=B1=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=EC=9E=90=20UI=20=EB=94=94=EC=9E=90=EC=9D=B8=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20#=20#!BREAKING=20CHANGE=20#=EC=BB=A4?= =?UTF-8?q?=EB=8B=A4=EB=9E=80=20API=20=EB=B3=80=EA=B2=BD=EC=9D=98=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20#=20#!HOTFIX=20#=EA=B8=89=ED=95=98?= =?UTF-8?q?=EA=B2=8C=20=EC=B9=98=EB=AA=85=EC=A0=81=EC=9D=B8=20=EB=B2=84?= =?UTF-8?q?=EA=B7=B8=EB=A5=BC=20=EA=B3=A0=EC=B3=90=EC=95=BC=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20#=20#style=20#=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=ED=8F=AC=EB=A7=B7=20=EB=B3=80=EA=B2=BD,=20?= =?UTF-8?q?=EC=84=B8=EB=AF=B8=20=EC=BD=9C=EB=A1=A0=20=EB=88=84=EB=9D=BD,?= =?UTF-8?q?=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95=EC=9D=B4=20=EC=97=86?= =?UTF-8?q?=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20#=20#refactor=20#=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EB=8D=95=EC=85=98=20=EC=BD=94=EB=93=9C=20=EB=A6=AC?= =?UTF-8?q?=ED=8C=A9=ED=86=A0=EB=A7=81=20#=20#comment=20#=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EC=A3=BC=EC=84=9D=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20=EB=B3=80=EA=B2=BD=20#=20#docs=20#=EB=AC=B8?= =?UTF-8?q?=EC=84=9C=20=EC=88=98=EC=A0=95=20#=20#test=20#=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=B6=94=EA=B0=80,=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81(=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EB=8D=95=EC=85=98=20=EC=BD=94=EB=93=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20X)=20#=20#setting=20#=ED=8C=A8=ED=82=A4=EC=A7=80=20?= =?UTF-8?q?=EC=84=A4=EC=B9=98,=20=EA=B0=9C=EB=B0=9C=20=EC=84=A4=EC=A0=95?= =?UTF-8?q?=20#=20#chore=20#=EB=B9=8C=EB=93=9C=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8,=20=ED=8C=A8?= =?UTF-8?q?=ED=82=A4=EC=A7=80=20=EB=A7=A4=EB=8B=88=EC=A0=80=EB=A5=BC=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=ED=95=98=EB=8A=94=20=EA=B2=BD=EC=9A=B0(?= =?UTF-8?q?=ED=94=84=EB=A1=9C=EB=8D=95=EC=85=98=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20X)=20#=20#rename=20#=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=ED=98=B9=EC=9D=80=20=ED=8F=B4=EB=8D=94=EB=AA=85=EC=9D=84=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=ED=95=98=EA=B1=B0=EB=82=98=20=EC=98=AE?= =?UTF-8?q?=EA=B8=B0=EB=8A=94=20=EC=9E=91=EC=97=85=EB=A7=8C=EC=9D=B8=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20#=20#remove=20#=ED=8C=8C=EC=9D=BC=EC=9D=84?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C=ED=95=98=EB=8A=94=20=EC=9E=91=EC=97=85?= =?UTF-8?q?=EB=A7=8C=20=EC=88=98=ED=96=89=ED=95=9C=20=EA=B2=BD=EC=9A=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/dto/ErrorResponseDto.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/dto/ErrorResponseDto.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/ErrorResponseDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/ErrorResponseDto.java new file mode 100644 index 0000000..ffde7cc --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/ErrorResponseDto.java @@ -0,0 +1,25 @@ +package com.hackathonteam1.refreshrator.dto; + +import com.hackathonteam1.refreshrator.exception.CustomException; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@AllArgsConstructor +@Getter +public class ErrorResponseDto { + private final String errorCode; + private final String message; + private final String detail; + + public static ErrorResponseDto res(final CustomException customException){ + String errorCode = customException.getErrorCode().getCode(); + String message = customException.getErrorCode().getMessage(); + String detail = customException.getDetail(); + return new ErrorResponseDto(errorCode,message,detail); + } + + public static ErrorResponseDto res(final String errorCode, final Exception e){ + return new ErrorResponseDto(errorCode, e.getMessage(), null); + } + +} From b50269b39b74a625be7526987f02ce5e4b0dea97 Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 17 Jul 2024 22:11:40 +0900 Subject: [PATCH 023/212] =?UTF-8?q?feat:=20ResponseDto=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20-#7=20################=20#=20<=ED=83=80=EC=9E=85>:?= =?UTF-8?q?=20<=EC=A0=9C=EB=AA=A9>=20-=20<=EC=9D=B4=EC=8A=88=EB=B2=88?= =?UTF-8?q?=ED=98=B8>=20=EC=9D=98=20=ED=98=95=EC=8B=9D=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EC=A0=9C=EB=AA=A9=EC=9D=84=20=EC=95=84=EB=9E=98=20=EA=B3=B5?= =?UTF-8?q?=EB=B0=B1=EC=A4=84=EC=97=90=20=EC=9E=91=EC=84=B1=20#=20?= =?UTF-8?q?=EC=A0=9C=EB=AA=A9=EC=9D=80=2050=EC=9E=90=20=EC=9D=B4=EB=82=B4?= =?UTF-8?q?=20/=20=EB=B3=80=EA=B2=BD=EC=82=AC=ED=95=AD=EC=9D=B4=20"?= =?UTF-8?q?=EB=AC=B4=EC=97=87"=EC=9D=B8=EC=A7=80=20=EB=AA=85=ED=99=95?= =?UTF-8?q?=ED=9E=88=20=EC=9E=91=EC=84=B1=20/=20=EB=81=9D=EC=97=90=20?= =?UTF-8?q?=EB=A7=88=EC=B9=A8=ED=91=9C=20=EA=B8=88=EC=A7=80=20#=20?= =?UTF-8?q?=EC=98=88)=20feat:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=B6=94=EA=B0=80=20-=20#2=20#=20=EB=B0=94?= =?UTF-8?q?=EB=A1=9C=20=EC=95=84=EB=9E=98=20=EA=B3=B5=EB=B0=B1=EC=9D=80=20?= =?UTF-8?q?=EC=A0=9C=EB=AA=A9=EA=B3=BC=20=EB=B3=B8=EB=AC=B8=EC=9D=98=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC=EB=A5=BC=20=EC=9C=84=ED=95=A8=20############?= =?UTF-8?q?####=20#=20=EB=B3=B8=EB=AC=B8(=EA=B5=AC=EC=B2=B4=EC=A0=81?= =?UTF-8?q?=EC=9D=B8=20=EB=82=B4=EC=9A=A9)=EC=9D=84=20=EC=95=84=EB=9E=AB?= =?UTF-8?q?=EC=A4=84=EC=97=90=20=EC=9E=91=EC=84=B1=20#=20=EC=97=AC?= =?UTF-8?q?=EB=9F=AC=20=EC=A4=84=EC=9D=98=20=EB=A9=94=EC=8B=9C=EC=A7=80?= =?UTF-8?q?=EB=A5=BC=20=EC=9E=91=EC=84=B1=ED=95=A0=20=EB=95=90=20"-"?= =?UTF-8?q?=EB=A1=9C=20=EA=B5=AC=EB=B6=84=20(=ED=95=9C=20=EC=A4=84?= =?UTF-8?q?=EC=9D=80=2072=EC=9E=90=20=EC=9D=B4=EB=82=B4)=20###############?= =?UTF-8?q?#=20#feat=20#=EC=83=88=EB=A1=9C=EC=9A=B4=20=EA=B8=B0=EB=8A=A5?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80=20#=20#fix=20#=EB=B2=84=EA=B7=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20#=20#design=20#CSS=20=EB=93=B1=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=EC=9E=90=20UI=20=EB=94=94=EC=9E=90=EC=9D=B8=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20#=20#!BREAKING=20CHANGE=20#=EC=BB=A4?= =?UTF-8?q?=EB=8B=A4=EB=9E=80=20API=20=EB=B3=80=EA=B2=BD=EC=9D=98=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20#=20#!HOTFIX=20#=EA=B8=89=ED=95=98?= =?UTF-8?q?=EA=B2=8C=20=EC=B9=98=EB=AA=85=EC=A0=81=EC=9D=B8=20=EB=B2=84?= =?UTF-8?q?=EA=B7=B8=EB=A5=BC=20=EA=B3=A0=EC=B3=90=EC=95=BC=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20#=20#style=20#=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=ED=8F=AC=EB=A7=B7=20=EB=B3=80=EA=B2=BD,=20?= =?UTF-8?q?=EC=84=B8=EB=AF=B8=20=EC=BD=9C=EB=A1=A0=20=EB=88=84=EB=9D=BD,?= =?UTF-8?q?=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95=EC=9D=B4=20=EC=97=86?= =?UTF-8?q?=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20#=20#refactor=20#=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EB=8D=95=EC=85=98=20=EC=BD=94=EB=93=9C=20=EB=A6=AC?= =?UTF-8?q?=ED=8C=A9=ED=86=A0=EB=A7=81=20#=20#comment=20#=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EC=A3=BC=EC=84=9D=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20=EB=B3=80=EA=B2=BD=20#=20#docs=20#=EB=AC=B8?= =?UTF-8?q?=EC=84=9C=20=EC=88=98=EC=A0=95=20#=20#test=20#=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=B6=94=EA=B0=80,=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81(=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EB=8D=95=EC=85=98=20=EC=BD=94=EB=93=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20X)=20#=20#setting=20#=ED=8C=A8=ED=82=A4=EC=A7=80=20?= =?UTF-8?q?=EC=84=A4=EC=B9=98,=20=EA=B0=9C=EB=B0=9C=20=EC=84=A4=EC=A0=95?= =?UTF-8?q?=20#=20#chore=20#=EB=B9=8C=EB=93=9C=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8,=20=ED=8C=A8?= =?UTF-8?q?=ED=82=A4=EC=A7=80=20=EB=A7=A4=EB=8B=88=EC=A0=80=EB=A5=BC=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=ED=95=98=EB=8A=94=20=EA=B2=BD=EC=9A=B0(?= =?UTF-8?q?=ED=94=84=EB=A1=9C=EB=8D=95=EC=85=98=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20X)=20#=20#rename=20#=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=ED=98=B9=EC=9D=80=20=ED=8F=B4=EB=8D=94=EB=AA=85=EC=9D=84=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=ED=95=98=EA=B1=B0=EB=82=98=20=EC=98=AE?= =?UTF-8?q?=EA=B8=B0=EB=8A=94=20=EC=9E=91=EC=97=85=EB=A7=8C=EC=9D=B8=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20#=20#remove=20#=ED=8C=8C=EC=9D=BC=EC=9D=84?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C=ED=95=98=EB=8A=94=20=EC=9E=91=EC=97=85?= =?UTF-8?q?=EB=A7=8C=20=EC=88=98=ED=96=89=ED=95=9C=20=EA=B2=BD=EC=9A=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/dto/ResponseDto.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/dto/ResponseDto.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/ResponseDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/ResponseDto.java new file mode 100644 index 0000000..771f43e --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/ResponseDto.java @@ -0,0 +1,22 @@ +package com.hackathonteam1.refreshrator.dto; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.springframework.http.HttpStatus; +import org.springframework.http.HttpStatusCode; + +@AllArgsConstructor +@Getter +public class ResponseDto { + private final String statusCode; + private final String message; + private final T data; + + public static ResponseDto res(final HttpStatusCode statusCode, final String message){ + return new ResponseDto<>(String.valueOf(statusCode.value()), message, null); + } + + public static ResponseDto res(final HttpStatusCode statusCode, final String message, final T data){ + return new ResponseDto<>(String.valueOf(statusCode.value()), message, data); + } +} From 87596b1d04e086968a4bd1405a245c06f3d1c06f Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 17 Jul 2024 22:11:54 +0900 Subject: [PATCH 024/212] =?UTF-8?q?feat:=20CustomException=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20-#7=20################=20#=20<=ED=83=80=EC=9E=85>:?= =?UTF-8?q?=20<=EC=A0=9C=EB=AA=A9>=20-=20<=EC=9D=B4=EC=8A=88=EB=B2=88?= =?UTF-8?q?=ED=98=B8>=20=EC=9D=98=20=ED=98=95=EC=8B=9D=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EC=A0=9C=EB=AA=A9=EC=9D=84=20=EC=95=84=EB=9E=98=20=EA=B3=B5?= =?UTF-8?q?=EB=B0=B1=EC=A4=84=EC=97=90=20=EC=9E=91=EC=84=B1=20#=20?= =?UTF-8?q?=EC=A0=9C=EB=AA=A9=EC=9D=80=2050=EC=9E=90=20=EC=9D=B4=EB=82=B4?= =?UTF-8?q?=20/=20=EB=B3=80=EA=B2=BD=EC=82=AC=ED=95=AD=EC=9D=B4=20"?= =?UTF-8?q?=EB=AC=B4=EC=97=87"=EC=9D=B8=EC=A7=80=20=EB=AA=85=ED=99=95?= =?UTF-8?q?=ED=9E=88=20=EC=9E=91=EC=84=B1=20/=20=EB=81=9D=EC=97=90=20?= =?UTF-8?q?=EB=A7=88=EC=B9=A8=ED=91=9C=20=EA=B8=88=EC=A7=80=20#=20?= =?UTF-8?q?=EC=98=88)=20feat:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=B6=94=EA=B0=80=20-=20#2=20#=20=EB=B0=94?= =?UTF-8?q?=EB=A1=9C=20=EC=95=84=EB=9E=98=20=EA=B3=B5=EB=B0=B1=EC=9D=80=20?= =?UTF-8?q?=EC=A0=9C=EB=AA=A9=EA=B3=BC=20=EB=B3=B8=EB=AC=B8=EC=9D=98=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC=EB=A5=BC=20=EC=9C=84=ED=95=A8=20############?= =?UTF-8?q?####=20#=20=EB=B3=B8=EB=AC=B8(=EA=B5=AC=EC=B2=B4=EC=A0=81?= =?UTF-8?q?=EC=9D=B8=20=EB=82=B4=EC=9A=A9)=EC=9D=84=20=EC=95=84=EB=9E=AB?= =?UTF-8?q?=EC=A4=84=EC=97=90=20=EC=9E=91=EC=84=B1=20#=20=EC=97=AC?= =?UTF-8?q?=EB=9F=AC=20=EC=A4=84=EC=9D=98=20=EB=A9=94=EC=8B=9C=EC=A7=80?= =?UTF-8?q?=EB=A5=BC=20=EC=9E=91=EC=84=B1=ED=95=A0=20=EB=95=90=20"-"?= =?UTF-8?q?=EB=A1=9C=20=EA=B5=AC=EB=B6=84=20(=ED=95=9C=20=EC=A4=84?= =?UTF-8?q?=EC=9D=80=2072=EC=9E=90=20=EC=9D=B4=EB=82=B4)=20###############?= =?UTF-8?q?#=20#feat=20#=EC=83=88=EB=A1=9C=EC=9A=B4=20=EA=B8=B0=EB=8A=A5?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80=20#=20#fix=20#=EB=B2=84=EA=B7=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20#=20#design=20#CSS=20=EB=93=B1=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=EC=9E=90=20UI=20=EB=94=94=EC=9E=90=EC=9D=B8=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20#=20#!BREAKING=20CHANGE=20#=EC=BB=A4?= =?UTF-8?q?=EB=8B=A4=EB=9E=80=20API=20=EB=B3=80=EA=B2=BD=EC=9D=98=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20#=20#!HOTFIX=20#=EA=B8=89=ED=95=98?= =?UTF-8?q?=EA=B2=8C=20=EC=B9=98=EB=AA=85=EC=A0=81=EC=9D=B8=20=EB=B2=84?= =?UTF-8?q?=EA=B7=B8=EB=A5=BC=20=EA=B3=A0=EC=B3=90=EC=95=BC=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20#=20#style=20#=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=ED=8F=AC=EB=A7=B7=20=EB=B3=80=EA=B2=BD,=20?= =?UTF-8?q?=EC=84=B8=EB=AF=B8=20=EC=BD=9C=EB=A1=A0=20=EB=88=84=EB=9D=BD,?= =?UTF-8?q?=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95=EC=9D=B4=20=EC=97=86?= =?UTF-8?q?=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20#=20#refactor=20#=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EB=8D=95=EC=85=98=20=EC=BD=94=EB=93=9C=20=EB=A6=AC?= =?UTF-8?q?=ED=8C=A9=ED=86=A0=EB=A7=81=20#=20#comment=20#=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EC=A3=BC=EC=84=9D=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20=EB=B3=80=EA=B2=BD=20#=20#docs=20#=EB=AC=B8?= =?UTF-8?q?=EC=84=9C=20=EC=88=98=EC=A0=95=20#=20#test=20#=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=B6=94=EA=B0=80,=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81(=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EB=8D=95=EC=85=98=20=EC=BD=94=EB=93=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20X)=20#=20#setting=20#=ED=8C=A8=ED=82=A4=EC=A7=80=20?= =?UTF-8?q?=EC=84=A4=EC=B9=98,=20=EA=B0=9C=EB=B0=9C=20=EC=84=A4=EC=A0=95?= =?UTF-8?q?=20#=20#chore=20#=EB=B9=8C=EB=93=9C=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8,=20=ED=8C=A8?= =?UTF-8?q?=ED=82=A4=EC=A7=80=20=EB=A7=A4=EB=8B=88=EC=A0=80=EB=A5=BC=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=ED=95=98=EB=8A=94=20=EA=B2=BD=EC=9A=B0(?= =?UTF-8?q?=ED=94=84=EB=A1=9C=EB=8D=95=EC=85=98=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20X)=20#=20#rename=20#=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=ED=98=B9=EC=9D=80=20=ED=8F=B4=EB=8D=94=EB=AA=85=EC=9D=84=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=ED=95=98=EA=B1=B0=EB=82=98=20=EC=98=AE?= =?UTF-8?q?=EA=B8=B0=EB=8A=94=20=EC=9E=91=EC=97=85=EB=A7=8C=EC=9D=B8=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20#=20#remove=20#=ED=8C=8C=EC=9D=BC=EC=9D=84?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C=ED=95=98=EB=8A=94=20=EC=9E=91=EC=97=85?= =?UTF-8?q?=EB=A7=8C=20=EC=88=98=ED=96=89=ED=95=9C=20=EA=B2=BD=EC=9A=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/CustomException.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/exception/CustomException.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/exception/CustomException.java b/src/main/java/com/hackathonteam1/refreshrator/exception/CustomException.java new file mode 100644 index 0000000..b0d1dac --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/exception/CustomException.java @@ -0,0 +1,23 @@ +package com.hackathonteam1.refreshrator.exception; + +import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +public class CustomException extends RuntimeException{ + + private final ErrorCode errorCode; + private final String detail; + + public CustomException(ErrorCode errorCode){ + this.errorCode = errorCode; + this.detail = null; + } + + public CustomException(ErrorCode errorCode, String detail){ + this.errorCode = errorCode; + this.detail = detail; + } + +} From f4e481e00f806dfa8725dbbb874b5c4382a12ff6 Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 17 Jul 2024 22:12:13 +0900 Subject: [PATCH 025/212] =?UTF-8?q?feat:=20ExceptionController=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20-#7=20################=20#=20<=ED=83=80=EC=9E=85>:?= =?UTF-8?q?=20<=EC=A0=9C=EB=AA=A9>=20-=20<=EC=9D=B4=EC=8A=88=EB=B2=88?= =?UTF-8?q?=ED=98=B8>=20=EC=9D=98=20=ED=98=95=EC=8B=9D=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EC=A0=9C=EB=AA=A9=EC=9D=84=20=EC=95=84=EB=9E=98=20=EA=B3=B5?= =?UTF-8?q?=EB=B0=B1=EC=A4=84=EC=97=90=20=EC=9E=91=EC=84=B1=20#=20?= =?UTF-8?q?=EC=A0=9C=EB=AA=A9=EC=9D=80=2050=EC=9E=90=20=EC=9D=B4=EB=82=B4?= =?UTF-8?q?=20/=20=EB=B3=80=EA=B2=BD=EC=82=AC=ED=95=AD=EC=9D=B4=20"?= =?UTF-8?q?=EB=AC=B4=EC=97=87"=EC=9D=B8=EC=A7=80=20=EB=AA=85=ED=99=95?= =?UTF-8?q?=ED=9E=88=20=EC=9E=91=EC=84=B1=20/=20=EB=81=9D=EC=97=90=20?= =?UTF-8?q?=EB=A7=88=EC=B9=A8=ED=91=9C=20=EA=B8=88=EC=A7=80=20#=20?= =?UTF-8?q?=EC=98=88)=20feat:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=B6=94=EA=B0=80=20-=20#2=20#=20=EB=B0=94?= =?UTF-8?q?=EB=A1=9C=20=EC=95=84=EB=9E=98=20=EA=B3=B5=EB=B0=B1=EC=9D=80=20?= =?UTF-8?q?=EC=A0=9C=EB=AA=A9=EA=B3=BC=20=EB=B3=B8=EB=AC=B8=EC=9D=98=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC=EB=A5=BC=20=EC=9C=84=ED=95=A8=20############?= =?UTF-8?q?####=20#=20=EB=B3=B8=EB=AC=B8(=EA=B5=AC=EC=B2=B4=EC=A0=81?= =?UTF-8?q?=EC=9D=B8=20=EB=82=B4=EC=9A=A9)=EC=9D=84=20=EC=95=84=EB=9E=AB?= =?UTF-8?q?=EC=A4=84=EC=97=90=20=EC=9E=91=EC=84=B1=20#=20=EC=97=AC?= =?UTF-8?q?=EB=9F=AC=20=EC=A4=84=EC=9D=98=20=EB=A9=94=EC=8B=9C=EC=A7=80?= =?UTF-8?q?=EB=A5=BC=20=EC=9E=91=EC=84=B1=ED=95=A0=20=EB=95=90=20"-"?= =?UTF-8?q?=EB=A1=9C=20=EA=B5=AC=EB=B6=84=20(=ED=95=9C=20=EC=A4=84?= =?UTF-8?q?=EC=9D=80=2072=EC=9E=90=20=EC=9D=B4=EB=82=B4)=20###############?= =?UTF-8?q?#=20#feat=20#=EC=83=88=EB=A1=9C=EC=9A=B4=20=EA=B8=B0=EB=8A=A5?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80=20#=20#fix=20#=EB=B2=84=EA=B7=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20#=20#design=20#CSS=20=EB=93=B1=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=EC=9E=90=20UI=20=EB=94=94=EC=9E=90=EC=9D=B8=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20#=20#!BREAKING=20CHANGE=20#=EC=BB=A4?= =?UTF-8?q?=EB=8B=A4=EB=9E=80=20API=20=EB=B3=80=EA=B2=BD=EC=9D=98=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20#=20#!HOTFIX=20#=EA=B8=89=ED=95=98?= =?UTF-8?q?=EA=B2=8C=20=EC=B9=98=EB=AA=85=EC=A0=81=EC=9D=B8=20=EB=B2=84?= =?UTF-8?q?=EA=B7=B8=EB=A5=BC=20=EA=B3=A0=EC=B3=90=EC=95=BC=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20#=20#style=20#=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=ED=8F=AC=EB=A7=B7=20=EB=B3=80=EA=B2=BD,=20?= =?UTF-8?q?=EC=84=B8=EB=AF=B8=20=EC=BD=9C=EB=A1=A0=20=EB=88=84=EB=9D=BD,?= =?UTF-8?q?=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95=EC=9D=B4=20=EC=97=86?= =?UTF-8?q?=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20#=20#refactor=20#=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EB=8D=95=EC=85=98=20=EC=BD=94=EB=93=9C=20=EB=A6=AC?= =?UTF-8?q?=ED=8C=A9=ED=86=A0=EB=A7=81=20#=20#comment=20#=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EC=A3=BC=EC=84=9D=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20=EB=B3=80=EA=B2=BD=20#=20#docs=20#=EB=AC=B8?= =?UTF-8?q?=EC=84=9C=20=EC=88=98=EC=A0=95=20#=20#test=20#=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=B6=94=EA=B0=80,=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81(=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EB=8D=95=EC=85=98=20=EC=BD=94=EB=93=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20X)=20#=20#setting=20#=ED=8C=A8=ED=82=A4=EC=A7=80=20?= =?UTF-8?q?=EC=84=A4=EC=B9=98,=20=EA=B0=9C=EB=B0=9C=20=EC=84=A4=EC=A0=95?= =?UTF-8?q?=20#=20#chore=20#=EB=B9=8C=EB=93=9C=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8,=20=ED=8C=A8?= =?UTF-8?q?=ED=82=A4=EC=A7=80=20=EB=A7=A4=EB=8B=88=EC=A0=80=EB=A5=BC=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=ED=95=98=EB=8A=94=20=EA=B2=BD=EC=9A=B0(?= =?UTF-8?q?=ED=94=84=EB=A1=9C=EB=8D=95=EC=85=98=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20X)=20#=20#rename=20#=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=ED=98=B9=EC=9D=80=20=ED=8F=B4=EB=8D=94=EB=AA=85=EC=9D=84=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=ED=95=98=EA=B1=B0=EB=82=98=20=EC=98=AE?= =?UTF-8?q?=EA=B8=B0=EB=8A=94=20=EC=9E=91=EC=97=85=EB=A7=8C=EC=9D=B8=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20#=20#remove=20#=ED=8C=8C=EC=9D=BC=EC=9D=84?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C=ED=95=98=EB=8A=94=20=EC=9E=91=EC=97=85?= =?UTF-8?q?=EB=A7=8C=20=EC=88=98=ED=96=89=ED=95=9C=20=EA=B2=BD=EC=9A=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/advice/ExceptionController.java | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/exception/advice/ExceptionController.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/exception/advice/ExceptionController.java b/src/main/java/com/hackathonteam1/refreshrator/exception/advice/ExceptionController.java new file mode 100644 index 0000000..5f17161 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/exception/advice/ExceptionController.java @@ -0,0 +1,65 @@ +package com.hackathonteam1.refreshrator.exception.advice; + +import com.hackathonteam1.refreshrator.dto.ErrorResponseDto; +import com.hackathonteam1.refreshrator.exception.CustomException; +import com.hackathonteam1.refreshrator.exception.DtoValidationException; +import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; +import jakarta.persistence.EntityNotFoundException; +import jakarta.validation.ValidationException; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.jdbc.support.MetaDataAccessException; +import org.springframework.validation.FieldError; +import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +@Slf4j +@RestControllerAdvice +public class ExceptionController { + + @ExceptionHandler(CustomException.class) + public ResponseEntity handleCustomException(CustomException customException){ + writeLog(customException); + HttpStatus httpStatus = this.resolveHttpStatus(customException); + return new ResponseEntity<>(ErrorResponseDto.res(customException), httpStatus); + } + + @ExceptionHandler({ValidationException.class, MetaDataAccessException.class}) + public ResponseEntity handleCustomException(MethodArgumentNotValidException methodArgumentNotValidException){ + FieldError fieldError = methodArgumentNotValidException.getBindingResult().getFieldError(); + if(fieldError == null){ + return new ResponseEntity<>(ErrorResponseDto.res(String.valueOf(HttpStatus.BAD_REQUEST.value()), + methodArgumentNotValidException), HttpStatus.BAD_REQUEST); + } + ErrorCode validationErrorCode = ErrorCode.resolveValidationErrorCode(fieldError.getCode()); + String detail = fieldError.getDefaultMessage(); + DtoValidationException dtoValidationException = new DtoValidationException(validationErrorCode, detail); + this.writeLog(dtoValidationException); + return new ResponseEntity<>(ErrorResponseDto.res(dtoValidationException),HttpStatus.BAD_REQUEST); + } + + @ExceptionHandler(EntityNotFoundException.class) + public ResponseEntity handleEntityNotFoundException(EntityNotFoundException entityNotFoundException){ + writeLog(entityNotFoundException); + return new ResponseEntity<>(ErrorResponseDto.res(String.valueOf(HttpStatus.NOT_FOUND.value()),entityNotFoundException), HttpStatus.NOT_FOUND); + } + + private void writeLog(CustomException customException){ + String exceptionName = customException.getClass().getSimpleName(); + ErrorCode errorCode = customException.getErrorCode(); + String detail = customException.getDetail(); + log.error("[{}]{}:{}", exceptionName,errorCode.getMessage(), detail); + } + + private void writeLog(Exception exception){ + String exceptionName = exception.getClass().getSimpleName(); + String message = exception.getMessage(); + log.error("[{}]:{}", exceptionName, message); + } + + private HttpStatus resolveHttpStatus(CustomException customException){ + return HttpStatus.resolve(Integer.parseInt(customException.getErrorCode().getCode().substring(0,3))); + } +} From 0ea9bcfb79296afaae821eac3c24462e8cb080ea Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 17 Jul 2024 22:12:27 +0900 Subject: [PATCH 026/212] =?UTF-8?q?feat:=20ConflictException=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20-#7=20################=20#=20<=ED=83=80=EC=9E=85>:?= =?UTF-8?q?=20<=EC=A0=9C=EB=AA=A9>=20-=20<=EC=9D=B4=EC=8A=88=EB=B2=88?= =?UTF-8?q?=ED=98=B8>=20=EC=9D=98=20=ED=98=95=EC=8B=9D=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EC=A0=9C=EB=AA=A9=EC=9D=84=20=EC=95=84=EB=9E=98=20=EA=B3=B5?= =?UTF-8?q?=EB=B0=B1=EC=A4=84=EC=97=90=20=EC=9E=91=EC=84=B1=20#=20?= =?UTF-8?q?=EC=A0=9C=EB=AA=A9=EC=9D=80=2050=EC=9E=90=20=EC=9D=B4=EB=82=B4?= =?UTF-8?q?=20/=20=EB=B3=80=EA=B2=BD=EC=82=AC=ED=95=AD=EC=9D=B4=20"?= =?UTF-8?q?=EB=AC=B4=EC=97=87"=EC=9D=B8=EC=A7=80=20=EB=AA=85=ED=99=95?= =?UTF-8?q?=ED=9E=88=20=EC=9E=91=EC=84=B1=20/=20=EB=81=9D=EC=97=90=20?= =?UTF-8?q?=EB=A7=88=EC=B9=A8=ED=91=9C=20=EA=B8=88=EC=A7=80=20#=20?= =?UTF-8?q?=EC=98=88)=20feat:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=B6=94=EA=B0=80=20-=20#2=20#=20=EB=B0=94?= =?UTF-8?q?=EB=A1=9C=20=EC=95=84=EB=9E=98=20=EA=B3=B5=EB=B0=B1=EC=9D=80=20?= =?UTF-8?q?=EC=A0=9C=EB=AA=A9=EA=B3=BC=20=EB=B3=B8=EB=AC=B8=EC=9D=98=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC=EB=A5=BC=20=EC=9C=84=ED=95=A8=20############?= =?UTF-8?q?####=20#=20=EB=B3=B8=EB=AC=B8(=EA=B5=AC=EC=B2=B4=EC=A0=81?= =?UTF-8?q?=EC=9D=B8=20=EB=82=B4=EC=9A=A9)=EC=9D=84=20=EC=95=84=EB=9E=AB?= =?UTF-8?q?=EC=A4=84=EC=97=90=20=EC=9E=91=EC=84=B1=20#=20=EC=97=AC?= =?UTF-8?q?=EB=9F=AC=20=EC=A4=84=EC=9D=98=20=EB=A9=94=EC=8B=9C=EC=A7=80?= =?UTF-8?q?=EB=A5=BC=20=EC=9E=91=EC=84=B1=ED=95=A0=20=EB=95=90=20"-"?= =?UTF-8?q?=EB=A1=9C=20=EA=B5=AC=EB=B6=84=20(=ED=95=9C=20=EC=A4=84?= =?UTF-8?q?=EC=9D=80=2072=EC=9E=90=20=EC=9D=B4=EB=82=B4)=20###############?= =?UTF-8?q?#=20#feat=20#=EC=83=88=EB=A1=9C=EC=9A=B4=20=EA=B8=B0=EB=8A=A5?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80=20#=20#fix=20#=EB=B2=84=EA=B7=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20#=20#design=20#CSS=20=EB=93=B1=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=EC=9E=90=20UI=20=EB=94=94=EC=9E=90=EC=9D=B8=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20#=20#!BREAKING=20CHANGE=20#=EC=BB=A4?= =?UTF-8?q?=EB=8B=A4=EB=9E=80=20API=20=EB=B3=80=EA=B2=BD=EC=9D=98=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20#=20#!HOTFIX=20#=EA=B8=89=ED=95=98?= =?UTF-8?q?=EA=B2=8C=20=EC=B9=98=EB=AA=85=EC=A0=81=EC=9D=B8=20=EB=B2=84?= =?UTF-8?q?=EA=B7=B8=EB=A5=BC=20=EA=B3=A0=EC=B3=90=EC=95=BC=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20#=20#style=20#=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=ED=8F=AC=EB=A7=B7=20=EB=B3=80=EA=B2=BD,=20?= =?UTF-8?q?=EC=84=B8=EB=AF=B8=20=EC=BD=9C=EB=A1=A0=20=EB=88=84=EB=9D=BD,?= =?UTF-8?q?=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95=EC=9D=B4=20=EC=97=86?= =?UTF-8?q?=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20#=20#refactor=20#=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EB=8D=95=EC=85=98=20=EC=BD=94=EB=93=9C=20=EB=A6=AC?= =?UTF-8?q?=ED=8C=A9=ED=86=A0=EB=A7=81=20#=20#comment=20#=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EC=A3=BC=EC=84=9D=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20=EB=B3=80=EA=B2=BD=20#=20#docs=20#=EB=AC=B8?= =?UTF-8?q?=EC=84=9C=20=EC=88=98=EC=A0=95=20#=20#test=20#=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=B6=94=EA=B0=80,=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81(=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EB=8D=95=EC=85=98=20=EC=BD=94=EB=93=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20X)=20#=20#setting=20#=ED=8C=A8=ED=82=A4=EC=A7=80=20?= =?UTF-8?q?=EC=84=A4=EC=B9=98,=20=EA=B0=9C=EB=B0=9C=20=EC=84=A4=EC=A0=95?= =?UTF-8?q?=20#=20#chore=20#=EB=B9=8C=EB=93=9C=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8,=20=ED=8C=A8?= =?UTF-8?q?=ED=82=A4=EC=A7=80=20=EB=A7=A4=EB=8B=88=EC=A0=80=EB=A5=BC=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=ED=95=98=EB=8A=94=20=EA=B2=BD=EC=9A=B0(?= =?UTF-8?q?=ED=94=84=EB=A1=9C=EB=8D=95=EC=85=98=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20X)=20#=20#rename=20#=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=ED=98=B9=EC=9D=80=20=ED=8F=B4=EB=8D=94=EB=AA=85=EC=9D=84=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=ED=95=98=EA=B1=B0=EB=82=98=20=EC=98=AE?= =?UTF-8?q?=EA=B8=B0=EB=8A=94=20=EC=9E=91=EC=97=85=EB=A7=8C=EC=9D=B8=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20#=20#remove=20#=ED=8C=8C=EC=9D=BC=EC=9D=84?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C=ED=95=98=EB=8A=94=20=EC=9E=91=EC=97=85?= =?UTF-8?q?=EB=A7=8C=20=EC=88=98=ED=96=89=ED=95=9C=20=EA=B2=BD=EC=9A=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/exception/ConflictException.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/exception/ConflictException.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/exception/ConflictException.java b/src/main/java/com/hackathonteam1/refreshrator/exception/ConflictException.java new file mode 100644 index 0000000..5d09a58 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/exception/ConflictException.java @@ -0,0 +1,13 @@ +package com.hackathonteam1.refreshrator.exception; + +import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; + +public class ConflictException extends CustomException{ + public ConflictException(ErrorCode errorCode) { + super(errorCode); + } + + public ConflictException(ErrorCode errorCode, String detail) { + super(errorCode, detail); + } +} From b482c4b1bad1e499c61c6e3469352dbaf6373efe Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 17 Jul 2024 22:12:34 +0900 Subject: [PATCH 027/212] =?UTF-8?q?feat:=20DtoValidationException=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20-#7=20################=20#=20<=ED=83=80?= =?UTF-8?q?=EC=9E=85>:=20<=EC=A0=9C=EB=AA=A9>=20-=20<=EC=9D=B4=EC=8A=88?= =?UTF-8?q?=EB=B2=88=ED=98=B8>=20=EC=9D=98=20=ED=98=95=EC=8B=9D=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EC=A0=9C=EB=AA=A9=EC=9D=84=20=EC=95=84=EB=9E=98=20?= =?UTF-8?q?=EA=B3=B5=EB=B0=B1=EC=A4=84=EC=97=90=20=EC=9E=91=EC=84=B1=20#?= =?UTF-8?q?=20=EC=A0=9C=EB=AA=A9=EC=9D=80=2050=EC=9E=90=20=EC=9D=B4?= =?UTF-8?q?=EB=82=B4=20/=20=EB=B3=80=EA=B2=BD=EC=82=AC=ED=95=AD=EC=9D=B4?= =?UTF-8?q?=20"=EB=AC=B4=EC=97=87"=EC=9D=B8=EC=A7=80=20=EB=AA=85=ED=99=95?= =?UTF-8?q?=ED=9E=88=20=EC=9E=91=EC=84=B1=20/=20=EB=81=9D=EC=97=90=20?= =?UTF-8?q?=EB=A7=88=EC=B9=A8=ED=91=9C=20=EA=B8=88=EC=A7=80=20#=20?= =?UTF-8?q?=EC=98=88)=20feat:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=B6=94=EA=B0=80=20-=20#2=20#=20=EB=B0=94?= =?UTF-8?q?=EB=A1=9C=20=EC=95=84=EB=9E=98=20=EA=B3=B5=EB=B0=B1=EC=9D=80=20?= =?UTF-8?q?=EC=A0=9C=EB=AA=A9=EA=B3=BC=20=EB=B3=B8=EB=AC=B8=EC=9D=98=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC=EB=A5=BC=20=EC=9C=84=ED=95=A8=20############?= =?UTF-8?q?####=20#=20=EB=B3=B8=EB=AC=B8(=EA=B5=AC=EC=B2=B4=EC=A0=81?= =?UTF-8?q?=EC=9D=B8=20=EB=82=B4=EC=9A=A9)=EC=9D=84=20=EC=95=84=EB=9E=AB?= =?UTF-8?q?=EC=A4=84=EC=97=90=20=EC=9E=91=EC=84=B1=20#=20=EC=97=AC?= =?UTF-8?q?=EB=9F=AC=20=EC=A4=84=EC=9D=98=20=EB=A9=94=EC=8B=9C=EC=A7=80?= =?UTF-8?q?=EB=A5=BC=20=EC=9E=91=EC=84=B1=ED=95=A0=20=EB=95=90=20"-"?= =?UTF-8?q?=EB=A1=9C=20=EA=B5=AC=EB=B6=84=20(=ED=95=9C=20=EC=A4=84?= =?UTF-8?q?=EC=9D=80=2072=EC=9E=90=20=EC=9D=B4=EB=82=B4)=20###############?= =?UTF-8?q?#=20#feat=20#=EC=83=88=EB=A1=9C=EC=9A=B4=20=EA=B8=B0=EB=8A=A5?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80=20#=20#fix=20#=EB=B2=84=EA=B7=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20#=20#design=20#CSS=20=EB=93=B1=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=EC=9E=90=20UI=20=EB=94=94=EC=9E=90=EC=9D=B8=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20#=20#!BREAKING=20CHANGE=20#=EC=BB=A4?= =?UTF-8?q?=EB=8B=A4=EB=9E=80=20API=20=EB=B3=80=EA=B2=BD=EC=9D=98=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20#=20#!HOTFIX=20#=EA=B8=89=ED=95=98?= =?UTF-8?q?=EA=B2=8C=20=EC=B9=98=EB=AA=85=EC=A0=81=EC=9D=B8=20=EB=B2=84?= =?UTF-8?q?=EA=B7=B8=EB=A5=BC=20=EA=B3=A0=EC=B3=90=EC=95=BC=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20#=20#style=20#=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=ED=8F=AC=EB=A7=B7=20=EB=B3=80=EA=B2=BD,=20?= =?UTF-8?q?=EC=84=B8=EB=AF=B8=20=EC=BD=9C=EB=A1=A0=20=EB=88=84=EB=9D=BD,?= =?UTF-8?q?=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95=EC=9D=B4=20=EC=97=86?= =?UTF-8?q?=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20#=20#refactor=20#=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EB=8D=95=EC=85=98=20=EC=BD=94=EB=93=9C=20=EB=A6=AC?= =?UTF-8?q?=ED=8C=A9=ED=86=A0=EB=A7=81=20#=20#comment=20#=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EC=A3=BC=EC=84=9D=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20=EB=B3=80=EA=B2=BD=20#=20#docs=20#=EB=AC=B8?= =?UTF-8?q?=EC=84=9C=20=EC=88=98=EC=A0=95=20#=20#test=20#=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=B6=94=EA=B0=80,=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81(=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EB=8D=95=EC=85=98=20=EC=BD=94=EB=93=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20X)=20#=20#setting=20#=ED=8C=A8=ED=82=A4=EC=A7=80=20?= =?UTF-8?q?=EC=84=A4=EC=B9=98,=20=EA=B0=9C=EB=B0=9C=20=EC=84=A4=EC=A0=95?= =?UTF-8?q?=20#=20#chore=20#=EB=B9=8C=EB=93=9C=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8,=20=ED=8C=A8?= =?UTF-8?q?=ED=82=A4=EC=A7=80=20=EB=A7=A4=EB=8B=88=EC=A0=80=EB=A5=BC=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=ED=95=98=EB=8A=94=20=EA=B2=BD=EC=9A=B0(?= =?UTF-8?q?=ED=94=84=EB=A1=9C=EB=8D=95=EC=85=98=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20X)=20#=20#rename=20#=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=ED=98=B9=EC=9D=80=20=ED=8F=B4=EB=8D=94=EB=AA=85=EC=9D=84=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=ED=95=98=EA=B1=B0=EB=82=98=20=EC=98=AE?= =?UTF-8?q?=EA=B8=B0=EB=8A=94=20=EC=9E=91=EC=97=85=EB=A7=8C=EC=9D=B8=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20#=20#remove=20#=ED=8C=8C=EC=9D=BC=EC=9D=84?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C=ED=95=98=EB=8A=94=20=EC=9E=91=EC=97=85?= =?UTF-8?q?=EB=A7=8C=20=EC=88=98=ED=96=89=ED=95=9C=20=EA=B2=BD=EC=9A=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/DtoValidationException.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/exception/DtoValidationException.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/exception/DtoValidationException.java b/src/main/java/com/hackathonteam1/refreshrator/exception/DtoValidationException.java new file mode 100644 index 0000000..f4f5bd3 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/exception/DtoValidationException.java @@ -0,0 +1,13 @@ +package com.hackathonteam1.refreshrator.exception; + +import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; + +public class DtoValidationException extends CustomException{ + public DtoValidationException(ErrorCode errorCode) { + super(errorCode); + } + + public DtoValidationException(ErrorCode errorCode, String detail) { + super(errorCode, detail); + } +} From febe8ab82c0e7c6f37e5aaf297c9cc64fa34db47 Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 17 Jul 2024 22:12:39 +0900 Subject: [PATCH 028/212] =?UTF-8?q?feat:=20ForbiddenException=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20-#7=20################=20#=20<=ED=83=80=EC=9E=85>:?= =?UTF-8?q?=20<=EC=A0=9C=EB=AA=A9>=20-=20<=EC=9D=B4=EC=8A=88=EB=B2=88?= =?UTF-8?q?=ED=98=B8>=20=EC=9D=98=20=ED=98=95=EC=8B=9D=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EC=A0=9C=EB=AA=A9=EC=9D=84=20=EC=95=84=EB=9E=98=20=EA=B3=B5?= =?UTF-8?q?=EB=B0=B1=EC=A4=84=EC=97=90=20=EC=9E=91=EC=84=B1=20#=20?= =?UTF-8?q?=EC=A0=9C=EB=AA=A9=EC=9D=80=2050=EC=9E=90=20=EC=9D=B4=EB=82=B4?= =?UTF-8?q?=20/=20=EB=B3=80=EA=B2=BD=EC=82=AC=ED=95=AD=EC=9D=B4=20"?= =?UTF-8?q?=EB=AC=B4=EC=97=87"=EC=9D=B8=EC=A7=80=20=EB=AA=85=ED=99=95?= =?UTF-8?q?=ED=9E=88=20=EC=9E=91=EC=84=B1=20/=20=EB=81=9D=EC=97=90=20?= =?UTF-8?q?=EB=A7=88=EC=B9=A8=ED=91=9C=20=EA=B8=88=EC=A7=80=20#=20?= =?UTF-8?q?=EC=98=88)=20feat:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=B6=94=EA=B0=80=20-=20#2=20#=20=EB=B0=94?= =?UTF-8?q?=EB=A1=9C=20=EC=95=84=EB=9E=98=20=EA=B3=B5=EB=B0=B1=EC=9D=80=20?= =?UTF-8?q?=EC=A0=9C=EB=AA=A9=EA=B3=BC=20=EB=B3=B8=EB=AC=B8=EC=9D=98=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC=EB=A5=BC=20=EC=9C=84=ED=95=A8=20############?= =?UTF-8?q?####=20#=20=EB=B3=B8=EB=AC=B8(=EA=B5=AC=EC=B2=B4=EC=A0=81?= =?UTF-8?q?=EC=9D=B8=20=EB=82=B4=EC=9A=A9)=EC=9D=84=20=EC=95=84=EB=9E=AB?= =?UTF-8?q?=EC=A4=84=EC=97=90=20=EC=9E=91=EC=84=B1=20#=20=EC=97=AC?= =?UTF-8?q?=EB=9F=AC=20=EC=A4=84=EC=9D=98=20=EB=A9=94=EC=8B=9C=EC=A7=80?= =?UTF-8?q?=EB=A5=BC=20=EC=9E=91=EC=84=B1=ED=95=A0=20=EB=95=90=20"-"?= =?UTF-8?q?=EB=A1=9C=20=EA=B5=AC=EB=B6=84=20(=ED=95=9C=20=EC=A4=84?= =?UTF-8?q?=EC=9D=80=2072=EC=9E=90=20=EC=9D=B4=EB=82=B4)=20###############?= =?UTF-8?q?#=20#feat=20#=EC=83=88=EB=A1=9C=EC=9A=B4=20=EA=B8=B0=EB=8A=A5?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80=20#=20#fix=20#=EB=B2=84=EA=B7=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20#=20#design=20#CSS=20=EB=93=B1=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=EC=9E=90=20UI=20=EB=94=94=EC=9E=90=EC=9D=B8=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20#=20#!BREAKING=20CHANGE=20#=EC=BB=A4?= =?UTF-8?q?=EB=8B=A4=EB=9E=80=20API=20=EB=B3=80=EA=B2=BD=EC=9D=98=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20#=20#!HOTFIX=20#=EA=B8=89=ED=95=98?= =?UTF-8?q?=EA=B2=8C=20=EC=B9=98=EB=AA=85=EC=A0=81=EC=9D=B8=20=EB=B2=84?= =?UTF-8?q?=EA=B7=B8=EB=A5=BC=20=EA=B3=A0=EC=B3=90=EC=95=BC=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20#=20#style=20#=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=ED=8F=AC=EB=A7=B7=20=EB=B3=80=EA=B2=BD,=20?= =?UTF-8?q?=EC=84=B8=EB=AF=B8=20=EC=BD=9C=EB=A1=A0=20=EB=88=84=EB=9D=BD,?= =?UTF-8?q?=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95=EC=9D=B4=20=EC=97=86?= =?UTF-8?q?=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20#=20#refactor=20#=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EB=8D=95=EC=85=98=20=EC=BD=94=EB=93=9C=20=EB=A6=AC?= =?UTF-8?q?=ED=8C=A9=ED=86=A0=EB=A7=81=20#=20#comment=20#=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EC=A3=BC=EC=84=9D=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20=EB=B3=80=EA=B2=BD=20#=20#docs=20#=EB=AC=B8?= =?UTF-8?q?=EC=84=9C=20=EC=88=98=EC=A0=95=20#=20#test=20#=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=B6=94=EA=B0=80,=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81(=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EB=8D=95=EC=85=98=20=EC=BD=94=EB=93=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20X)=20#=20#setting=20#=ED=8C=A8=ED=82=A4=EC=A7=80=20?= =?UTF-8?q?=EC=84=A4=EC=B9=98,=20=EA=B0=9C=EB=B0=9C=20=EC=84=A4=EC=A0=95?= =?UTF-8?q?=20#=20#chore=20#=EB=B9=8C=EB=93=9C=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8,=20=ED=8C=A8?= =?UTF-8?q?=ED=82=A4=EC=A7=80=20=EB=A7=A4=EB=8B=88=EC=A0=80=EB=A5=BC=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=ED=95=98=EB=8A=94=20=EA=B2=BD=EC=9A=B0(?= =?UTF-8?q?=ED=94=84=EB=A1=9C=EB=8D=95=EC=85=98=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20X)=20#=20#rename=20#=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=ED=98=B9=EC=9D=80=20=ED=8F=B4=EB=8D=94=EB=AA=85=EC=9D=84=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=ED=95=98=EA=B1=B0=EB=82=98=20=EC=98=AE?= =?UTF-8?q?=EA=B8=B0=EB=8A=94=20=EC=9E=91=EC=97=85=EB=A7=8C=EC=9D=B8=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20#=20#remove=20#=ED=8C=8C=EC=9D=BC=EC=9D=84?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C=ED=95=98=EB=8A=94=20=EC=9E=91=EC=97=85?= =?UTF-8?q?=EB=A7=8C=20=EC=88=98=ED=96=89=ED=95=9C=20=EA=B2=BD=EC=9A=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/exception/ForbiddenException.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/exception/ForbiddenException.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/exception/ForbiddenException.java b/src/main/java/com/hackathonteam1/refreshrator/exception/ForbiddenException.java new file mode 100644 index 0000000..33f3637 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/exception/ForbiddenException.java @@ -0,0 +1,13 @@ +package com.hackathonteam1.refreshrator.exception; + +import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; + +public class ForbiddenException extends CustomException{ + public ForbiddenException(ErrorCode errorCode) { + super(errorCode); + } + + public ForbiddenException(ErrorCode errorCode, String detail) { + super(errorCode, detail); + } +} From 32ffa92492d130ffd1cdad16fc6b69c4937bf489 Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 17 Jul 2024 22:12:45 +0900 Subject: [PATCH 029/212] =?UTF-8?q?feat:=20NotFoundException=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20-#7=20################=20#=20<=ED=83=80=EC=9E=85>:?= =?UTF-8?q?=20<=EC=A0=9C=EB=AA=A9>=20-=20<=EC=9D=B4=EC=8A=88=EB=B2=88?= =?UTF-8?q?=ED=98=B8>=20=EC=9D=98=20=ED=98=95=EC=8B=9D=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EC=A0=9C=EB=AA=A9=EC=9D=84=20=EC=95=84=EB=9E=98=20=EA=B3=B5?= =?UTF-8?q?=EB=B0=B1=EC=A4=84=EC=97=90=20=EC=9E=91=EC=84=B1=20#=20?= =?UTF-8?q?=EC=A0=9C=EB=AA=A9=EC=9D=80=2050=EC=9E=90=20=EC=9D=B4=EB=82=B4?= =?UTF-8?q?=20/=20=EB=B3=80=EA=B2=BD=EC=82=AC=ED=95=AD=EC=9D=B4=20"?= =?UTF-8?q?=EB=AC=B4=EC=97=87"=EC=9D=B8=EC=A7=80=20=EB=AA=85=ED=99=95?= =?UTF-8?q?=ED=9E=88=20=EC=9E=91=EC=84=B1=20/=20=EB=81=9D=EC=97=90=20?= =?UTF-8?q?=EB=A7=88=EC=B9=A8=ED=91=9C=20=EA=B8=88=EC=A7=80=20#=20?= =?UTF-8?q?=EC=98=88)=20feat:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=B6=94=EA=B0=80=20-=20#2=20#=20=EB=B0=94?= =?UTF-8?q?=EB=A1=9C=20=EC=95=84=EB=9E=98=20=EA=B3=B5=EB=B0=B1=EC=9D=80=20?= =?UTF-8?q?=EC=A0=9C=EB=AA=A9=EA=B3=BC=20=EB=B3=B8=EB=AC=B8=EC=9D=98=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC=EB=A5=BC=20=EC=9C=84=ED=95=A8=20############?= =?UTF-8?q?####=20#=20=EB=B3=B8=EB=AC=B8(=EA=B5=AC=EC=B2=B4=EC=A0=81?= =?UTF-8?q?=EC=9D=B8=20=EB=82=B4=EC=9A=A9)=EC=9D=84=20=EC=95=84=EB=9E=AB?= =?UTF-8?q?=EC=A4=84=EC=97=90=20=EC=9E=91=EC=84=B1=20#=20=EC=97=AC?= =?UTF-8?q?=EB=9F=AC=20=EC=A4=84=EC=9D=98=20=EB=A9=94=EC=8B=9C=EC=A7=80?= =?UTF-8?q?=EB=A5=BC=20=EC=9E=91=EC=84=B1=ED=95=A0=20=EB=95=90=20"-"?= =?UTF-8?q?=EB=A1=9C=20=EA=B5=AC=EB=B6=84=20(=ED=95=9C=20=EC=A4=84?= =?UTF-8?q?=EC=9D=80=2072=EC=9E=90=20=EC=9D=B4=EB=82=B4)=20###############?= =?UTF-8?q?#=20#feat=20#=EC=83=88=EB=A1=9C=EC=9A=B4=20=EA=B8=B0=EB=8A=A5?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80=20#=20#fix=20#=EB=B2=84=EA=B7=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20#=20#design=20#CSS=20=EB=93=B1=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=EC=9E=90=20UI=20=EB=94=94=EC=9E=90=EC=9D=B8=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20#=20#!BREAKING=20CHANGE=20#=EC=BB=A4?= =?UTF-8?q?=EB=8B=A4=EB=9E=80=20API=20=EB=B3=80=EA=B2=BD=EC=9D=98=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20#=20#!HOTFIX=20#=EA=B8=89=ED=95=98?= =?UTF-8?q?=EA=B2=8C=20=EC=B9=98=EB=AA=85=EC=A0=81=EC=9D=B8=20=EB=B2=84?= =?UTF-8?q?=EA=B7=B8=EB=A5=BC=20=EA=B3=A0=EC=B3=90=EC=95=BC=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20#=20#style=20#=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=ED=8F=AC=EB=A7=B7=20=EB=B3=80=EA=B2=BD,=20?= =?UTF-8?q?=EC=84=B8=EB=AF=B8=20=EC=BD=9C=EB=A1=A0=20=EB=88=84=EB=9D=BD,?= =?UTF-8?q?=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95=EC=9D=B4=20=EC=97=86?= =?UTF-8?q?=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20#=20#refactor=20#=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EB=8D=95=EC=85=98=20=EC=BD=94=EB=93=9C=20=EB=A6=AC?= =?UTF-8?q?=ED=8C=A9=ED=86=A0=EB=A7=81=20#=20#comment=20#=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EC=A3=BC=EC=84=9D=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20=EB=B3=80=EA=B2=BD=20#=20#docs=20#=EB=AC=B8?= =?UTF-8?q?=EC=84=9C=20=EC=88=98=EC=A0=95=20#=20#test=20#=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=B6=94=EA=B0=80,=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81(=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EB=8D=95=EC=85=98=20=EC=BD=94=EB=93=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20X)=20#=20#setting=20#=ED=8C=A8=ED=82=A4=EC=A7=80=20?= =?UTF-8?q?=EC=84=A4=EC=B9=98,=20=EA=B0=9C=EB=B0=9C=20=EC=84=A4=EC=A0=95?= =?UTF-8?q?=20#=20#chore=20#=EB=B9=8C=EB=93=9C=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8,=20=ED=8C=A8?= =?UTF-8?q?=ED=82=A4=EC=A7=80=20=EB=A7=A4=EB=8B=88=EC=A0=80=EB=A5=BC=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=ED=95=98=EB=8A=94=20=EA=B2=BD=EC=9A=B0(?= =?UTF-8?q?=ED=94=84=EB=A1=9C=EB=8D=95=EC=85=98=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20X)=20#=20#rename=20#=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=ED=98=B9=EC=9D=80=20=ED=8F=B4=EB=8D=94=EB=AA=85=EC=9D=84=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=ED=95=98=EA=B1=B0=EB=82=98=20=EC=98=AE?= =?UTF-8?q?=EA=B8=B0=EB=8A=94=20=EC=9E=91=EC=97=85=EB=A7=8C=EC=9D=B8=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20#=20#remove=20#=ED=8C=8C=EC=9D=BC=EC=9D=84?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C=ED=95=98=EB=8A=94=20=EC=9E=91=EC=97=85?= =?UTF-8?q?=EB=A7=8C=20=EC=88=98=ED=96=89=ED=95=9C=20=EA=B2=BD=EC=9A=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/exception/NotFoundException.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/exception/NotFoundException.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/exception/NotFoundException.java b/src/main/java/com/hackathonteam1/refreshrator/exception/NotFoundException.java new file mode 100644 index 0000000..6591d97 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/exception/NotFoundException.java @@ -0,0 +1,13 @@ +package com.hackathonteam1.refreshrator.exception; + +import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; + +public class NotFoundException extends CustomException{ + public NotFoundException(ErrorCode errorCode) { + super(errorCode); + } + + public NotFoundException(ErrorCode errorCode, String detail) { + super(errorCode, detail); + } +} From 1c8749ac5bbcabf553dd5ad189259e707888341f Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 17 Jul 2024 22:12:54 +0900 Subject: [PATCH 030/212] =?UTF-8?q?feat:=20UnauthorizedException=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20-#7=20################=20#=20<=ED=83=80?= =?UTF-8?q?=EC=9E=85>:=20<=EC=A0=9C=EB=AA=A9>=20-=20<=EC=9D=B4=EC=8A=88?= =?UTF-8?q?=EB=B2=88=ED=98=B8>=20=EC=9D=98=20=ED=98=95=EC=8B=9D=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EC=A0=9C=EB=AA=A9=EC=9D=84=20=EC=95=84=EB=9E=98=20?= =?UTF-8?q?=EA=B3=B5=EB=B0=B1=EC=A4=84=EC=97=90=20=EC=9E=91=EC=84=B1=20#?= =?UTF-8?q?=20=EC=A0=9C=EB=AA=A9=EC=9D=80=2050=EC=9E=90=20=EC=9D=B4?= =?UTF-8?q?=EB=82=B4=20/=20=EB=B3=80=EA=B2=BD=EC=82=AC=ED=95=AD=EC=9D=B4?= =?UTF-8?q?=20"=EB=AC=B4=EC=97=87"=EC=9D=B8=EC=A7=80=20=EB=AA=85=ED=99=95?= =?UTF-8?q?=ED=9E=88=20=EC=9E=91=EC=84=B1=20/=20=EB=81=9D=EC=97=90=20?= =?UTF-8?q?=EB=A7=88=EC=B9=A8=ED=91=9C=20=EA=B8=88=EC=A7=80=20#=20?= =?UTF-8?q?=EC=98=88)=20feat:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=B6=94=EA=B0=80=20-=20#2=20#=20=EB=B0=94?= =?UTF-8?q?=EB=A1=9C=20=EC=95=84=EB=9E=98=20=EA=B3=B5=EB=B0=B1=EC=9D=80=20?= =?UTF-8?q?=EC=A0=9C=EB=AA=A9=EA=B3=BC=20=EB=B3=B8=EB=AC=B8=EC=9D=98=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC=EB=A5=BC=20=EC=9C=84=ED=95=A8=20############?= =?UTF-8?q?####=20#=20=EB=B3=B8=EB=AC=B8(=EA=B5=AC=EC=B2=B4=EC=A0=81?= =?UTF-8?q?=EC=9D=B8=20=EB=82=B4=EC=9A=A9)=EC=9D=84=20=EC=95=84=EB=9E=AB?= =?UTF-8?q?=EC=A4=84=EC=97=90=20=EC=9E=91=EC=84=B1=20#=20=EC=97=AC?= =?UTF-8?q?=EB=9F=AC=20=EC=A4=84=EC=9D=98=20=EB=A9=94=EC=8B=9C=EC=A7=80?= =?UTF-8?q?=EB=A5=BC=20=EC=9E=91=EC=84=B1=ED=95=A0=20=EB=95=90=20"-"?= =?UTF-8?q?=EB=A1=9C=20=EA=B5=AC=EB=B6=84=20(=ED=95=9C=20=EC=A4=84?= =?UTF-8?q?=EC=9D=80=2072=EC=9E=90=20=EC=9D=B4=EB=82=B4)=20###############?= =?UTF-8?q?#=20#feat=20#=EC=83=88=EB=A1=9C=EC=9A=B4=20=EA=B8=B0=EB=8A=A5?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80=20#=20#fix=20#=EB=B2=84=EA=B7=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20#=20#design=20#CSS=20=EB=93=B1=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=EC=9E=90=20UI=20=EB=94=94=EC=9E=90=EC=9D=B8=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20#=20#!BREAKING=20CHANGE=20#=EC=BB=A4?= =?UTF-8?q?=EB=8B=A4=EB=9E=80=20API=20=EB=B3=80=EA=B2=BD=EC=9D=98=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20#=20#!HOTFIX=20#=EA=B8=89=ED=95=98?= =?UTF-8?q?=EA=B2=8C=20=EC=B9=98=EB=AA=85=EC=A0=81=EC=9D=B8=20=EB=B2=84?= =?UTF-8?q?=EA=B7=B8=EB=A5=BC=20=EA=B3=A0=EC=B3=90=EC=95=BC=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20#=20#style=20#=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=ED=8F=AC=EB=A7=B7=20=EB=B3=80=EA=B2=BD,=20?= =?UTF-8?q?=EC=84=B8=EB=AF=B8=20=EC=BD=9C=EB=A1=A0=20=EB=88=84=EB=9D=BD,?= =?UTF-8?q?=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95=EC=9D=B4=20=EC=97=86?= =?UTF-8?q?=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20#=20#refactor=20#=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EB=8D=95=EC=85=98=20=EC=BD=94=EB=93=9C=20=EB=A6=AC?= =?UTF-8?q?=ED=8C=A9=ED=86=A0=EB=A7=81=20#=20#comment=20#=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EC=A3=BC=EC=84=9D=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20=EB=B3=80=EA=B2=BD=20#=20#docs=20#=EB=AC=B8?= =?UTF-8?q?=EC=84=9C=20=EC=88=98=EC=A0=95=20#=20#test=20#=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=B6=94=EA=B0=80,=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81(=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EB=8D=95=EC=85=98=20=EC=BD=94=EB=93=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20X)=20#=20#setting=20#=ED=8C=A8=ED=82=A4=EC=A7=80=20?= =?UTF-8?q?=EC=84=A4=EC=B9=98,=20=EA=B0=9C=EB=B0=9C=20=EC=84=A4=EC=A0=95?= =?UTF-8?q?=20#=20#chore=20#=EB=B9=8C=EB=93=9C=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8,=20=ED=8C=A8?= =?UTF-8?q?=ED=82=A4=EC=A7=80=20=EB=A7=A4=EB=8B=88=EC=A0=80=EB=A5=BC=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=ED=95=98=EB=8A=94=20=EA=B2=BD=EC=9A=B0(?= =?UTF-8?q?=ED=94=84=EB=A1=9C=EB=8D=95=EC=85=98=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20X)=20#=20#rename=20#=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=ED=98=B9=EC=9D=80=20=ED=8F=B4=EB=8D=94=EB=AA=85=EC=9D=84=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=ED=95=98=EA=B1=B0=EB=82=98=20=EC=98=AE?= =?UTF-8?q?=EA=B8=B0=EB=8A=94=20=EC=9E=91=EC=97=85=EB=A7=8C=EC=9D=B8=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20#=20#remove=20#=ED=8C=8C=EC=9D=BC=EC=9D=84?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C=ED=95=98=EB=8A=94=20=EC=9E=91=EC=97=85?= =?UTF-8?q?=EB=A7=8C=20=EC=88=98=ED=96=89=ED=95=9C=20=EA=B2=BD=EC=9A=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/UnauthorizedException.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/exception/UnauthorizedException.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/exception/UnauthorizedException.java b/src/main/java/com/hackathonteam1/refreshrator/exception/UnauthorizedException.java new file mode 100644 index 0000000..92b507a --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/exception/UnauthorizedException.java @@ -0,0 +1,13 @@ +package com.hackathonteam1.refreshrator.exception; + +import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; + +public class UnauthorizedException extends CustomException{ + public UnauthorizedException(ErrorCode errorCode) { + super(errorCode); + } + + public UnauthorizedException(ErrorCode errorCode, String detail) { + super(errorCode, detail); + } +} From 2dcb81824397a52f5bd2055d73c18426d5f60aad Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 17 Jul 2024 22:13:18 +0900 Subject: [PATCH 031/212] =?UTF-8?q?feat:=20=EC=9D=98=EC=A1=B4=EC=84=B1=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20-#7=20################=20#=20<=ED=83=80?= =?UTF-8?q?=EC=9E=85>:=20<=EC=A0=9C=EB=AA=A9>=20-=20<=EC=9D=B4=EC=8A=88?= =?UTF-8?q?=EB=B2=88=ED=98=B8>=20=EC=9D=98=20=ED=98=95=EC=8B=9D=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EC=A0=9C=EB=AA=A9=EC=9D=84=20=EC=95=84=EB=9E=98=20?= =?UTF-8?q?=EA=B3=B5=EB=B0=B1=EC=A4=84=EC=97=90=20=EC=9E=91=EC=84=B1=20#?= =?UTF-8?q?=20=EC=A0=9C=EB=AA=A9=EC=9D=80=2050=EC=9E=90=20=EC=9D=B4?= =?UTF-8?q?=EB=82=B4=20/=20=EB=B3=80=EA=B2=BD=EC=82=AC=ED=95=AD=EC=9D=B4?= =?UTF-8?q?=20"=EB=AC=B4=EC=97=87"=EC=9D=B8=EC=A7=80=20=EB=AA=85=ED=99=95?= =?UTF-8?q?=ED=9E=88=20=EC=9E=91=EC=84=B1=20/=20=EB=81=9D=EC=97=90=20?= =?UTF-8?q?=EB=A7=88=EC=B9=A8=ED=91=9C=20=EA=B8=88=EC=A7=80=20#=20?= =?UTF-8?q?=EC=98=88)=20feat:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=B6=94=EA=B0=80=20-=20#2=20#=20=EB=B0=94?= =?UTF-8?q?=EB=A1=9C=20=EC=95=84=EB=9E=98=20=EA=B3=B5=EB=B0=B1=EC=9D=80=20?= =?UTF-8?q?=EC=A0=9C=EB=AA=A9=EA=B3=BC=20=EB=B3=B8=EB=AC=B8=EC=9D=98=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC=EB=A5=BC=20=EC=9C=84=ED=95=A8=20############?= =?UTF-8?q?####=20#=20=EB=B3=B8=EB=AC=B8(=EA=B5=AC=EC=B2=B4=EC=A0=81?= =?UTF-8?q?=EC=9D=B8=20=EB=82=B4=EC=9A=A9)=EC=9D=84=20=EC=95=84=EB=9E=AB?= =?UTF-8?q?=EC=A4=84=EC=97=90=20=EC=9E=91=EC=84=B1=20#=20=EC=97=AC?= =?UTF-8?q?=EB=9F=AC=20=EC=A4=84=EC=9D=98=20=EB=A9=94=EC=8B=9C=EC=A7=80?= =?UTF-8?q?=EB=A5=BC=20=EC=9E=91=EC=84=B1=ED=95=A0=20=EB=95=90=20"-"?= =?UTF-8?q?=EB=A1=9C=20=EA=B5=AC=EB=B6=84=20(=ED=95=9C=20=EC=A4=84?= =?UTF-8?q?=EC=9D=80=2072=EC=9E=90=20=EC=9D=B4=EB=82=B4)=20###############?= =?UTF-8?q?#=20#feat=20#=EC=83=88=EB=A1=9C=EC=9A=B4=20=EA=B8=B0=EB=8A=A5?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80=20#=20#fix=20#=EB=B2=84=EA=B7=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20#=20#design=20#CSS=20=EB=93=B1=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=EC=9E=90=20UI=20=EB=94=94=EC=9E=90=EC=9D=B8=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20#=20#!BREAKING=20CHANGE=20#=EC=BB=A4?= =?UTF-8?q?=EB=8B=A4=EB=9E=80=20API=20=EB=B3=80=EA=B2=BD=EC=9D=98=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20#=20#!HOTFIX=20#=EA=B8=89=ED=95=98?= =?UTF-8?q?=EA=B2=8C=20=EC=B9=98=EB=AA=85=EC=A0=81=EC=9D=B8=20=EB=B2=84?= =?UTF-8?q?=EA=B7=B8=EB=A5=BC=20=EA=B3=A0=EC=B3=90=EC=95=BC=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20#=20#style=20#=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=ED=8F=AC=EB=A7=B7=20=EB=B3=80=EA=B2=BD,=20?= =?UTF-8?q?=EC=84=B8=EB=AF=B8=20=EC=BD=9C=EB=A1=A0=20=EB=88=84=EB=9D=BD,?= =?UTF-8?q?=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95=EC=9D=B4=20=EC=97=86?= =?UTF-8?q?=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20#=20#refactor=20#=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EB=8D=95=EC=85=98=20=EC=BD=94=EB=93=9C=20=EB=A6=AC?= =?UTF-8?q?=ED=8C=A9=ED=86=A0=EB=A7=81=20#=20#comment=20#=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EC=A3=BC=EC=84=9D=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20=EB=B3=80=EA=B2=BD=20#=20#docs=20#=EB=AC=B8?= =?UTF-8?q?=EC=84=9C=20=EC=88=98=EC=A0=95=20#=20#test=20#=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=B6=94=EA=B0=80,=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81(=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EB=8D=95=EC=85=98=20=EC=BD=94=EB=93=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20X)=20#=20#setting=20#=ED=8C=A8=ED=82=A4=EC=A7=80=20?= =?UTF-8?q?=EC=84=A4=EC=B9=98,=20=EA=B0=9C=EB=B0=9C=20=EC=84=A4=EC=A0=95?= =?UTF-8?q?=20#=20#chore=20#=EB=B9=8C=EB=93=9C=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8,=20=ED=8C=A8?= =?UTF-8?q?=ED=82=A4=EC=A7=80=20=EB=A7=A4=EB=8B=88=EC=A0=80=EB=A5=BC=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=ED=95=98=EB=8A=94=20=EA=B2=BD=EC=9A=B0(?= =?UTF-8?q?=ED=94=84=EB=A1=9C=EB=8D=95=EC=85=98=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20X)=20#=20#rename=20#=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=ED=98=B9=EC=9D=80=20=ED=8F=B4=EB=8D=94=EB=AA=85=EC=9D=84=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=ED=95=98=EA=B1=B0=EB=82=98=20=EC=98=AE?= =?UTF-8?q?=EA=B8=B0=EB=8A=94=20=EC=9E=91=EC=97=85=EB=A7=8C=EC=9D=B8=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20#=20#remove=20#=ED=8C=8C=EC=9D=BC=EC=9D=84?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C=ED=95=98=EB=8A=94=20=EC=9E=91=EC=97=85?= =?UTF-8?q?=EB=A7=8C=20=EC=88=98=ED=96=89=ED=95=9C=20=EA=B2=BD=EC=9A=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/build.gradle b/build.gradle index e41f84e..91964fe 100644 --- a/build.gradle +++ b/build.gradle @@ -21,6 +21,18 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' testImplementation 'org.springframework.boot:spring-boot-starter-test' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' + + compileOnly 'org.projectlombok:lombok:1.18.32' + annotationProcessor 'org.projectlombok:lombok:1.18.32' + + testCompileOnly 'org.projectlombok:lombok:1.18.32' + testAnnotationProcessor 'org.projectlombok:lombok:1.18.32' + + implementation 'org.springframework.boot:spring-boot-starter-validation' + + implementation 'org.springframework.boot:spring-boot-starter-data-jpa'//JPA + implementation 'org.springframework.boot:spring-boot-starter-jdbc'//JDBC + runtimeOnly 'com.mysql:mysql-connector-j'//MySQL } tasks.named('test') { From 403e3ac66e89430bd3f16e05cff35359e9f6a0c8 Mon Sep 17 00:00:00 2001 From: juryheed Date: Fri, 19 Jul 2024 22:06:30 +0900 Subject: [PATCH 032/212] =?UTF-8?q?feat:=20signinDto=EC=B6=94=EA=B0=80=20-?= =?UTF-8?q?=20#10=20Dto=EC=97=90=EB=8A=94=20name,email,password=EA=B0=80?= =?UTF-8?q?=20=EC=9E=88=EC=9D=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/dto/request/SigninDto.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/dto/request/SigninDto.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/request/SigninDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/request/SigninDto.java new file mode 100644 index 0000000..7864851 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/request/SigninDto.java @@ -0,0 +1,29 @@ +package com.hackathonteam1.refreshrator.dto.request; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.Pattern; +import jakarta.validation.constraints.Size; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class SigninDto { + //이름 + @NotBlank(message = "본인의 이름을 입력해주세요.") + @Size(min = 1, max = 20, message = "이름은 최소 한글자 최대 20글자입니다.") + private String name; + + //아이디(이메일) + @Pattern(regexp = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{1,100}$", message = "이메일이 형식에 맞지 않습니다.") + @NotBlank(message = "사용하실 아이디(이메일)을 입력해주세요.") + @Size(min = 1,max=100,message = "아이디는 최소 한글자 이상 최대 100글자입니다.") + private String email; + + //비밀번호 + @NotBlank(message = "영문과 숫자,특수기호를 조합하여 8~14글자 미만으로 입력하여 주세요.") + @Pattern(regexp = "^(?=.*[A-Za-z])(?=.*\\d)(?=.*[!@#$%^&*()])[A-Za-z\\d!@#$%^&*()]{8,14}$", message = "영문,숫자,특수기호를 조합하여 8~14글자 미만으로 입력하여 주세요.") + @Size(min = 8, max = 14, message = " 비밀번로는 최소8글자 최대 14글자 입니다.") + private String password; + +} From 812026005b7a8c58c14d3f2204e1caf6f499e54d Mon Sep 17 00:00:00 2001 From: juryheed Date: Fri, 19 Jul 2024 23:48:01 +0900 Subject: [PATCH 033/212] =?UTF-8?q?feature:=20UseRepository=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20-=20#10=20email=EB=A1=9C=20=EC=9C=A0=EC=A0=80=20?= =?UTF-8?q?=EC=B0=BE=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20=EB=A7=8C=EB=93=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/repository/UserRepository.java | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/repository/UserRepository.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/repository/UserRepository.java b/src/main/java/com/hackathonteam1/refreshrator/repository/UserRepository.java new file mode 100644 index 0000000..bf8a641 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/repository/UserRepository.java @@ -0,0 +1,11 @@ +package com.hackathonteam1.refreshrator.repository; + +import com.hackathonteam1.refreshrator.entity.User; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.Optional; +import java.util.UUID; + +public interface UserRepository extends JpaRepository { + Optional findByEmail(String email); +} From a69436cc60c8cdd0330c549ae73a78ab7b52a980 Mon Sep 17 00:00:00 2001 From: juryheed Date: Fri, 19 Jul 2024 23:52:00 +0900 Subject: [PATCH 034/212] =?UTF-8?q?feat:=20AtthService=EC=97=90=20?= =?UTF-8?q?=ED=9A=8C=EC=9B=90=EA=B0=80=EC=9E=85=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84=20-=20#10=20=EC=9D=B4=EB=A9=94=EC=9D=BC(?= =?UTF-8?q?=EC=95=84=EC=9D=B4=EB=94=94)=20=EC=A4=91=EB=B3=B5=ED=99=95?= =?UTF-8?q?=EC=9D=B8=20=ED=9B=84=20=EC=9C=A0=EC=A0=80=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/service/AuthService.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java b/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java new file mode 100644 index 0000000..b95aee8 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java @@ -0,0 +1,34 @@ +package com.hackathonteam1.refreshrator.service; + +import com.hackathonteam1.refreshrator.dto.request.SigninDto; +import com.hackathonteam1.refreshrator.entity.User; +import com.hackathonteam1.refreshrator.exception.ConflictException; +import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; +import com.hackathonteam1.refreshrator.repository.UserRepository; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@AllArgsConstructor +public class AuthService { + private final UserRepository userRepository; + + //회원가입 + public void signin(SigninDto signinDto){ + + //아이디(이메일) 중복 방지 + if(userRepository.findByEmail(signinDto.getEmail()).isPresent()){ + throw new ConflictException(ErrorCode.DUPLICATED_EMAIL); + } + + //비밀번호 암호화 + + //유저 생성과 등록 + User user=User.builder() + .name(signinDto.getName()) + .email(signinDto.getEmail()) + .password(signinDto.getPassword()) + .build(); + userRepository.save(user); + } +} From b80e6f68563dee9a9c2cdb372b69bf7a64440b75 Mon Sep 17 00:00:00 2001 From: juryheed Date: Fri, 19 Jul 2024 23:55:22 +0900 Subject: [PATCH 035/212] =?UTF-8?q?feat:=20=ED=9A=8C=EC=9B=90=EA=B0=80?= =?UTF-8?q?=EC=9E=85=20=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20-=20#10=20AuthController=EC=97=90=20=ED=9A=8C?= =?UTF-8?q?=EC=9B=90=EA=B0=80=EC=9E=85=20=EC=BB=A8=ED=8A=B8=EB=A1=A4?= =?UTF-8?q?=EB=9F=AC=20=EC=9E=91=EC=84=B1=20=ED=9A=8C=EC=9B=90=EA=B0=80?= =?UTF-8?q?=EC=9E=85=20=EC=A3=BC=EC=86=8C=EB=8A=94=20/auth/signin=20?= =?UTF-8?q?=ED=9A=8C=EC=9B=90=EA=B0=80=EC=9E=85=20=EC=84=B1=EA=B3=B5?= =?UTF-8?q?=EC=8B=9C=20"=ED=9A=8C=EC=9B=90=20=EA=B0=80=EC=9E=85=20?= =?UTF-8?q?=EC=99=84=EB=A3=8C"=20=EB=AC=B8=EA=B5=AC=EA=B0=80=20=EB=82=98?= =?UTF-8?q?=EC=98=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/AuthController.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java new file mode 100644 index 0000000..3f8dea2 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java @@ -0,0 +1,29 @@ +package com.hackathonteam1.refreshrator.controller; + +import com.hackathonteam1.refreshrator.dto.ResponseDto; +import com.hackathonteam1.refreshrator.dto.request.SigninDto; +import com.hackathonteam1.refreshrator.service.AuthService; +import jakarta.validation.Valid; +import lombok.AllArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +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 +@AllArgsConstructor +@RequestMapping("/auth") +public class AuthController { + + private final AuthService authService; + + @PostMapping("/signin") + public ResponseEntity> signup(@RequestBody @Valid SigninDto signinDto) { + + authService.signin(signinDto); + + return new ResponseEntity<>(ResponseDto.res(HttpStatus.CREATED, "회원 가입 완료"), HttpStatus.CREATED); + } +} From 2741b60169ea987e374642d44c7a5ce1591bb61d Mon Sep 17 00:00:00 2001 From: juryheed Date: Sat, 20 Jul 2024 00:00:29 +0900 Subject: [PATCH 036/212] =?UTF-8?q?feat:=20=EC=9D=B4=EB=A9=94=EC=9D=BC=20?= =?UTF-8?q?=EC=A4=91=EB=B3=B5=EC=8B=9C=20=EB=82=98=EC=98=A4=EB=8A=94=20err?= =?UTF-8?q?or=20code=20=EC=9E=91=EC=84=B1=20-=20#10=20=ED=9A=8C=EC=9B=90?= =?UTF-8?q?=EA=B0=80=EC=9E=85=20=ED=95=A0=EB=95=8C=20=EC=9D=B4=EB=A9=94?= =?UTF-8?q?=EC=9D=BC=20=EC=A4=91=EB=B3=B5=20=EA=B2=80=EC=82=AC=EC=8B=9C=20?= =?UTF-8?q?=EC=9D=B4=EB=AF=B8=20=EC=A1=B4=EC=9E=AC=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EC=9D=B4=EB=A9=94=EC=9D=BC=EC=9D=B4=EB=A9=B4=20=EB=B0=9C?= =?UTF-8?q?=EC=83=9D=ED=95=98=EB=8A=94=20=EC=97=90=EB=9F=AC=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EB=B2=88=ED=98=B8=204090=20=EB=A9=94=EC=84=B8?= =?UTF-8?q?=EC=A7=80=20=EC=9D=B4=EB=AF=B8=20=EC=82=AC=EC=9A=A9=EC=A4=91?= =?UTF-8?q?=EC=9D=B8=20=EC=9D=B4=EB=A9=94=EC=9D=BC=20=EC=9E=85=EB=8B=88?= =?UTF-8?q?=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/exception/errorcode/ErrorCode.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java index 4d27006..a917603 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java +++ b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java @@ -12,7 +12,7 @@ public enum ErrorCode { PATTERN("4001","형식에 맞지 않습니다."), NOT_BLANK("4002", "필수값이 공백입니다."), LENGTH("4003", "길이가 유효하지 않습니다."), - EMAIL("4004", "이메일 형식이 유효하지 않습니다."); + EMAIL("4004", "이메일 형식이 유효하지 않습니다."), //AuthorizedException @@ -21,6 +21,8 @@ public enum ErrorCode { //NotFoundException //ConflictException + DUPLICATED_EMAIL("4090", "이미 사용 중인 이메일입니다."); + private final String code; private final String message; From 34b6bdef4a32af404ecdc9c8c67c4bc2a5eb621a Mon Sep 17 00:00:00 2001 From: juryheed Date: Sat, 20 Jul 2024 03:37:00 +0900 Subject: [PATCH 037/212] =?UTF-8?q?feat:=20=EC=9D=98=EC=A1=B4=EC=84=B1=20?= =?UTF-8?q?=EC=A3=BC=EC=9E=85=20-=20#14?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build.gradle b/build.gradle index 91964fe..1e6c71a 100644 --- a/build.gradle +++ b/build.gradle @@ -33,6 +33,11 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-data-jpa'//JPA implementation 'org.springframework.boot:spring-boot-starter-jdbc'//JDBC runtimeOnly 'com.mysql:mysql-connector-j'//MySQL + + implementation 'io.jsonwebtoken:jjwt-api:0.11.5'//JWT + implementation 'io.jsonwebtoken:jjwt-impl:0.11.5'//JWT + implementation 'io.jsonwebtoken:jjwt-jackson:0.11.5'//JWT + implementation 'javax.xml.bind:jaxb-api:2.3.1'//JAXB } tasks.named('test') { From aa81213fbf48d00f60f2f9b398e25284b4546ded Mon Sep 17 00:00:00 2001 From: juryheed Date: Sat, 20 Jul 2024 03:41:13 +0900 Subject: [PATCH 038/212] =?UTF-8?q?feature:=20AuthenticatedUser=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20-=20#14?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../authentication/AuthenticatedUser.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticatedUser.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticatedUser.java b/src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticatedUser.java new file mode 100644 index 0000000..4e56c91 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticatedUser.java @@ -0,0 +1,12 @@ +package com.hackathonteam1.refreshrator.authentication; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +public @interface AuthenticatedUser { +} + From 4b1c8c73a4fc8eab1ef2855b896bb5f57041fb1d Mon Sep 17 00:00:00 2001 From: juryheed Date: Sat, 20 Jul 2024 03:42:11 +0900 Subject: [PATCH 039/212] =?UTF-8?q?feat:=20AuthenticatedUserArgumentResolv?= =?UTF-8?q?er=EC=9E=91=EC=84=B1=20-=20#14?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AuthenticatedUserArgumentResolver.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticatedUserArgumentResolver.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticatedUserArgumentResolver.java b/src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticatedUserArgumentResolver.java new file mode 100644 index 0000000..bd4a9e5 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticatedUserArgumentResolver.java @@ -0,0 +1,32 @@ +package com.hackathonteam1.refreshrator.authentication; + +import com.hackathonteam1.refreshrator.entity.User; +import lombok.RequiredArgsConstructor; +import org.springframework.core.MethodParameter; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.support.WebDataBinderFactory; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.method.support.HandlerMethodArgumentResolver; +import org.springframework.web.method.support.ModelAndViewContainer; + +@Component +@RequiredArgsConstructor +public class AuthenticatedUserArgumentResolver implements HandlerMethodArgumentResolver { + + private final AuthenticationContext authenticationContext; + + @Override + public boolean supportsParameter(final MethodParameter parameter) { + return parameter.hasParameterAnnotation(AuthenticatedUser.class); + } + + //supportsParameter가 true를 반환할 때 호출 + @Override + public User resolveArgument(final MethodParameter parameter, //메서드의 파라미터를 나타내는 객체 + final ModelAndViewContainer mavContainer, //현재 요청 모델의 뷰 정보를 담고 있음 + final NativeWebRequest webRequest, //HTTP요청을 추상화한 객체 + final WebDataBinderFactory binderFactory) { //데이터바인더를 반환하는 팩토리 + return authenticationContext.getPrincipal(); //이제 인증된 User를 반환 + } +} + From cb6345f37cbd1309484221a097a7b637c979ca96 Mon Sep 17 00:00:00 2001 From: juryheed Date: Sat, 20 Jul 2024 03:43:15 +0900 Subject: [PATCH 040/212] =?UTF-8?q?feat:=20AuthenticationConfig=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20-=20#14?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../authentication/AuthenticationConfig.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticationConfig.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticationConfig.java b/src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticationConfig.java new file mode 100644 index 0000000..56f48be --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticationConfig.java @@ -0,0 +1,31 @@ +package com.hackathonteam1.refreshrator.authentication; + +import lombok.RequiredArgsConstructor; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.method.support.HandlerMethodArgumentResolver; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +import java.util.List; + +@Configuration +@RequiredArgsConstructor +public class AuthenticationConfig implements WebMvcConfigurer { + + private final AuthenticationInterceptor authenticationInterceptor; + private final AuthenticatedUserArgumentResolver authenticatedUserArgumentResolver; + + //인터셉터 등록 + 경로 설정 + @Override + public void addInterceptors(final InterceptorRegistry registry) { + registry.addInterceptor(authenticationInterceptor) + .addPathPatterns("/fridge/**") + .excludePathPatterns("/auth/signin", "/auth/login","/auth/logout"); + } + + //컨트롤러 메서드 파라미터에 인증된 유저가 들어가도록 함 + @Override + public void addArgumentResolvers(final List resolvers) { + resolvers.add(authenticatedUserArgumentResolver); + } +} From 4b0cbbdc0658fcc776e5ee6a5b0e10e7f394083e Mon Sep 17 00:00:00 2001 From: juryheed Date: Sat, 20 Jul 2024 03:44:21 +0900 Subject: [PATCH 041/212] =?UTF-8?q?feat:=20AuthenticationContext=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20-=20#14?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../authentication/AuthenticationContext.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticationContext.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticationContext.java b/src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticationContext.java new file mode 100644 index 0000000..bb32065 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticationContext.java @@ -0,0 +1,15 @@ +package com.hackathonteam1.refreshrator.authentication; + +import com.hackathonteam1.refreshrator.entity.User; +import lombok.Getter; +import lombok.Setter; +import org.springframework.stereotype.Component; +import org.springframework.web.context.annotation.RequestScope; + +@Setter +@Getter +@Component +@RequestScope +public class AuthenticationContext { + private User principal; +} \ No newline at end of file From 28d49896ca1d69a5ea51ed14d39c8b63e5aa004a Mon Sep 17 00:00:00 2001 From: juryheed Date: Sat, 20 Jul 2024 03:44:58 +0900 Subject: [PATCH 042/212] =?UTF-8?q?feat:=20AuthenticationExtractor?= =?UTF-8?q?=EC=9E=91=EC=84=B1=20-=20#14?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AuthenticationExtractor.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticationExtractor.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticationExtractor.java b/src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticationExtractor.java new file mode 100644 index 0000000..8b141cd --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticationExtractor.java @@ -0,0 +1,24 @@ +package com.hackathonteam1.refreshrator.authentication; + +import com.hackathonteam1.refreshrator.exception.UnauthorizedException; +import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; +import jakarta.servlet.http.Cookie; +import jakarta.servlet.http.HttpServletRequest; + +public class AuthenticationExtractor { + public static final String TOKEN_COOKIE_NAME = "AccessToken"; + + public static String extract(final HttpServletRequest request) { + + Cookie[] cookies = request.getCookies(); + + if (cookies != null) { + for (Cookie cookie : cookies) { + if (TOKEN_COOKIE_NAME.equals(cookie.getName())) { + return JwtEncoder.decodeJwtBearerToken(cookie.getValue()); //디코딩 + } + } + } + throw new UnauthorizedException(ErrorCode.COOKIE_NOT_FOUND); + } +} From 2ed086958c77b93c1458c0fa3c0dd364fdf21894 Mon Sep 17 00:00:00 2001 From: juryheed Date: Sat, 20 Jul 2024 03:45:34 +0900 Subject: [PATCH 043/212] =?UTF-8?q?feat:=20AuthenticationInterceptor?= =?UTF-8?q?=EC=9E=91=EC=84=B1=20-#14?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AuthenticationInterceptor.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticationInterceptor.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticationInterceptor.java b/src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticationInterceptor.java new file mode 100644 index 0000000..87282a1 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticationInterceptor.java @@ -0,0 +1,40 @@ +package com.hackathonteam1.refreshrator.authentication; + +import com.hackathonteam1.refreshrator.entity.User; +import com.hackathonteam1.refreshrator.exception.NotFoundException; +import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; +import com.hackathonteam1.refreshrator.repository.UserRepository; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; +import org.springframework.web.servlet.HandlerInterceptor; + +import java.util.UUID; + +@Component +@RequiredArgsConstructor +@Slf4j +public class AuthenticationInterceptor implements HandlerInterceptor { + + private final JwtTokenProvider jwtTokenProvider; + private final AuthenticationContext authenticationContext; + private final UserRepository userRepository; + + @Override + public boolean preHandle(final HttpServletRequest request, + final HttpServletResponse response, + final Object handler) { + String accessToken = AuthenticationExtractor.extract(request); + UUID userId = UUID.fromString(jwtTokenProvider.getPayload(accessToken)); + User user = findExistingUser(userId); + authenticationContext.setPrincipal(user); + return true; + } + + private User findExistingUser(final UUID userId) { + return userRepository.findById(userId) + .orElseThrow(() -> new NotFoundException(ErrorCode.USERID_NOT_FOUND)); + } +} \ No newline at end of file From 150c317993bffa2fb567d767cb7c584e331e479f Mon Sep 17 00:00:00 2001 From: juryheed Date: Sat, 20 Jul 2024 03:46:25 +0900 Subject: [PATCH 044/212] =?UTF-8?q?feat:=20JwtEncoder=EC=9E=91=EC=84=B1=20?= =?UTF-8?q?-#14?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../authentication/JwtEncoder.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/authentication/JwtEncoder.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/authentication/JwtEncoder.java b/src/main/java/com/hackathonteam1/refreshrator/authentication/JwtEncoder.java new file mode 100644 index 0000000..9ba3e81 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/authentication/JwtEncoder.java @@ -0,0 +1,30 @@ +package com.hackathonteam1.refreshrator.authentication; + +import com.hackathonteam1.refreshrator.exception.UnauthorizedException; +import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; +import org.springframework.stereotype.Component; + +import java.net.URLDecoder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; + +@Component +public class JwtEncoder { + public static final String TOKEN_TYPE="Bearer "; + + public static String encodeJwtToken(String token){ + String cookieValue = TOKEN_TYPE+token; + return URLEncoder.encode(cookieValue, StandardCharsets.UTF_8).replace("\\", "%20"); + } + + public static String decodeJwtBearerToken(String cookieValue){ + String decodedValue = URLDecoder.decode(cookieValue,StandardCharsets.UTF_8); + + if (decodedValue.startsWith(TOKEN_TYPE)) { + return decodedValue.substring(TOKEN_TYPE.length()); + } + + throw new UnauthorizedException(ErrorCode.INVALID_TOKEN); + } +} + From 9dea90708900633e33f3c4fc0c37c79f313241b6 Mon Sep 17 00:00:00 2001 From: juryheed Date: Sat, 20 Jul 2024 03:47:16 +0900 Subject: [PATCH 045/212] =?UTF-8?q?feat:=20JwtTokenProviderw=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20-#14?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../authentication/JwtTokenProvider.java | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/authentication/JwtTokenProvider.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/authentication/JwtTokenProvider.java b/src/main/java/com/hackathonteam1/refreshrator/authentication/JwtTokenProvider.java new file mode 100644 index 0000000..ebca850 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/authentication/JwtTokenProvider.java @@ -0,0 +1,56 @@ +package com.hackathonteam1.refreshrator.authentication; + + +import com.hackathonteam1.refreshrator.exception.UnauthorizedException; +import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; +import io.jsonwebtoken.JwtException; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.SignatureAlgorithm; +import io.jsonwebtoken.security.Keys; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import javax.crypto.SecretKey; +import java.nio.charset.StandardCharsets; +import java.util.Date; + +@Component +public class JwtTokenProvider { + + private final SecretKey key; + private final long validityInMilliseconds; + + //생성자 + public JwtTokenProvider(@Value("${security.jwt.token.secret-key}") final String secretKey, + @Value("${security.jwt.token.expire-length}") final long validityInMilliseconds) { + this.key = Keys.hmacShaKeyFor(secretKey.getBytes(StandardCharsets.UTF_8)); + this.validityInMilliseconds = validityInMilliseconds; + } + + //로그인시 토큰을 발급함 + public String createToken(final String payload) { + Date now = new Date(); + Date expiration = new Date(now.getTime() + validityInMilliseconds); + + return Jwts.builder() + .setSubject(payload) //userid + .setIssuedAt(now) //발급 시간 + .setExpiration(expiration) //만료 시간 + .signWith(key, SignatureAlgorithm.HS256) //서명 + .compact(); //문자열로 반환 + } + + //페이로드 분석,userId 반환 + public String getPayload(final String token) { + try { + return Jwts.parserBuilder() + .setSigningKey(key) //키 설정 + .build() + .parseClaimsJws(token)//parse:분석하다, 여기서 토큰이 유효하지 않으면 JwtException이 발생 + .getBody() + .getSubject(); + } catch (JwtException e) { + throw new UnauthorizedException(ErrorCode.INVALID_TOKEN); + } + } +} \ No newline at end of file From 0a0c84bca74edb659a9c5e0e9b07800263d85273 Mon Sep 17 00:00:00 2001 From: juryheed Date: Sat, 20 Jul 2024 03:48:13 +0900 Subject: [PATCH 046/212] =?UTF-8?q?feat:=20TokenResponseDto=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20-=20#14?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/dto/response/TokenResponseDto.java | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/dto/response/TokenResponseDto.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/response/TokenResponseDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/response/TokenResponseDto.java new file mode 100644 index 0000000..6bef615 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/response/TokenResponseDto.java @@ -0,0 +1,10 @@ +package com.hackathonteam1.refreshrator.dto.response; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class TokenResponseDto { + private String AccessToken; +} From b5d2bd23b39c660e9a38a85f31e7f177a8a106a2 Mon Sep 17 00:00:00 2001 From: juryheed Date: Sat, 20 Jul 2024 03:48:55 +0900 Subject: [PATCH 047/212] =?UTF-8?q?feat:=20PasswordHashEncryption=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20-=20#14?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PasswordHashEncryption.java | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/authentication/PasswordHashEncryption.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/authentication/PasswordHashEncryption.java b/src/main/java/com/hackathonteam1/refreshrator/authentication/PasswordHashEncryption.java new file mode 100644 index 0000000..cd469b0 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/authentication/PasswordHashEncryption.java @@ -0,0 +1,47 @@ +package com.hackathonteam1.refreshrator.authentication; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import javax.crypto.SecretKeyFactory; +import javax.crypto.spec.PBEKeySpec; +import java.security.NoSuchAlgorithmException; +import java.security.spec.InvalidKeySpecException; +import java.security.spec.KeySpec; +import java.util.Base64; + +@Component +public class PasswordHashEncryption { + + private static final String PBKDF2_WITH_SHA1 = "PBKDF2WithHmacSHA1"; + + private final String salt;// salt는 암호화할 때 사용하는 임의의 값 + private final int iterationCount;// 반복 횟수(암호화 강도) + private final int keyLength;// 키 길이(암호화된 비밀번호 길이) + + public PasswordHashEncryption(@Value("${encryption.pbkdf2.salt}") final String salt, + @Value("${encryption.pbkdf2.iteration-count}") final int iterationCount, + @Value("${encryption.pbkdf2.key-length}") final int keyLength) { + this.salt = salt; + this.iterationCount = iterationCount; + this.keyLength = keyLength; + } + + public String encrypt(final String plainPassword) { + try { + KeySpec spec = new PBEKeySpec(plainPassword.toCharArray(), salt.getBytes(), iterationCount, keyLength); + SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(PBKDF2_WITH_SHA1); + byte[] encodedPassword = keyFactory.generateSecret(spec) + .getEncoded(); + return Base64.getEncoder() + .withoutPadding() + .encodeToString(encodedPassword); + } catch (NoSuchAlgorithmException | InvalidKeySpecException e) { + throw new RuntimeException("Cannot encrypt password"); + } + } + + public boolean matches(final String plainPassword, final String hashedPassword) { + return encrypt(plainPassword).equals(hashedPassword); + } +} \ No newline at end of file From 784893dcb4e6bbda685d552ca264eca549da0efc Mon Sep 17 00:00:00 2001 From: juryheed Date: Sat, 20 Jul 2024 03:50:24 +0900 Subject: [PATCH 048/212] =?UTF-8?q?feat:=20loginDto=EC=9E=91=EC=84=B1=20-?= =?UTF-8?q?=20#14=20=EC=9D=B4=EB=A9=94=EC=9D=BC=EA=B3=BC=20=EB=B9=84?= =?UTF-8?q?=EB=B0=80=EB=B2=88=ED=98=B8=EB=A1=9C=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8=ED=95=9C=EB=8B=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/dto/request/LoginDto.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/dto/request/LoginDto.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/request/LoginDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/request/LoginDto.java new file mode 100644 index 0000000..e331a6b --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/request/LoginDto.java @@ -0,0 +1,24 @@ +package com.hackathonteam1.refreshrator.dto.request; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.Pattern; +import jakarta.validation.constraints.Size; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class LoginDto { + + //아이디(이메일) + @Pattern(regexp = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{1,100}$", message = "이메일이 형식에 맞지 않습니다.") + @NotBlank(message = "사용하실 아이디(이메일)을 입력해주세요.") + @Size(min = 1,max=100,message = "아이디는 최소 한글자 이상 최대 100글자입니다.") + private String email; + + //비밀번호 + @NotBlank(message = "영문과 숫자,특수기호를 조합하여 8~14글자 미만으로 입력하여 주세요.") + @Pattern(regexp = "^(?=.*[A-Za-z])(?=.*\\d)(?=.*[!@#$%^&*()])[A-Za-z\\d!@#$%^&*()]{8,14}$", message = "영문,숫자,특수기호를 조합하여 8~14글자 미만으로 입력하여 주세요.") + @Size(min = 8, max = 14, message = " 비밀번로는 최소8글자 최대 14글자 입니다.") + private String password; +} From 5f90ddc68029ad5d1839e5d7134df1c6b81e6c8d Mon Sep 17 00:00:00 2001 From: juryheed Date: Sat, 20 Jul 2024 03:52:32 +0900 Subject: [PATCH 049/212] =?UTF-8?q?feat:=20UserRepository=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20-=20#14=20UserRepository=EB=A5=BC=20=EB=A7=8C?= =?UTF-8?q?=EB=93=A4=EA=B3=A0=20=EC=9D=B4=EB=A9=94=EC=9D=BC=EB=A1=9C=20use?= =?UTF-8?q?r=ED=85=8C=EC=9D=B4=EB=B8=94=EC=97=90=EC=84=9C=20=EC=9C=A0?= =?UTF-8?q?=EC=A0=80=EB=A5=BC=20=EC=B0=BE=EB=8A=94=20=EA=B8=B0=EB=8A=A5?= =?UTF-8?q?=EC=9D=84=20=EC=B6=94=EA=B0=80=20=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hackathonteam1/refreshrator/repository/UserRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/repository/UserRepository.java b/src/main/java/com/hackathonteam1/refreshrator/repository/UserRepository.java index bf8a641..5c70d35 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/repository/UserRepository.java +++ b/src/main/java/com/hackathonteam1/refreshrator/repository/UserRepository.java @@ -7,5 +7,5 @@ import java.util.UUID; public interface UserRepository extends JpaRepository { - Optional findByEmail(String email); + User findByEmail(String email); } From 8fba1b5abd526e689e651793530f91a9ab7c0256 Mon Sep 17 00:00:00 2001 From: juryheed Date: Sat, 20 Jul 2024 03:56:05 +0900 Subject: [PATCH 050/212] =?UTF-8?q?feat:=20login=EC=84=9C=EB=B9=84?= =?UTF-8?q?=EC=8A=A4=20=EC=9E=91=EC=84=B1=20-#14=201.=20=ED=9A=8C=EC=9B=90?= =?UTF-8?q?=EA=B0=80=EC=9E=85=20=EC=8B=9C=20=EB=B9=84=EB=B0=80=EB=B2=88?= =?UTF-8?q?=ED=98=B8=EB=A5=BC=20=EC=95=94=ED=98=B8=ED=99=94=20=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD=ED=96=88=EC=9D=8C=202.?= =?UTF-8?q?=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=EC=8B=9C=20=EC=9D=B4=EB=A9=94?= =?UTF-8?q?=EC=9D=BC=EA=B3=BC=20=EB=B9=84=EB=B0=80=EB=B2=88=ED=98=B8?= =?UTF-8?q?=EB=A5=BC=20=EA=B2=80=EC=82=AC=ED=95=A8=203.=20=EC=9D=B4?= =?UTF-8?q?=EB=A9=94=EC=9D=BC=EA=B3=BC=20=EB=B9=84=EB=B0=80=EB=B2=88?= =?UTF-8?q?=ED=98=B8=EC=97=90=20=EB=AC=B8=EC=A0=9C=EA=B0=80=20=EC=97=86?= =?UTF-8?q?=EB=8B=A4=EB=A9=B4=20=ED=86=A0=ED=81=B0=EC=9D=84=20=EB=B0=9C?= =?UTF-8?q?=ED=96=89=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/service/AuthService.java | 41 +++++++++++++++++-- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java b/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java index b95aee8..0d7b3d2 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java @@ -1,8 +1,14 @@ package com.hackathonteam1.refreshrator.service; +import com.hackathonteam1.refreshrator.authentication.JwtTokenProvider; +import com.hackathonteam1.refreshrator.authentication.PasswordHashEncryption; +import com.hackathonteam1.refreshrator.dto.request.LoginDto; import com.hackathonteam1.refreshrator.dto.request.SigninDto; +import com.hackathonteam1.refreshrator.dto.response.TokenResponseDto; import com.hackathonteam1.refreshrator.entity.User; import com.hackathonteam1.refreshrator.exception.ConflictException; +import com.hackathonteam1.refreshrator.exception.ForbiddenException; +import com.hackathonteam1.refreshrator.exception.NotFoundException; import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; import com.hackathonteam1.refreshrator.repository.UserRepository; import lombok.AllArgsConstructor; @@ -12,23 +18,50 @@ @AllArgsConstructor public class AuthService { private final UserRepository userRepository; + private final PasswordHashEncryption passwordHashEncryption; + private final JwtTokenProvider jwtTokenProvider; //회원가입 public void signin(SigninDto signinDto){ //아이디(이메일) 중복 방지 - if(userRepository.findByEmail(signinDto.getEmail()).isPresent()){ + User user=userRepository.findByEmail(signinDto.getEmail()); + if(user!=null){ throw new ConflictException(ErrorCode.DUPLICATED_EMAIL); } //비밀번호 암호화 + String plainPassword = signinDto.getPassword(); + String hashedPassword = passwordHashEncryption.encrypt(plainPassword); //유저 생성과 등록 - User user=User.builder() + User loginUser=User.builder() .name(signinDto.getName()) .email(signinDto.getEmail()) - .password(signinDto.getPassword()) + .password(hashedPassword) .build(); - userRepository.save(user); + userRepository.save(loginUser); + } + + //로그인 + public TokenResponseDto login(LoginDto loginDto){ + + //아이디(이메일)검사 + User user=userRepository.findByEmail(loginDto.getEmail()); + + if(user==null){ + throw new NotFoundException(ErrorCode.USERID_NOT_FOUND); + } + + //비밀번호가 입력한 아이디에 일치하는지 검사 + if(!passwordHashEncryption.matches(loginDto.getPassword(), user.getPassword())){ + throw new ForbiddenException(ErrorCode.INVALID_PASSWORD); + } + + //토큰 생성 + String payload = String.valueOf(user.getId()); + String accessToken = jwtTokenProvider.createToken(payload); + + return new TokenResponseDto(accessToken); } } From a99c5a68e8314e99811792c79534742a77b495ed Mon Sep 17 00:00:00 2001 From: juryheed Date: Sat, 20 Jul 2024 03:57:45 +0900 Subject: [PATCH 051/212] =?UTF-8?q?feat:=20login=EC=BB=A8=ED=8A=B8?= =?UTF-8?q?=EB=A1=A4=EB=9F=AC=20=EC=9E=91=EC=84=B1=20-=20#14=201.=20?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EC=9D=B8=EC=8B=9C=20=EC=A3=BC=EC=86=8C?= =?UTF-8?q?=EB=8A=94=20/auth/login?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/AuthController.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java index 3f8dea2..42d5e2c 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java @@ -1,17 +1,25 @@ package com.hackathonteam1.refreshrator.controller; +import com.hackathonteam1.refreshrator.authentication.AuthenticationExtractor; +import com.hackathonteam1.refreshrator.authentication.JwtEncoder; import com.hackathonteam1.refreshrator.dto.ResponseDto; +import com.hackathonteam1.refreshrator.dto.request.LoginDto; import com.hackathonteam1.refreshrator.dto.request.SigninDto; +import com.hackathonteam1.refreshrator.dto.response.TokenResponseDto; import com.hackathonteam1.refreshrator.service.AuthService; +import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.Valid; import lombok.AllArgsConstructor; import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseCookie; import org.springframework.http.ResponseEntity; 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.time.Duration; + @RestController @AllArgsConstructor @RequestMapping("/auth") @@ -19,6 +27,7 @@ public class AuthController { private final AuthService authService; + //회원가입 @PostMapping("/signin") public ResponseEntity> signup(@RequestBody @Valid SigninDto signinDto) { @@ -26,4 +35,22 @@ public ResponseEntity> signup(@RequestBody @Valid SigninDto si return new ResponseEntity<>(ResponseDto.res(HttpStatus.CREATED, "회원 가입 완료"), HttpStatus.CREATED); } + + //로그인 + @PostMapping("/login") + public ResponseEntity> login(@RequestBody @Valid LoginDto loginDto, HttpServletResponse response) { + + TokenResponseDto tokenResponseDto = authService.login(loginDto); + String bearerToken = JwtEncoder.encodeJwtToken(tokenResponseDto.getAccessToken()); + + ResponseCookie cookie = ResponseCookie.from(AuthenticationExtractor.TOKEN_COOKIE_NAME, bearerToken) + .maxAge(Duration.ofMillis(1800000)) + .path("/") + .httpOnly(true) + .sameSite("None").secure(true) + .build(); + response.addHeader("set-cookie", cookie.toString()); + + return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "로그인 완료"), HttpStatus.OK); + } } From 1bcd82ed72ecb8fb87c01347694d2464cb32e8d6 Mon Sep 17 00:00:00 2001 From: juryheed Date: Sat, 20 Jul 2024 04:00:20 +0900 Subject: [PATCH 052/212] =?UTF-8?q?feat:=20=EC=97=90=EB=9F=AC=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=B6=94=EA=B0=80=20-=20#14=20-=20COOKIE=5FNOT=5FF?= =?UTF-8?q?OUND=20-=20INVALID=5FTOKEN=20-=20INVALID=5FPASSWORD=20-=20USERI?= =?UTF-8?q?D=5FNOT=5FFOUND?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/exception/errorcode/ErrorCode.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java index a917603..1f69a00 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java +++ b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java @@ -15,10 +15,14 @@ public enum ErrorCode { EMAIL("4004", "이메일 형식이 유효하지 않습니다."), //AuthorizedException + COOKIE_NOT_FOUND("4010", "쿠키를 찾을 수 없습니다."), + INVALID_TOKEN("4011", "유효하지 않은 토큰입니다."), + INVALID_PASSWORD("4012","검증되지 않은 비밀번호입니다."), //ForbiddenException //NotFoundException + USERID_NOT_FOUND("4040","존재하지 않는 사용자 입니다"), //ConflictException DUPLICATED_EMAIL("4090", "이미 사용 중인 이메일입니다."); From a2bbbd5514b23765870e8c2c282c28ba3953581b Mon Sep 17 00:00:00 2001 From: jher235 Date: Sat, 20 Jul 2024 10:57:43 +0900 Subject: [PATCH 053/212] =?UTF-8?q?feat:=20interceptor=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20-#14=20=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC=20?= =?UTF-8?q?=EB=B6=80=EB=B6=84=EC=9D=84=20userNotFound=EC=97=90=EC=84=9C=20?= =?UTF-8?q?invalidToken=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{authentication => annotation}/AuthenticatedUser.java | 0 .../config}/AuthenticationConfig.java | 0 .../resolver}/AuthenticatedUserArgumentResolver.java | 0 .../refreshrator/authentication/AuthenticationInterceptor.java | 3 ++- 4 files changed, 2 insertions(+), 1 deletion(-) rename src/main/java/com/hackathonteam1/refreshrator/{authentication => annotation}/AuthenticatedUser.java (100%) rename src/main/java/com/hackathonteam1/refreshrator/{authentication => annotation/config}/AuthenticationConfig.java (100%) rename src/main/java/com/hackathonteam1/refreshrator/{authentication => annotation/resolver}/AuthenticatedUserArgumentResolver.java (100%) diff --git a/src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticatedUser.java b/src/main/java/com/hackathonteam1/refreshrator/annotation/AuthenticatedUser.java similarity index 100% rename from src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticatedUser.java rename to src/main/java/com/hackathonteam1/refreshrator/annotation/AuthenticatedUser.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticationConfig.java b/src/main/java/com/hackathonteam1/refreshrator/annotation/config/AuthenticationConfig.java similarity index 100% rename from src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticationConfig.java rename to src/main/java/com/hackathonteam1/refreshrator/annotation/config/AuthenticationConfig.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticatedUserArgumentResolver.java b/src/main/java/com/hackathonteam1/refreshrator/annotation/resolver/AuthenticatedUserArgumentResolver.java similarity index 100% rename from src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticatedUserArgumentResolver.java rename to src/main/java/com/hackathonteam1/refreshrator/annotation/resolver/AuthenticatedUserArgumentResolver.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticationInterceptor.java b/src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticationInterceptor.java index 87282a1..8b2bc83 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticationInterceptor.java +++ b/src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticationInterceptor.java @@ -2,6 +2,7 @@ import com.hackathonteam1.refreshrator.entity.User; import com.hackathonteam1.refreshrator.exception.NotFoundException; +import com.hackathonteam1.refreshrator.exception.UnauthorizedException; import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; import com.hackathonteam1.refreshrator.repository.UserRepository; import jakarta.servlet.http.HttpServletRequest; @@ -35,6 +36,6 @@ public boolean preHandle(final HttpServletRequest request, private User findExistingUser(final UUID userId) { return userRepository.findById(userId) - .orElseThrow(() -> new NotFoundException(ErrorCode.USERID_NOT_FOUND)); + .orElseThrow(() -> new UnauthorizedException(ErrorCode.INVALID_TOKEN)); } } \ No newline at end of file From 80d69506f9ed9dceca47b931930f02d02878b91d Mon Sep 17 00:00:00 2001 From: jher235 Date: Sat, 20 Jul 2024 11:01:28 +0900 Subject: [PATCH 054/212] =?UTF-8?q?feat:=20JwtEncoder=20=EC=9E=91=EC=84=B1?= =?UTF-8?q?=20-=20#14=20jwt=EC=9D=B8=EC=BD=94=EB=8D=94=EC=97=90=EC=84=9C?= =?UTF-8?q?=20=ED=86=A0=ED=81=B0=EC=9D=84=20BEARER=20=ED=86=A0=ED=81=B0?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EB=B3=80=ED=99=98=ED=95=A0=20=EB=95=8C=20?= =?UTF-8?q?+=EB=A5=BC=20=EA=B3=B5=EB=B0=B1=EC=9C=BC=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=ED=99=98=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hackathonteam1/refreshrator/authentication/JwtEncoder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/authentication/JwtEncoder.java b/src/main/java/com/hackathonteam1/refreshrator/authentication/JwtEncoder.java index 9ba3e81..d664e56 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/authentication/JwtEncoder.java +++ b/src/main/java/com/hackathonteam1/refreshrator/authentication/JwtEncoder.java @@ -14,7 +14,7 @@ public class JwtEncoder { public static String encodeJwtToken(String token){ String cookieValue = TOKEN_TYPE+token; - return URLEncoder.encode(cookieValue, StandardCharsets.UTF_8).replace("\\", "%20"); + return URLEncoder.encode(cookieValue, StandardCharsets.UTF_8).replace("+", "%20"); } public static String decodeJwtBearerToken(String cookieValue){ From 562a108ff753328678552b8e1820f2d85aa1618c Mon Sep 17 00:00:00 2001 From: jher235 Date: Sat, 20 Jul 2024 11:01:45 +0900 Subject: [PATCH 055/212] =?UTF-8?q?feat:=20=ED=8C=A8=ED=82=A4=EC=A7=80=20?= =?UTF-8?q?=EA=B5=AC=EC=A1=B0=20=EC=88=98=EC=A0=95=20-=20#14=20=ED=8C=A8?= =?UTF-8?q?=ED=82=A4=EC=A7=80=EB=A5=BC=20annotation,=20config=EB=A1=9C=20?= =?UTF-8?q?=EC=A2=80=20=EB=8D=94=20=EC=84=B8=EC=84=B8=ED=95=98=EA=B2=8C=20?= =?UTF-8?q?=EB=82=98=EB=88=B4=EC=8A=B5=EB=8B=88=EB=8B=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/annotation/AuthenticatedUser.java | 2 +- .../refreshrator/annotation/config/AuthenticationConfig.java | 4 +++- .../resolver/AuthenticatedUserArgumentResolver.java | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/annotation/AuthenticatedUser.java b/src/main/java/com/hackathonteam1/refreshrator/annotation/AuthenticatedUser.java index 4e56c91..0ede310 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/annotation/AuthenticatedUser.java +++ b/src/main/java/com/hackathonteam1/refreshrator/annotation/AuthenticatedUser.java @@ -1,4 +1,4 @@ -package com.hackathonteam1.refreshrator.authentication; +package com.hackathonteam1.refreshrator.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/src/main/java/com/hackathonteam1/refreshrator/annotation/config/AuthenticationConfig.java b/src/main/java/com/hackathonteam1/refreshrator/annotation/config/AuthenticationConfig.java index 56f48be..4992e3c 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/annotation/config/AuthenticationConfig.java +++ b/src/main/java/com/hackathonteam1/refreshrator/annotation/config/AuthenticationConfig.java @@ -1,5 +1,7 @@ -package com.hackathonteam1.refreshrator.authentication; +package com.hackathonteam1.refreshrator.annotation.config; +import com.hackathonteam1.refreshrator.annotation.resolver.AuthenticatedUserArgumentResolver; +import com.hackathonteam1.refreshrator.authentication.AuthenticationInterceptor; import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Configuration; import org.springframework.web.method.support.HandlerMethodArgumentResolver; diff --git a/src/main/java/com/hackathonteam1/refreshrator/annotation/resolver/AuthenticatedUserArgumentResolver.java b/src/main/java/com/hackathonteam1/refreshrator/annotation/resolver/AuthenticatedUserArgumentResolver.java index bd4a9e5..857825e 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/annotation/resolver/AuthenticatedUserArgumentResolver.java +++ b/src/main/java/com/hackathonteam1/refreshrator/annotation/resolver/AuthenticatedUserArgumentResolver.java @@ -1,5 +1,7 @@ -package com.hackathonteam1.refreshrator.authentication; +package com.hackathonteam1.refreshrator.annotation.resolver; +import com.hackathonteam1.refreshrator.annotation.AuthenticatedUser; +import com.hackathonteam1.refreshrator.authentication.AuthenticationContext; import com.hackathonteam1.refreshrator.entity.User; import lombok.RequiredArgsConstructor; import org.springframework.core.MethodParameter; From dd1bf2c9be5abbf1dbc62ae406fb679c90a5e822 Mon Sep 17 00:00:00 2001 From: juryheed Date: Sat, 20 Jul 2024 17:01:06 +0900 Subject: [PATCH 056/212] =?UTF-8?q?feat:=20=ED=9A=8C=EC=9B=90=EA=B0=80?= =?UTF-8?q?=EC=9E=85=EC=8B=9C=20=EB=83=89=EC=9E=A5=EA=B3=A0=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80=20-=20#16?= =?UTF-8?q?=20-=EC=9C=A0=EC=A0=80=20=EC=83=9D=EC=84=B1=EA=B3=BC=20?= =?UTF-8?q?=EB=93=B1=EB=A1=9D=EC=9D=B4=20=EC=99=84=EB=A3=8C=20=EB=90=98?= =?UTF-8?q?=EB=A9=B4=20=EB=83=89=EC=9E=A5=EA=B3=A0=EB=A5=BC=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=ED=95=9C=EB=8B=A4.=20-=ED=9A=8C=EC=9B=90=EA=B0=80?= =?UTF-8?q?=EC=9E=85=20=EB=A9=94=EC=84=9C=EB=93=9C=EB=A5=BC=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=ED=95=A8=20-=EB=A7=8C=EB=93=A0=20=EB=83=89=EC=9E=90?= =?UTF-8?q?=EA=B3=A0=EB=A5=BC=20FridgeRepositorge=EC=97=90=20=EC=A0=80?= =?UTF-8?q?=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/service/AuthService.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java b/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java index 0d7b3d2..94c2585 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java @@ -5,11 +5,13 @@ import com.hackathonteam1.refreshrator.dto.request.LoginDto; import com.hackathonteam1.refreshrator.dto.request.SigninDto; import com.hackathonteam1.refreshrator.dto.response.TokenResponseDto; +import com.hackathonteam1.refreshrator.entity.Fridge; import com.hackathonteam1.refreshrator.entity.User; import com.hackathonteam1.refreshrator.exception.ConflictException; import com.hackathonteam1.refreshrator.exception.ForbiddenException; import com.hackathonteam1.refreshrator.exception.NotFoundException; import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; +import com.hackathonteam1.refreshrator.repository.FridgeRepository; import com.hackathonteam1.refreshrator.repository.UserRepository; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; @@ -18,6 +20,7 @@ @AllArgsConstructor public class AuthService { private final UserRepository userRepository; + private final FridgeRepository fridgeRepository; private final PasswordHashEncryption passwordHashEncryption; private final JwtTokenProvider jwtTokenProvider; @@ -35,12 +38,18 @@ public void signin(SigninDto signinDto){ String hashedPassword = passwordHashEncryption.encrypt(plainPassword); //유저 생성과 등록 - User loginUser=User.builder() + User signinUser=User.builder() .name(signinDto.getName()) .email(signinDto.getEmail()) .password(hashedPassword) .build(); - userRepository.save(loginUser); + userRepository.save(signinUser); + + //냉장고 생성 + Fridge fridge= Fridge.builder() + .user(signinUser) + .build(); + fridgeRepository.save(fridge); } //로그인 From ca69f65907d9d62e783dbd30034a5d8cce51f146 Mon Sep 17 00:00:00 2001 From: juryheed Date: Sat, 20 Jul 2024 17:06:49 +0900 Subject: [PATCH 057/212] =?UTF-8?q?feat:=20FridgeRepository=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20-=20#16?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/repository/FridgeRepository.java | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/repository/FridgeRepository.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/repository/FridgeRepository.java b/src/main/java/com/hackathonteam1/refreshrator/repository/FridgeRepository.java new file mode 100644 index 0000000..d36304a --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/repository/FridgeRepository.java @@ -0,0 +1,9 @@ +package com.hackathonteam1.refreshrator.repository; + +import com.hackathonteam1.refreshrator.entity.Fridge; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.UUID; + +public interface FridgeRepository extends JpaRepository { +} From d746aafc34a72e98883591b9e8be168e943d6eb3 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sat, 20 Jul 2024 17:44:10 +0900 Subject: [PATCH 058/212] =?UTF-8?q?feat:=20config=20=EA=B2=BD=EB=A1=9C?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20-#9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{annotation => }/config/AuthenticationConfig.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename src/main/java/com/hackathonteam1/refreshrator/{annotation => }/config/AuthenticationConfig.java (92%) diff --git a/src/main/java/com/hackathonteam1/refreshrator/annotation/config/AuthenticationConfig.java b/src/main/java/com/hackathonteam1/refreshrator/config/AuthenticationConfig.java similarity index 92% rename from src/main/java/com/hackathonteam1/refreshrator/annotation/config/AuthenticationConfig.java rename to src/main/java/com/hackathonteam1/refreshrator/config/AuthenticationConfig.java index 4992e3c..a3cf1af 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/annotation/config/AuthenticationConfig.java +++ b/src/main/java/com/hackathonteam1/refreshrator/config/AuthenticationConfig.java @@ -1,4 +1,4 @@ -package com.hackathonteam1.refreshrator.annotation.config; +package com.hackathonteam1.refreshrator.config; import com.hackathonteam1.refreshrator.annotation.resolver.AuthenticatedUserArgumentResolver; import com.hackathonteam1.refreshrator.authentication.AuthenticationInterceptor; @@ -21,7 +21,7 @@ public class AuthenticationConfig implements WebMvcConfigurer { @Override public void addInterceptors(final InterceptorRegistry registry) { registry.addInterceptor(authenticationInterceptor) - .addPathPatterns("/fridge/**") + .addPathPatterns("/fridge/**","/recipes/**") .excludePathPatterns("/auth/signin", "/auth/login","/auth/logout"); } From 5b9d3b3bd8140a7e3dc18738f85bdfd22542b9e1 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sat, 20 Jul 2024 17:45:22 +0900 Subject: [PATCH 059/212] =?UTF-8?q?feat:=20=EC=98=A4=EB=A5=98=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20-#9=20INGREDIENT=5FNOT=5FFOUND=20=EC=98=A4=EB=A5=98?= =?UTF-8?q?=EB=A5=BC=20=EC=B6=94=EA=B0=80=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/exception/errorcode/ErrorCode.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java index 1f69a00..61c706d 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java +++ b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java @@ -23,6 +23,7 @@ public enum ErrorCode { //NotFoundException USERID_NOT_FOUND("4040","존재하지 않는 사용자 입니다"), + INGREDIENT_NOT_FOUND("4041", "재료를 찾을 수 없습니다."), //ConflictException DUPLICATED_EMAIL("4090", "이미 사용 중인 이메일입니다."); From 4f1bd75fb925ae5a86b707dec497620d409d967e Mon Sep 17 00:00:00 2001 From: jher235 Date: Sat, 20 Jul 2024 17:47:29 +0900 Subject: [PATCH 060/212] =?UTF-8?q?feat:=20IngredientRecipeRepository=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20-=20#9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/IngredientRecipeRepository.java | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/repository/IngredientRecipeRepository.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/repository/IngredientRecipeRepository.java b/src/main/java/com/hackathonteam1/refreshrator/repository/IngredientRecipeRepository.java new file mode 100644 index 0000000..630fb28 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/repository/IngredientRecipeRepository.java @@ -0,0 +1,9 @@ +package com.hackathonteam1.refreshrator.repository; + +import com.hackathonteam1.refreshrator.entity.IngredientRecipe; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.UUID; + +public interface IngredientRecipeRepository extends JpaRepository { +} From 1503ea25589d9cd9fe3b33a0984f748df8177511 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sat, 20 Jul 2024 17:47:50 +0900 Subject: [PATCH 061/212] =?UTF-8?q?feat:=20IngredientRepository=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20-=20#9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/repository/IngredientRepository.java | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/repository/IngredientRepository.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/repository/IngredientRepository.java b/src/main/java/com/hackathonteam1/refreshrator/repository/IngredientRepository.java new file mode 100644 index 0000000..4e9f04d --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/repository/IngredientRepository.java @@ -0,0 +1,9 @@ +package com.hackathonteam1.refreshrator.repository; + +import com.hackathonteam1.refreshrator.entity.Ingredient; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.UUID; + +public interface IngredientRepository extends JpaRepository { +} From d498fe0ff66175fa32d13f569c4d642a0717c37c Mon Sep 17 00:00:00 2001 From: jher235 Date: Sat, 20 Jul 2024 17:48:44 +0900 Subject: [PATCH 062/212] =?UTF-8?q?feat:=20RecipeController=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20-=20#9=20register=20=EA=B8=B0=EB=8A=A5=EC=9D=84=20?= =?UTF-8?q?=EB=93=B1=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/RecipeController.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java new file mode 100644 index 0000000..a0ce7b2 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java @@ -0,0 +1,29 @@ +package com.hackathonteam1.refreshrator.controller; + +import com.hackathonteam1.refreshrator.annotation.AuthenticatedUser; +import com.hackathonteam1.refreshrator.dto.ResponseDto; +import com.hackathonteam1.refreshrator.dto.request.recipe.RegisterRecipeDto; +import com.hackathonteam1.refreshrator.entity.User; +import com.hackathonteam1.refreshrator.service.RecipeService; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +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 +@RequiredArgsConstructor +@RequestMapping("/recipes") +public class RecipeController { + private final RecipeService recipeService; + + @PostMapping + public ResponseEntity> register( + @RequestBody RegisterRecipeDto registerRecipeDto, @AuthenticatedUser User user){ + recipeService.register(registerRecipeDto, user); + return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK,"레시피 등록 성공"),HttpStatus.OK); + } + +} From c11a9ab3adcd88f653bf5f618a815e1eeee5875c Mon Sep 17 00:00:00 2001 From: jher235 Date: Sat, 20 Jul 2024 17:49:31 +0900 Subject: [PATCH 063/212] =?UTF-8?q?feat:=20RecipeRepository=20-=20#9=20Jpa?= =?UTF-8?q?Repository=EB=A5=BC=20=EC=83=81=EC=86=8D=EB=B0=9B=EC=9D=80=20Re?= =?UTF-8?q?cipeRepository=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/repository/RecipeRepository.java | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/repository/RecipeRepository.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/repository/RecipeRepository.java b/src/main/java/com/hackathonteam1/refreshrator/repository/RecipeRepository.java new file mode 100644 index 0000000..f55b37b --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/repository/RecipeRepository.java @@ -0,0 +1,9 @@ +package com.hackathonteam1.refreshrator.repository; + +import com.hackathonteam1.refreshrator.entity.Recipe; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.UUID; + +public interface RecipeRepository extends JpaRepository { +} From e1df5ea1aef0289ad8ef85c2f64de6b9ac83711f Mon Sep 17 00:00:00 2001 From: jher235 Date: Sat, 20 Jul 2024 17:50:03 +0900 Subject: [PATCH 064/212] =?UTF-8?q?feat:=20RecipeSerivce=20=EC=9D=B8?= =?UTF-8?q?=ED=84=B0=ED=8E=98=EC=9D=B4=EC=8A=A4=20=EC=9E=91=EC=84=B1=20-?= =?UTF-8?q?=20#9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/service/RecipeService.java | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java new file mode 100644 index 0000000..470b1ce --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java @@ -0,0 +1,11 @@ +package com.hackathonteam1.refreshrator.service; + +import com.hackathonteam1.refreshrator.dto.request.recipe.RegisterRecipeDto; +import com.hackathonteam1.refreshrator.entity.User; +import org.springframework.stereotype.Service; + +public interface RecipeService { + + public void register(RegisterRecipeDto registerRecipeDto, User user); + +} From 005770350cc637ec5d3fe51c6a8de75806ea74c5 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sat, 20 Jul 2024 17:50:22 +0900 Subject: [PATCH 065/212] =?UTF-8?q?feat:=20RecipeSerivce=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84=ED=81=B4=EB=9E=98=EC=8A=A4=20=EC=9E=91=EC=84=B1=20-?= =?UTF-8?q?=20#9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/RecipeServiceImpl.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java new file mode 100644 index 0000000..1efaf70 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java @@ -0,0 +1,50 @@ +package com.hackathonteam1.refreshrator.service; + +import com.hackathonteam1.refreshrator.dto.request.recipe.RegisterRecipeDto; +import com.hackathonteam1.refreshrator.entity.Ingredient; +import com.hackathonteam1.refreshrator.entity.IngredientRecipe; +import com.hackathonteam1.refreshrator.entity.Recipe; +import com.hackathonteam1.refreshrator.entity.User; +import com.hackathonteam1.refreshrator.exception.NotFoundException; +import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; +import com.hackathonteam1.refreshrator.repository.IngredientRecipeRepository; +import com.hackathonteam1.refreshrator.repository.IngredientRepository; +import com.hackathonteam1.refreshrator.repository.RecipeRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.UUID; + +@Service +@RequiredArgsConstructor +public class RecipeServiceImpl implements RecipeService{ + private final RecipeRepository recipeRepository; + private final IngredientRepository ingredientRepository; + private final IngredientRecipeRepository ingredientRecipeRepository; + + @Override + @Transactional + public void register(RegisterRecipeDto registerRecipeDto, User user) { + + System.out.println(user.getEmail()); + Recipe recipe = Recipe.builder() + .name(registerRecipeDto.getName()) + .cookingStep(registerRecipeDto.getCookingStep()) + .user(user) + .build(); + + recipeRepository.save(recipe); + registerRecipeDto.getIngredientIds().stream().forEach(i -> registerRecipeIngredient(findIngredientByIngredientId(i),recipe)); + } + private Ingredient findIngredientByIngredientId(UUID ingredientId){ + return ingredientRepository.findById(ingredientId).orElseThrow(()-> new NotFoundException(ErrorCode.INGREDIENT_NOT_FOUND)); + } + private void registerRecipeIngredient(Ingredient ingredient, Recipe recipe){ + IngredientRecipe ingredientRecipe = IngredientRecipe.builder() + .recipe(recipe) + .ingredient(ingredient) + .build(); + ingredientRecipeRepository.save(ingredientRecipe); + } +} From 654811208c8dee5bbbaac59b5029a5794b1d8d78 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sat, 20 Jul 2024 17:50:47 +0900 Subject: [PATCH 066/212] =?UTF-8?q?feat:=20RegisterRecipeDto=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20-=20#9=20=EB=A0=88=EC=8B=9C=ED=94=BC=20=EB=93=B1?= =?UTF-8?q?=EB=A1=9D=EC=9D=84=20=EC=9C=84=ED=95=9C=20DTO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/recipe/RegisterRecipeDto.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/RegisterRecipeDto.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/RegisterRecipeDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/RegisterRecipeDto.java new file mode 100644 index 0000000..78e494b --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/RegisterRecipeDto.java @@ -0,0 +1,24 @@ +package com.hackathonteam1.refreshrator.dto.request.recipe; + +import com.hackathonteam1.refreshrator.entity.Ingredient; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import lombok.Builder; +import lombok.Getter; + +import java.util.List; +import java.util.UUID; + +@Getter +public class RegisterRecipeDto { + + @Size(min = 1, max = 20) + private String name; + + @NotNull + private List ingredientIds; + + @Size(min = 1) + private String cookingStep; + +} From 246241643a7d290d13da38e26f75b80ca90642b2 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sat, 20 Jul 2024 17:50:54 +0900 Subject: [PATCH 067/212] =?UTF-8?q?feat:=20=ED=8C=A8=ED=82=A4=EC=A7=80=20?= =?UTF-8?q?=EA=B5=AC=EC=A1=B0=20=EC=88=98=EC=A0=95=20-=20#9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/controller/AuthController.java | 6 +++--- .../refreshrator/dto/request/{ => auth}/LoginDto.java | 2 +- .../refreshrator/dto/request/{ => auth}/SigninDto.java | 2 +- .../dto/response/{ => auth}/TokenResponseDto.java | 2 +- .../hackathonteam1/refreshrator/service/AuthService.java | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) rename src/main/java/com/hackathonteam1/refreshrator/dto/request/{ => auth}/LoginDto.java (94%) rename src/main/java/com/hackathonteam1/refreshrator/dto/request/{ => auth}/SigninDto.java (95%) rename src/main/java/com/hackathonteam1/refreshrator/dto/response/{ => auth}/TokenResponseDto.java (72%) diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java index 42d5e2c..02b7c3b 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java @@ -3,9 +3,9 @@ import com.hackathonteam1.refreshrator.authentication.AuthenticationExtractor; import com.hackathonteam1.refreshrator.authentication.JwtEncoder; import com.hackathonteam1.refreshrator.dto.ResponseDto; -import com.hackathonteam1.refreshrator.dto.request.LoginDto; -import com.hackathonteam1.refreshrator.dto.request.SigninDto; -import com.hackathonteam1.refreshrator.dto.response.TokenResponseDto; +import com.hackathonteam1.refreshrator.dto.request.auth.LoginDto; +import com.hackathonteam1.refreshrator.dto.request.auth.SigninDto; +import com.hackathonteam1.refreshrator.dto.response.auth.TokenResponseDto; import com.hackathonteam1.refreshrator.service.AuthService; import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.Valid; diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/request/LoginDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/request/auth/LoginDto.java similarity index 94% rename from src/main/java/com/hackathonteam1/refreshrator/dto/request/LoginDto.java rename to src/main/java/com/hackathonteam1/refreshrator/dto/request/auth/LoginDto.java index e331a6b..6fb0728 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/dto/request/LoginDto.java +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/request/auth/LoginDto.java @@ -1,4 +1,4 @@ -package com.hackathonteam1.refreshrator.dto.request; +package com.hackathonteam1.refreshrator.dto.request.auth; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.Pattern; diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/request/SigninDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/request/auth/SigninDto.java similarity index 95% rename from src/main/java/com/hackathonteam1/refreshrator/dto/request/SigninDto.java rename to src/main/java/com/hackathonteam1/refreshrator/dto/request/auth/SigninDto.java index 7864851..fe9ec7a 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/dto/request/SigninDto.java +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/request/auth/SigninDto.java @@ -1,4 +1,4 @@ -package com.hackathonteam1.refreshrator.dto.request; +package com.hackathonteam1.refreshrator.dto.request.auth; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.Pattern; diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/response/TokenResponseDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/response/auth/TokenResponseDto.java similarity index 72% rename from src/main/java/com/hackathonteam1/refreshrator/dto/response/TokenResponseDto.java rename to src/main/java/com/hackathonteam1/refreshrator/dto/response/auth/TokenResponseDto.java index 6bef615..e7a38c6 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/dto/response/TokenResponseDto.java +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/response/auth/TokenResponseDto.java @@ -1,4 +1,4 @@ -package com.hackathonteam1.refreshrator.dto.response; +package com.hackathonteam1.refreshrator.dto.response.auth; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java b/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java index 0d7b3d2..ce144fd 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java @@ -2,9 +2,9 @@ import com.hackathonteam1.refreshrator.authentication.JwtTokenProvider; import com.hackathonteam1.refreshrator.authentication.PasswordHashEncryption; -import com.hackathonteam1.refreshrator.dto.request.LoginDto; -import com.hackathonteam1.refreshrator.dto.request.SigninDto; -import com.hackathonteam1.refreshrator.dto.response.TokenResponseDto; +import com.hackathonteam1.refreshrator.dto.request.auth.LoginDto; +import com.hackathonteam1.refreshrator.dto.request.auth.SigninDto; +import com.hackathonteam1.refreshrator.dto.response.auth.TokenResponseDto; import com.hackathonteam1.refreshrator.entity.User; import com.hackathonteam1.refreshrator.exception.ConflictException; import com.hackathonteam1.refreshrator.exception.ForbiddenException; From a6e0ee369ff68c55397eb271508865a8f773736a Mon Sep 17 00:00:00 2001 From: jher235 Date: Sat, 20 Jul 2024 19:47:48 +0900 Subject: [PATCH 068/212] =?UTF-8?q?feat:=20=EB=A0=88=EC=8B=9C=ED=94=BC=20?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20=EC=98=A4=EB=A5=98=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20-=20#20=20RECIPE=5FNOT=5FFOUND=EC=99=80=20?= =?UTF-8?q?INGREDIENT=5FRECIPE=5FNOT=5FFOUND=EB=A5=BC=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?=ED=95=A8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/exception/errorcode/ErrorCode.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java index 61c706d..48ac2d5 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java +++ b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java @@ -24,6 +24,8 @@ public enum ErrorCode { //NotFoundException USERID_NOT_FOUND("4040","존재하지 않는 사용자 입니다"), INGREDIENT_NOT_FOUND("4041", "재료를 찾을 수 없습니다."), + RECIPE_NOT_FOUND("4042", "레시피를 찾을 수 없습니다."), + INGREDIENT_RECIPE_NOT_FOUND("4043", "레시피의 재료를 찾을 수 없습니다."), //ConflictException DUPLICATED_EMAIL("4090", "이미 사용 중인 이메일입니다."); From 3147f38a4e7e6ed88a42c75ec48a86ab388a5195 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sat, 20 Jul 2024 19:48:37 +0900 Subject: [PATCH 069/212] =?UTF-8?q?feat:=20IngredientRecipeRepository=20?= =?UTF-8?q?=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94=EA=B0=80=20-=20#20=20?= =?UTF-8?q?=EB=A0=88=EC=8B=9C=ED=94=BC=EB=A1=9C=20=EB=A0=88=EC=8B=9C?= =?UTF-8?q?=ED=94=BC=EC=9D=98=20=EC=9E=AC=EB=A3=8C=EB=93=A4=EC=9D=84=20?= =?UTF-8?q?=EC=B0=BE=EB=8A=94=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/repository/IngredientRecipeRepository.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/repository/IngredientRecipeRepository.java b/src/main/java/com/hackathonteam1/refreshrator/repository/IngredientRecipeRepository.java index 630fb28..5a0feb5 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/repository/IngredientRecipeRepository.java +++ b/src/main/java/com/hackathonteam1/refreshrator/repository/IngredientRecipeRepository.java @@ -1,9 +1,13 @@ package com.hackathonteam1.refreshrator.repository; import com.hackathonteam1.refreshrator.entity.IngredientRecipe; +import com.hackathonteam1.refreshrator.entity.Recipe; import org.springframework.data.jpa.repository.JpaRepository; +import java.util.List; +import java.util.Optional; import java.util.UUID; public interface IngredientRecipeRepository extends JpaRepository { + Optional> findAllByRecipe(Recipe recipe); } From 7ae7d6ffb80756fed88758dba340f57b0a96098d Mon Sep 17 00:00:00 2001 From: jher235 Date: Sat, 20 Jul 2024 19:49:37 +0900 Subject: [PATCH 070/212] =?UTF-8?q?feat:=20=EB=A0=88=EC=8B=9C=ED=94=BC=20?= =?UTF-8?q?=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20-=20#20=20=EB=A0=88=EC=8B=9C=ED=94=BC=20?= =?UTF-8?q?=EB=93=B1=EB=A1=9D=20=EA=B8=B0=EB=8A=A5=20HttpStatus=20OK->CREA?= =?UTF-8?q?TE=EC=9C=BC=EB=A1=9C=20=EC=88=98=EC=A0=95,=20=EB=A0=88=EC=8B=9C?= =?UTF-8?q?=ED=94=BC=20=EC=83=81=EC=84=B8=20=EC=A1=B0=ED=9A=8C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/RecipeController.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java index a0ce7b2..db940f9 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java @@ -3,15 +3,16 @@ import com.hackathonteam1.refreshrator.annotation.AuthenticatedUser; import com.hackathonteam1.refreshrator.dto.ResponseDto; import com.hackathonteam1.refreshrator.dto.request.recipe.RegisterRecipeDto; +import com.hackathonteam1.refreshrator.dto.response.recipe.DetailRecipeDto; import com.hackathonteam1.refreshrator.entity.User; import com.hackathonteam1.refreshrator.service.RecipeService; +import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -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 org.springframework.web.bind.annotation.*; + +import java.util.UUID; @RestController @RequiredArgsConstructor @@ -21,9 +22,15 @@ public class RecipeController { @PostMapping public ResponseEntity> register( - @RequestBody RegisterRecipeDto registerRecipeDto, @AuthenticatedUser User user){ + @RequestBody @Valid RegisterRecipeDto registerRecipeDto, @AuthenticatedUser User user){ recipeService.register(registerRecipeDto, user); - return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK,"레시피 등록 성공"),HttpStatus.OK); + return new ResponseEntity<>(ResponseDto.res(HttpStatus.CREATED,"레시피 등록 성공"),HttpStatus.CREATED); + } + + @GetMapping("/{recipe_id}") + public ResponseEntity> getDetail(@PathVariable("recipe_id") UUID recipeId){ + DetailRecipeDto detailRecipeDto = recipeService.getDetail(recipeId); + return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "레시피 상세 조회 성공", detailRecipeDto),HttpStatus.OK); } } From 4347c339a4cd4990bae12146cb74d9b446685e37 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sat, 20 Jul 2024 19:49:56 +0900 Subject: [PATCH 071/212] =?UTF-8?q?feat:=20=EB=A0=88=EC=8B=9C=ED=94=BC=20?= =?UTF-8?q?=EC=83=81=EC=84=B8=EC=A1=B0=ED=9A=8C=20=EB=B9=84=EC=A6=88?= =?UTF-8?q?=EB=8B=88=EC=8A=A4=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?-=20#20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/service/RecipeService.java | 7 +++++ .../service/RecipeServiceImpl.java | 27 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java index 470b1ce..250b678 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java @@ -1,11 +1,18 @@ package com.hackathonteam1.refreshrator.service; import com.hackathonteam1.refreshrator.dto.request.recipe.RegisterRecipeDto; +import com.hackathonteam1.refreshrator.dto.response.recipe.DetailRecipeDto; import com.hackathonteam1.refreshrator.entity.User; import org.springframework.stereotype.Service; +import java.util.UUID; + public interface RecipeService { + //레시피 등록 public void register(RegisterRecipeDto registerRecipeDto, User user); + //레시피 상세조회 + public DetailRecipeDto getDetail(UUID recipeId); + } diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java index 1efaf70..c5dfc66 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java @@ -1,6 +1,8 @@ package com.hackathonteam1.refreshrator.service; import com.hackathonteam1.refreshrator.dto.request.recipe.RegisterRecipeDto; +import com.hackathonteam1.refreshrator.dto.response.ingredient.IngredientDto; +import com.hackathonteam1.refreshrator.dto.response.recipe.DetailRecipeDto; import com.hackathonteam1.refreshrator.entity.Ingredient; import com.hackathonteam1.refreshrator.entity.IngredientRecipe; import com.hackathonteam1.refreshrator.entity.Recipe; @@ -14,7 +16,10 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; + +import java.util.List; import java.util.UUID; +import java.util.stream.Collectors; @Service @RequiredArgsConstructor @@ -37,9 +42,23 @@ public void register(RegisterRecipeDto registerRecipeDto, User user) { recipeRepository.save(recipe); registerRecipeDto.getIngredientIds().stream().forEach(i -> registerRecipeIngredient(findIngredientByIngredientId(i),recipe)); } + + @Override + public DetailRecipeDto getDetail(UUID recipeId) { + Recipe recipe = findRecipeByRecipeId(recipeId); + List ingredientRecipes = findAllIngredientRecipeByRecipe(recipe); + + List ingredients = ingredientRecipes.stream().map(i->i.getIngredient()).collect(Collectors.toList()); + + DetailRecipeDto detailRecipeDto = DetailRecipeDto.detailRecipeDto(recipe.getName(),ingredients, recipe.getCookingStep()); + + return detailRecipeDto; + } + private Ingredient findIngredientByIngredientId(UUID ingredientId){ return ingredientRepository.findById(ingredientId).orElseThrow(()-> new NotFoundException(ErrorCode.INGREDIENT_NOT_FOUND)); } + private void registerRecipeIngredient(Ingredient ingredient, Recipe recipe){ IngredientRecipe ingredientRecipe = IngredientRecipe.builder() .recipe(recipe) @@ -47,4 +66,12 @@ private void registerRecipeIngredient(Ingredient ingredient, Recipe recipe){ .build(); ingredientRecipeRepository.save(ingredientRecipe); } + + private Recipe findRecipeByRecipeId(UUID recipeId){ + return recipeRepository.findById(recipeId).orElseThrow(()-> new NotFoundException(ErrorCode.RECIPE_NOT_FOUND)); + } + + private List findAllIngredientRecipeByRecipe(Recipe recipe){ + return ingredientRecipeRepository.findAllByRecipe(recipe).orElseThrow(()-> new NotFoundException(ErrorCode.INGREDIENT_RECIPE_NOT_FOUND)); + } } From 87d47609dc49a68d57e7b12c2a451732b538ff48 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sat, 20 Jul 2024 19:50:56 +0900 Subject: [PATCH 072/212] =?UTF-8?q?feat:=20DTO=20=EC=B6=94=EA=B0=80=20-=20?= =?UTF-8?q?#20=20=EC=9E=AC=EB=A3=8C=20DTO,=20=EC=9E=AC=EB=A3=8C=20DTO?= =?UTF-8?q?=EB=A5=BC=20=ED=86=B5=ED=95=9C=20=EB=A0=88=EC=8B=9C=ED=94=BC=20?= =?UTF-8?q?=EC=83=81=EC=84=B8=20=EC=A1=B0=ED=9A=8C=20DTO=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/recipe/RegisterRecipeDto.java | 2 ++ .../response/ingredient/IngredientDto.java | 23 +++++++++++++++++ .../dto/response/recipe/DetailRecipeDto.java | 25 +++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/dto/response/ingredient/IngredientDto.java create mode 100644 src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/DetailRecipeDto.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/RegisterRecipeDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/RegisterRecipeDto.java index 78e494b..a31c2c5 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/RegisterRecipeDto.java +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/RegisterRecipeDto.java @@ -3,6 +3,7 @@ import com.hackathonteam1.refreshrator.entity.Ingredient; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Size; +import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; @@ -10,6 +11,7 @@ import java.util.UUID; @Getter +@AllArgsConstructor public class RegisterRecipeDto { @Size(min = 1, max = 20) diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/response/ingredient/IngredientDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/response/ingredient/IngredientDto.java new file mode 100644 index 0000000..f4c7a43 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/response/ingredient/IngredientDto.java @@ -0,0 +1,23 @@ +package com.hackathonteam1.refreshrator.dto.response.ingredient; + +import com.hackathonteam1.refreshrator.entity.Ingredient; +import lombok.Builder; +import lombok.Getter; + +import java.util.UUID; + +@Builder +@Getter +public class IngredientDto { + + private UUID id; + private String name; + + public static IngredientDto changeToDto(Ingredient ingredient){ + return IngredientDto.builder() + .id(ingredient.getId()) + .name(ingredient.getName()) + .build(); + } + +} diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/DetailRecipeDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/DetailRecipeDto.java new file mode 100644 index 0000000..934da84 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/DetailRecipeDto.java @@ -0,0 +1,25 @@ +package com.hackathonteam1.refreshrator.dto.response.recipe; + +import com.hackathonteam1.refreshrator.dto.response.ingredient.IngredientDto; +import com.hackathonteam1.refreshrator.entity.Ingredient; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; + +import java.util.List; +import java.util.stream.Collectors; + +@Getter +@Builder +@AllArgsConstructor +public class DetailRecipeDto { + private String name; + private List ingredients; + private String cookingStep; + + public static DetailRecipeDto detailRecipeDto(String name, List ingredients, String cookingStep){ + List ingredientDtos = ingredients.stream().map( + i->IngredientDto.changeToDto(i)).collect(Collectors.toList()); + return new DetailRecipeDto(name, ingredientDtos, cookingStep); + } +} From b889e95db7fa6cb1ff2a3a9ad3c5528509deba7e Mon Sep 17 00:00:00 2001 From: jher235 Date: Sat, 20 Jul 2024 19:51:19 +0900 Subject: [PATCH 073/212] =?UTF-8?q?feat:=20Fridge=20=EC=9E=84=ED=8F=AC?= =?UTF-8?q?=ED=8A=B8=20=EC=95=88=EB=90=9C=20=EB=B6=80=EB=B6=84=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80-=20#20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hackathonteam1/refreshrator/service/AuthService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java b/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java index 8bb8400..de06fc1 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java @@ -5,6 +5,7 @@ import com.hackathonteam1.refreshrator.dto.request.auth.LoginDto; import com.hackathonteam1.refreshrator.dto.request.auth.SigninDto; import com.hackathonteam1.refreshrator.dto.response.auth.TokenResponseDto; +import com.hackathonteam1.refreshrator.entity.Fridge; import com.hackathonteam1.refreshrator.entity.User; import com.hackathonteam1.refreshrator.exception.ConflictException; import com.hackathonteam1.refreshrator.exception.ForbiddenException; From ea0406835946c430082741fcd0f2470fd4dfc9e8 Mon Sep 17 00:00:00 2001 From: juryheed Date: Sat, 20 Jul 2024 20:48:18 +0900 Subject: [PATCH 074/212] =?UTF-8?q?feat:=20AddfridgeDto=EC=9E=91=EC=84=B1?= =?UTF-8?q?=20-=20#18=20=EC=9E=AC=EB=A3=8C=20=EB=93=B1=EB=A1=9D=20Dtp?= =?UTF-8?q?=EC=97=90=EB=8A=94=20=EC=9E=AC=EB=A3=8C,=EC=9C=A0=ED=86=B5?= =?UTF-8?q?=EA=B8=B0=ED=95=9C,=EC=88=98=EB=9F=89,=EB=B3=B4=EA=B4=80?= =?UTF-8?q?=EB=B0=A9=EB=B2=95,=EB=A9=94=EB=AA=A8=EA=B0=80=20=EC=9E=88?= =?UTF-8?q?=EB=8B=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/fridge/AddFridgeDto.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/dto/request/fridge/AddFridgeDto.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/request/fridge/AddFridgeDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/request/fridge/AddFridgeDto.java new file mode 100644 index 0000000..262e0d5 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/request/fridge/AddFridgeDto.java @@ -0,0 +1,34 @@ +package com.hackathonteam1.refreshrator.dto.request.fridge; + +import com.hackathonteam1.refreshrator.entity.FridgeItem; +import jakarta.validation.constraints.NotBlank; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.time.LocalDate; +import java.util.UUID; + +@Getter +@AllArgsConstructor +public class AddFridgeDto { + + //재료 + @NotBlank + private UUID ingredient; + + //유통기한 설정 + @NotBlank + private LocalDate expiredDate; + + //수량 설정 + @NotBlank + private int quantity; + + //보관 방법 + @NotBlank + private String storage; + + //메모 + private String memo; + +} From 169a404e277cc3b39a827cda738ffd20dfdb392f Mon Sep 17 00:00:00 2001 From: juryheed Date: Sat, 20 Jul 2024 20:50:07 +0900 Subject: [PATCH 075/212] =?UTF-8?q?feat:=20=EC=95=A0=EB=9F=AC=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=B6=94=EA=B0=80=20-=20#18=20=EB=83=89=EC=9E=A5?= =?UTF-8?q?=EA=B3=A0=EB=A5=BC=20=EC=B0=BE=EC=9D=84=EC=88=98=20=EC=97=86?= =?UTF-8?q?=EC=9D=84=EB=95=8C=20=EC=82=AC=EC=9A=A9=EB=90=98=EB=8A=94=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC=EC=BD=94=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/exception/errorcode/ErrorCode.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java index 48ac2d5..54800bb 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java +++ b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java @@ -26,6 +26,7 @@ public enum ErrorCode { INGREDIENT_NOT_FOUND("4041", "재료를 찾을 수 없습니다."), RECIPE_NOT_FOUND("4042", "레시피를 찾을 수 없습니다."), INGREDIENT_RECIPE_NOT_FOUND("4043", "레시피의 재료를 찾을 수 없습니다."), + FRIDGE_NOT_FOUND("4044","냉장고를 찾을 수 없습니다"), //ConflictException DUPLICATED_EMAIL("4090", "이미 사용 중인 이메일입니다."); From ab6eb2f333a41316ccabb0fd3db9fc8ff495ab92 Mon Sep 17 00:00:00 2001 From: juryheed Date: Sat, 20 Jul 2024 20:51:32 +0900 Subject: [PATCH 076/212] =?UTF-8?q?feat:=20FridgeItem=EC=96=B4=EB=85=B8?= =?UTF-8?q?=ED=85=8C=EC=9D=B4=EC=85=98=20=EC=88=98=EC=A0=95=20-=20#18=20Bu?= =?UTF-8?q?ilder=EC=96=B4=EB=85=B8=ED=85=8C=EC=9D=B4=EC=85=98=EC=9D=84=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hackathonteam1/refreshrator/entity/FridgeItem.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/FridgeItem.java b/src/main/java/com/hackathonteam1/refreshrator/entity/FridgeItem.java index 5f5c703..2d7bfac 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/entity/FridgeItem.java +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/FridgeItem.java @@ -1,10 +1,7 @@ package com.hackathonteam1.refreshrator.entity; import jakarta.persistence.*; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; +import lombok.*; import java.time.LocalDate; @@ -13,6 +10,7 @@ @Setter @AllArgsConstructor @NoArgsConstructor +@Builder public class FridgeItem extends BaseEntity{ @ManyToOne(optional = false, fetch = FetchType.LAZY) From c409f95fee1bdebd61b0e76f1ade0153e7307b6e Mon Sep 17 00:00:00 2001 From: juryheed Date: Sat, 20 Jul 2024 20:53:34 +0900 Subject: [PATCH 077/212] =?UTF-8?q?feat:=20FridgeRepository=EC=97=90=20fin?= =?UTF-8?q?dByUser=EC=9D=84=20=EC=B6=94=EA=B0=80=ED=95=A8=20findByUser?= =?UTF-8?q?=EB=8A=94=20=EC=9C=A0=EC=A0=80=EB=A1=9C=20=EB=83=89=EC=9E=A5?= =?UTF-8?q?=EA=B3=A0=20id=EB=A5=BC=20=EC=B0=BE=EC=9D=84=20=EB=95=8C=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=ED=95=9C=EB=8B=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/repository/FridgeRepository.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/repository/FridgeRepository.java b/src/main/java/com/hackathonteam1/refreshrator/repository/FridgeRepository.java index d36304a..309ce5b 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/repository/FridgeRepository.java +++ b/src/main/java/com/hackathonteam1/refreshrator/repository/FridgeRepository.java @@ -1,9 +1,12 @@ package com.hackathonteam1.refreshrator.repository; import com.hackathonteam1.refreshrator.entity.Fridge; +import com.hackathonteam1.refreshrator.entity.User; import org.springframework.data.jpa.repository.JpaRepository; +import java.util.Optional; import java.util.UUID; public interface FridgeRepository extends JpaRepository { + Optional findByUser(User user); } From 231c5d0021cd5c8a5c2c93e6f39737151d62a41d Mon Sep 17 00:00:00 2001 From: juryheed Date: Sat, 20 Jul 2024 20:54:55 +0900 Subject: [PATCH 078/212] =?UTF-8?q?feat:=20FridgeItemRepository=20?= =?UTF-8?q?=EB=A7=8C=EB=93=AC=20-=20#18?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/repository/FridgeItemRepository.java | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/repository/FridgeItemRepository.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/repository/FridgeItemRepository.java b/src/main/java/com/hackathonteam1/refreshrator/repository/FridgeItemRepository.java new file mode 100644 index 0000000..58e2ff5 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/repository/FridgeItemRepository.java @@ -0,0 +1,9 @@ +package com.hackathonteam1.refreshrator.repository; + +import com.hackathonteam1.refreshrator.entity.FridgeItem; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.UUID; + +public interface FridgeItemRepository extends JpaRepository { +} From 84d78c97e0a42ea4867dd1e889c700c43d3e63ac Mon Sep 17 00:00:00 2001 From: juryheed Date: Sat, 20 Jul 2024 20:57:11 +0900 Subject: [PATCH 079/212] =?UTF-8?q?feat:=20=EB=83=89=EC=9E=A5=EA=B3=A0?= =?UTF-8?q?=EC=97=90=20=EC=9E=AC=EB=A3=8C=EB=A5=BC=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EB=B9=84=EC=8A=A4=EB=8B=88=EC=8A=A4=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=9E=91=EC=84=B1=20-=20#18=20-FridgeServ?= =?UTF-8?q?ise=EC=97=90=20addIngredientInFridge=EB=A5=BC=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/service/FridgeService.java | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java b/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java new file mode 100644 index 0000000..c313484 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java @@ -0,0 +1,57 @@ +package com.hackathonteam1.refreshrator.service; + +import com.hackathonteam1.refreshrator.dto.request.fridge.AddFridgeDto; +import com.hackathonteam1.refreshrator.entity.Fridge; +import com.hackathonteam1.refreshrator.entity.FridgeItem; +import com.hackathonteam1.refreshrator.entity.Ingredient; +import com.hackathonteam1.refreshrator.entity.User; +import com.hackathonteam1.refreshrator.exception.NotFoundException; +import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; +import com.hackathonteam1.refreshrator.repository.FridgeItemRepository; +import com.hackathonteam1.refreshrator.repository.FridgeRepository; +import com.hackathonteam1.refreshrator.repository.IngredientRepository; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.UUID; + +@Service +@AllArgsConstructor +public class FridgeService { + private IngredientRepository ingredientRepository; + private FridgeItemRepository fridgeItemRepository; + private FridgeRepository fridgeRepository; + + //냉장고에 재료 추가 + public void addIngredientInFridge(AddFridgeDto addFridgeDto, User user){ + + //재료 찾기 + Ingredient ingredient=ingredientRepository.findById(addFridgeDto.getIngredient()) + .orElseThrow(()-> new NotFoundException(ErrorCode.INGREDIENT_NOT_FOUND)); + + //냉장고 찾기 + Fridge fridge=fridgeRepository.findByUser(user) + .orElseThrow(()-> new NotFoundException(ErrorCode.FRIDGE_NOT_FOUND)); + + //재료 정보 입력 + FridgeItem fridgeItem=FridgeItem.builder() + .fridge(fridge) + .ingredient(ingredient) + .expiredDate(addFridgeDto.getExpiredDate()) + .quantity(addFridgeDto.getQuantity()) + .storage(findStorage(addFridgeDto.getStorage())) + .memo(addFridgeDto.getMemo()) + .build(); + + //재료를 냉장고에 저장 + fridgeItemRepository.save(fridgeItem); + } + + private FridgeItem.Storage findStorage(String storage){ + return switch (storage){ + case "상온"-> FridgeItem.Storage.STORE_AT_ROOM_TEMPERATURE; + case "냉동"-> FridgeItem.Storage.FROZEN; + default -> FridgeItem.Storage.REFRIGERATED; + }; + } +} From 4dcabe1f67c5c2d9c8a39e3baa8d3cfa363c18df Mon Sep 17 00:00:00 2001 From: juryheed Date: Sat, 20 Jul 2024 20:59:34 +0900 Subject: [PATCH 080/212] =?UTF-8?q?feat:=20=EB=83=89=EC=9E=A5=EA=B3=A0?= =?UTF-8?q?=EC=97=90=20=EC=9E=AC=EB=A3=8C=EB=A5=BC=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1=20-=20#18=20-=20=EA=B2=BD=EB=A1=9C=EB=8A=94?= =?UTF-8?q?=20/fridge/ingredients=20-=20fridgeService=EC=9D=98=20addIngred?= =?UTF-8?q?ientInFridge=EB=A5=BC=20=EC=82=AC=EC=9A=A9=20-=20=EC=A0=95?= =?UTF-8?q?=EC=83=81=EC=A0=81=EC=9C=BC=EB=A1=9C=20=EC=9E=91=EB=8F=99=20?= =?UTF-8?q?=EC=99=84=EB=A3=8C=EC=8B=9C=20"=EB=83=89=EC=9E=A5=EA=B3=A0?= =?UTF-8?q?=EC=97=90=20=EC=9E=AC=EB=A3=8C=20=EB=93=B1=EB=A1=9D=20=EC=84=B1?= =?UTF-8?q?=EA=B3=B5"=20=EB=AC=B8=EA=B5=AC=EA=B0=80=20=EC=B6=9C=EB=A0=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/FridgeController.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java new file mode 100644 index 0000000..3c2443b --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java @@ -0,0 +1,29 @@ +package com.hackathonteam1.refreshrator.controller; + +import com.hackathonteam1.refreshrator.annotation.AuthenticatedUser; +import com.hackathonteam1.refreshrator.dto.ResponseDto; +import com.hackathonteam1.refreshrator.dto.request.fridge.AddFridgeDto; +import com.hackathonteam1.refreshrator.entity.User; +import com.hackathonteam1.refreshrator.service.FridgeService; +import lombok.AllArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +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 +@AllArgsConstructor +@RequestMapping("/fridge") +public class FridgeController { + + private final FridgeService fridgeService; + + //냉장고에 재료 추가 + @PostMapping("/ingredients") + public ResponseEntity> addIngredientInFridge(@RequestBody AddFridgeDto addFridgeDto , @AuthenticatedUser User user){ + fridgeService.addIngredientInFridge(addFridgeDto,user); + return new ResponseEntity<>(ResponseDto.res(HttpStatus.CREATED,"냉장고에 재료 등록 성공"),HttpStatus.CREATED); + } +} From 96fe1e270ad702d04193b33eed9b8cfbc2a0c40f Mon Sep 17 00:00:00 2001 From: juryheed Date: Sat, 20 Jul 2024 21:25:15 +0900 Subject: [PATCH 081/212] =?UTF-8?q?fix:=20=EC=96=B4=EB=85=B8=ED=85=8C?= =?UTF-8?q?=EC=9D=B4=EC=85=98=20=EB=B3=80=EA=B2=BD=20-=20#18=20-=20NotBlan?= =?UTF-8?q?k=EC=97=90=EC=84=9C=20NotNull=EB=A1=9C=20=EB=B3=80=EA=B2=BD=20-?= =?UTF-8?q?=20quantity=EB=A5=BC=20int=20=EC=97=90=EC=84=9C=20Integer?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/dto/request/fridge/AddFridgeDto.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/request/fridge/AddFridgeDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/request/fridge/AddFridgeDto.java index 262e0d5..1c88f35 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/dto/request/fridge/AddFridgeDto.java +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/request/fridge/AddFridgeDto.java @@ -2,6 +2,7 @@ import com.hackathonteam1.refreshrator.entity.FridgeItem; import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Getter; @@ -13,19 +14,19 @@ public class AddFridgeDto { //재료 - @NotBlank + @NotNull private UUID ingredient; //유통기한 설정 - @NotBlank + @NotNull private LocalDate expiredDate; //수량 설정 - @NotBlank - private int quantity; + @NotNull + private Integer quantity; //보관 방법 - @NotBlank + @NotNull private String storage; //메모 From 60055f0b612e092ff6c42497b77569ae2c847a2f Mon Sep 17 00:00:00 2001 From: jher235 Date: Sat, 20 Jul 2024 21:39:21 +0900 Subject: [PATCH 082/212] =?UTF-8?q?refactor:=20=EC=98=88=EC=99=B8=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=20=EB=88=84=EB=9D=BD=20=EB=B6=80=EB=B6=84=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EB=B0=8F=20=EC=88=98=EC=A0=95=20notNull=20validati?= =?UTF-8?q?on=EC=B6=94=EA=B0=80,=20=EC=98=88=EC=83=81=20=EB=B6=88=EA=B0=80?= =?UTF-8?q?=ED=95=9C=20=EC=98=A4=EB=A5=98=20=EC=B2=98=EB=A6=AC=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/advice/ExceptionController.java | 15 +++++++++++++-- .../exception/errorcode/ErrorCode.java | 2 ++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/exception/advice/ExceptionController.java b/src/main/java/com/hackathonteam1/refreshrator/exception/advice/ExceptionController.java index 5f17161..af2f5a0 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/exception/advice/ExceptionController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/exception/advice/ExceptionController.java @@ -13,6 +13,7 @@ import org.springframework.validation.FieldError; import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestControllerAdvice; @Slf4j @@ -21,12 +22,12 @@ public class ExceptionController { @ExceptionHandler(CustomException.class) public ResponseEntity handleCustomException(CustomException customException){ - writeLog(customException); + writeLog(customException); HttpStatus httpStatus = this.resolveHttpStatus(customException); return new ResponseEntity<>(ErrorResponseDto.res(customException), httpStatus); } - @ExceptionHandler({ValidationException.class, MetaDataAccessException.class}) + @ExceptionHandler({ValidationException.class, MethodArgumentNotValidException.class}) public ResponseEntity handleCustomException(MethodArgumentNotValidException methodArgumentNotValidException){ FieldError fieldError = methodArgumentNotValidException.getBindingResult().getFieldError(); if(fieldError == null){ @@ -46,6 +47,16 @@ public ResponseEntity handleEntityNotFoundException(EntityNotF return new ResponseEntity<>(ErrorResponseDto.res(String.valueOf(HttpStatus.NOT_FOUND.value()),entityNotFoundException), HttpStatus.NOT_FOUND); } + @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) + @ExceptionHandler(Exception.class) + public ResponseEntity handleExceptioon(Exception exception){ + this.writeLog(exception); + return new ResponseEntity<>( + ErrorResponseDto.res(String.valueOf(HttpStatus.INTERNAL_SERVER_ERROR.value()), exception), + HttpStatus.INTERNAL_SERVER_ERROR + ); + } + private void writeLog(CustomException customException){ String exceptionName = customException.getClass().getSimpleName(); ErrorCode errorCode = customException.getErrorCode(); diff --git a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java index 48ac2d5..b3f6c3b 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java +++ b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java @@ -13,6 +13,7 @@ public enum ErrorCode { NOT_BLANK("4002", "필수값이 공백입니다."), LENGTH("4003", "길이가 유효하지 않습니다."), EMAIL("4004", "이메일 형식이 유효하지 않습니다."), + NOT_NULL("4005", "필수값이 공백입니다."), //AuthorizedException COOKIE_NOT_FOUND("4010", "쿠키를 찾을 수 없습니다."), @@ -41,6 +42,7 @@ public static ErrorCode resolveValidationErrorCode(String code){ case "NotBlank" -> NOT_BLANK; case "Length" -> LENGTH; case "Email" -> EMAIL; + case "NotNull" -> NOT_NULL; default -> throw new IllegalArgumentException("Unexpected value: "+ code); }; } From f08f5b026db4742046f5f362cc10c717bc50b4dc Mon Sep 17 00:00:00 2001 From: juryheed Date: Sat, 20 Jul 2024 21:48:33 +0900 Subject: [PATCH 083/212] =?UTF-8?q?refactor:=20=EB=B3=80=EC=88=98=EB=AA=85?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD=20-=20#18=20-ingredient=EC=97=90=EC=84=9C?= =?UTF-8?q?=20ingredientId=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/controller/FridgeController.java | 4 +++- .../refreshrator/dto/request/fridge/AddFridgeDto.java | 2 +- .../hackathonteam1/refreshrator/service/FridgeService.java | 4 +--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java index 3c2443b..042bea2 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java @@ -5,7 +5,9 @@ import com.hackathonteam1.refreshrator.dto.request.fridge.AddFridgeDto; import com.hackathonteam1.refreshrator.entity.User; import com.hackathonteam1.refreshrator.service.FridgeService; +import jakarta.validation.Valid; import lombok.AllArgsConstructor; +import lombok.Value; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PostMapping; @@ -22,7 +24,7 @@ public class FridgeController { //냉장고에 재료 추가 @PostMapping("/ingredients") - public ResponseEntity> addIngredientInFridge(@RequestBody AddFridgeDto addFridgeDto , @AuthenticatedUser User user){ + public ResponseEntity> addIngredientInFridge(@RequestBody @Valid AddFridgeDto addFridgeDto , @AuthenticatedUser User user){ fridgeService.addIngredientInFridge(addFridgeDto,user); return new ResponseEntity<>(ResponseDto.res(HttpStatus.CREATED,"냉장고에 재료 등록 성공"),HttpStatus.CREATED); } diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/request/fridge/AddFridgeDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/request/fridge/AddFridgeDto.java index 1c88f35..b280c84 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/dto/request/fridge/AddFridgeDto.java +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/request/fridge/AddFridgeDto.java @@ -15,7 +15,7 @@ public class AddFridgeDto { //재료 @NotNull - private UUID ingredient; + private UUID ingredientId; //유통기한 설정 @NotNull diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java b/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java index c313484..3e6306b 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java @@ -13,8 +13,6 @@ import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; -import java.util.UUID; - @Service @AllArgsConstructor public class FridgeService { @@ -26,7 +24,7 @@ public class FridgeService { public void addIngredientInFridge(AddFridgeDto addFridgeDto, User user){ //재료 찾기 - Ingredient ingredient=ingredientRepository.findById(addFridgeDto.getIngredient()) + Ingredient ingredient=ingredientRepository.findById(addFridgeDto.getIngredientId()) .orElseThrow(()-> new NotFoundException(ErrorCode.INGREDIENT_NOT_FOUND)); //냉장고 찾기 From f0ac22cd86463c6ff9bf3b55b5236106a0d6cd69 Mon Sep 17 00:00:00 2001 From: juryheed Date: Sat, 20 Jul 2024 21:52:30 +0900 Subject: [PATCH 084/212] =?UTF-8?q?refactor:=20=EB=A9=94=EC=86=8C=EB=93=9C?= =?UTF-8?q?=EB=AA=85=20=EB=B3=80=EA=B2=BD=20-=20#18=20-=20findStorage?= =?UTF-8?q?=EC=97=90=EC=84=9C=20defindStorage=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hackathonteam1/refreshrator/service/FridgeService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java b/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java index 3e6306b..cde8d52 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java @@ -37,7 +37,7 @@ public void addIngredientInFridge(AddFridgeDto addFridgeDto, User user){ .ingredient(ingredient) .expiredDate(addFridgeDto.getExpiredDate()) .quantity(addFridgeDto.getQuantity()) - .storage(findStorage(addFridgeDto.getStorage())) + .storage(defindStorage(addFridgeDto.getStorage())) .memo(addFridgeDto.getMemo()) .build(); @@ -45,7 +45,7 @@ public void addIngredientInFridge(AddFridgeDto addFridgeDto, User user){ fridgeItemRepository.save(fridgeItem); } - private FridgeItem.Storage findStorage(String storage){ + private FridgeItem.Storage defindStorage(String storage){ return switch (storage){ case "상온"-> FridgeItem.Storage.STORE_AT_ROOM_TEMPERATURE; case "냉동"-> FridgeItem.Storage.FROZEN; From a0ee1a5bded04590025c3f275137be83b7c9b641 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 21 Jul 2024 01:14:28 +0900 Subject: [PATCH 085/212] =?UTF-8?q?feat:=20=EA=B6=8C=ED=95=9C=20=EC=97=90?= =?UTF-8?q?=EB=9F=AC=EC=BD=94=EB=93=9C=20=EC=B6=94=EA=B0=80=20-=20#20=20?= =?UTF-8?q?=EA=B6=8C=ED=95=9C=EC=9D=B4=20=EC=97=86=EC=9D=84=20=EA=B2=BD?= =?UTF-8?q?=EC=9A=B0=20=EB=B0=9C=EC=83=9D=ED=95=98=EB=8A=94=20RECIPE=5FFOR?= =?UTF-8?q?BIDDEN=20=EC=97=90=EB=9F=AC=20=EC=B6=94=EA=B0=80.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/exception/errorcode/ErrorCode.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java index 2c251c6..c445da4 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java +++ b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java @@ -21,6 +21,7 @@ public enum ErrorCode { INVALID_PASSWORD("4012","검증되지 않은 비밀번호입니다."), //ForbiddenException + RECIPE_FORBIDDEN("4030","해당 레시피에 대한 권한이 없습니다."), //NotFoundException USERID_NOT_FOUND("4040","존재하지 않는 사용자 입니다"), From 3d97855b73b010ef3236aa1da285c22a7432e8ef Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 21 Jul 2024 01:15:07 +0900 Subject: [PATCH 086/212] =?UTF-8?q?feat:=20Recipe=20=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=20=EB=82=B4=EB=B6=80=EC=97=90=20=ED=95=84=EB=93=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20-=20#20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hackathonteam1/refreshrator/entity/Recipe.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/Recipe.java b/src/main/java/com/hackathonteam1/refreshrator/entity/Recipe.java index d4a3911..9b29fcc 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/entity/Recipe.java +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/Recipe.java @@ -29,4 +29,11 @@ public class Recipe extends BaseEntity{ @JoinColumn(name = "image_id") private Image image; + public void updateName(String name){ + this.name = name; + } + public void updateCookingStep(String cookingStep){ + this.cookingStep = cookingStep; + } + } From 39f6121a7ca7c94e8622f71d6bed67a8681d3109 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 21 Jul 2024 01:15:41 +0900 Subject: [PATCH 087/212] =?UTF-8?q?feat:=20=EB=A0=88=EC=8B=9C=ED=94=BC?= =?UTF-8?q?=EB=AA=85,=20=EC=A1=B0=EB=A6=AC=EB=B2=95=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=EC=9D=84=20=EC=9C=84=ED=95=9C=20=EC=BB=A8=ED=8A=B8=EB=A1=A4?= =?UTF-8?q?=EB=9F=AC=20=EC=B6=94=EA=B0=80=20-=20#20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/controller/RecipeController.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java index db940f9..48dd984 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java @@ -2,6 +2,7 @@ import com.hackathonteam1.refreshrator.annotation.AuthenticatedUser; import com.hackathonteam1.refreshrator.dto.ResponseDto; +import com.hackathonteam1.refreshrator.dto.request.recipe.ModifyRecipeDto; import com.hackathonteam1.refreshrator.dto.request.recipe.RegisterRecipeDto; import com.hackathonteam1.refreshrator.dto.response.recipe.DetailRecipeDto; import com.hackathonteam1.refreshrator.entity.User; @@ -33,4 +34,12 @@ public ResponseEntity> getDetail(@PathVariable("rec return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "레시피 상세 조회 성공", detailRecipeDto),HttpStatus.OK); } + @PatchMapping("/{recipe_id}") + public ResponseEntity> modify( + @RequestBody @Valid ModifyRecipeDto modifyRecipeDto, @AuthenticatedUser User user, @PathVariable("recipe_id") UUID recipeId){ + recipeService.modifyContent(modifyRecipeDto, user, recipeId); + return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK,"레시피 수정 성공"),HttpStatus.OK); + } + + } From 967dc7ee03c599dece29f61094db65671ae3cf16 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 21 Jul 2024 01:16:37 +0900 Subject: [PATCH 088/212] =?UTF-8?q?feat:=20=EB=A0=88=EC=8B=9C=ED=94=BC?= =?UTF-8?q?=EB=AA=85,=20=EC=A1=B0=EB=A6=AC=EB=B2=95=EC=9D=84=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=ED=95=98=EB=8A=94=20=EB=B9=84=EC=A6=88=EB=8B=88?= =?UTF-8?q?=EC=8A=A4=20=EB=A1=9C=EC=A7=81=20=EC=9E=91=EC=84=B1=20-=20#20?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80=EB=A1=9C=20=EC=84=A4=EB=AA=85=EC=9A=A9=20?= =?UTF-8?q?=EC=A3=BC=EC=84=9D=20=EC=B6=94=EA=B0=80,=20=EA=B6=8C=ED=95=9C?= =?UTF-8?q?=20=ED=99=95=EC=9D=B8=ED=95=98=EB=8A=94=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/service/RecipeService.java | 3 ++ .../service/RecipeServiceImpl.java | 29 +++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java index 250b678..453ce20 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java @@ -1,5 +1,6 @@ package com.hackathonteam1.refreshrator.service; +import com.hackathonteam1.refreshrator.dto.request.recipe.ModifyRecipeDto; import com.hackathonteam1.refreshrator.dto.request.recipe.RegisterRecipeDto; import com.hackathonteam1.refreshrator.dto.response.recipe.DetailRecipeDto; import com.hackathonteam1.refreshrator.entity.User; @@ -15,4 +16,6 @@ public interface RecipeService { //레시피 상세조회 public DetailRecipeDto getDetail(UUID recipeId); + public void modifyContent(ModifyRecipeDto modifyRecipeDto, User user, UUID recipeId); + } diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java index c5dfc66..1e4811f 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java @@ -1,12 +1,13 @@ package com.hackathonteam1.refreshrator.service; +import com.hackathonteam1.refreshrator.dto.request.recipe.ModifyRecipeDto; import com.hackathonteam1.refreshrator.dto.request.recipe.RegisterRecipeDto; -import com.hackathonteam1.refreshrator.dto.response.ingredient.IngredientDto; import com.hackathonteam1.refreshrator.dto.response.recipe.DetailRecipeDto; import com.hackathonteam1.refreshrator.entity.Ingredient; import com.hackathonteam1.refreshrator.entity.IngredientRecipe; import com.hackathonteam1.refreshrator.entity.Recipe; import com.hackathonteam1.refreshrator.entity.User; +import com.hackathonteam1.refreshrator.exception.ForbiddenException; import com.hackathonteam1.refreshrator.exception.NotFoundException; import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; import com.hackathonteam1.refreshrator.repository.IngredientRecipeRepository; @@ -32,7 +33,6 @@ public class RecipeServiceImpl implements RecipeService{ @Transactional public void register(RegisterRecipeDto registerRecipeDto, User user) { - System.out.println(user.getEmail()); Recipe recipe = Recipe.builder() .name(registerRecipeDto.getName()) .cookingStep(registerRecipeDto.getCookingStep()) @@ -43,6 +43,7 @@ public void register(RegisterRecipeDto registerRecipeDto, User user) { registerRecipeDto.getIngredientIds().stream().forEach(i -> registerRecipeIngredient(findIngredientByIngredientId(i),recipe)); } + //상세조회 @Override public DetailRecipeDto getDetail(UUID recipeId) { Recipe recipe = findRecipeByRecipeId(recipeId); @@ -55,10 +56,27 @@ public DetailRecipeDto getDetail(UUID recipeId) { return detailRecipeDto; } + //레시피명, 조리법 수정 + @Override + public void modifyContent(ModifyRecipeDto modifyRecipeDto, User user, UUID recipeId) { + Recipe recipe = findRecipeByRecipeId(recipeId); + checkAuth(recipe.getUser(), user); + + if(modifyRecipeDto.getName()!=null){ + recipe.updateName(modifyRecipeDto.getName()); + } + if(modifyRecipeDto.getCookingStep()!=null) { + recipe.updateCookingStep(modifyRecipeDto.getCookingStep()); + } + + recipeRepository.save(recipe); + } + private Ingredient findIngredientByIngredientId(UUID ingredientId){ return ingredientRepository.findById(ingredientId).orElseThrow(()-> new NotFoundException(ErrorCode.INGREDIENT_NOT_FOUND)); } + //RecipeIngredient를 등록하는 메서드 private void registerRecipeIngredient(Ingredient ingredient, Recipe recipe){ IngredientRecipe ingredientRecipe = IngredientRecipe.builder() .recipe(recipe) @@ -74,4 +92,11 @@ private Recipe findRecipeByRecipeId(UUID recipeId){ private List findAllIngredientRecipeByRecipe(Recipe recipe){ return ingredientRecipeRepository.findAllByRecipe(recipe).orElseThrow(()-> new NotFoundException(ErrorCode.INGREDIENT_RECIPE_NOT_FOUND)); } + + //권한 확인 + private void checkAuth(User writer, User user){ + if(!writer.getId().equals(user.getId())){ + throw new ForbiddenException(ErrorCode.RECIPE_FORBIDDEN); + } + } } From ebbf29c1a1f8d925aeead11a0b6b3f853964810f Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 21 Jul 2024 01:18:35 +0900 Subject: [PATCH 089/212] =?UTF-8?q?feat:=20=EB=A0=88=EC=8B=9C=ED=94=BC?= =?UTF-8?q?=EB=AA=85,=20=EC=A1=B0=EB=A6=AC=EB=B2=95=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=EC=9A=A9=20Dto=20=EC=B6=94=EA=B0=80=20-=20#20=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=EB=A1=9C=20=EB=A0=88=EC=8B=9C=ED=94=BC=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1Dto=20=ED=95=84=EB=93=9C=EC=97=90=20@notblank=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/recipe/ModifyRecipeDto.java | 20 +++++++++++++++++++ .../dto/request/recipe/RegisterRecipeDto.java | 3 +++ 2 files changed, 23 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/ModifyRecipeDto.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/ModifyRecipeDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/ModifyRecipeDto.java new file mode 100644 index 0000000..7ecfc4c --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/ModifyRecipeDto.java @@ -0,0 +1,20 @@ +package com.hackathonteam1.refreshrator.dto.request.recipe; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@AllArgsConstructor +@NoArgsConstructor +public class ModifyRecipeDto { + + @Size(min = 1, max = 20) + private String name; + + @Size(min = 1) + private String cookingStep; +} diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/RegisterRecipeDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/RegisterRecipeDto.java index a31c2c5..33f942c 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/RegisterRecipeDto.java +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/RegisterRecipeDto.java @@ -1,6 +1,7 @@ package com.hackathonteam1.refreshrator.dto.request.recipe; import com.hackathonteam1.refreshrator.entity.Ingredient; +import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Size; import lombok.AllArgsConstructor; @@ -15,12 +16,14 @@ public class RegisterRecipeDto { @Size(min = 1, max = 20) + @NotBlank private String name; @NotNull private List ingredientIds; @Size(min = 1) + @NotBlank private String cookingStep; } From 278cd315d5f2887198d936d46d08546bff46464e Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 21 Jul 2024 02:28:10 +0900 Subject: [PATCH 090/212] =?UTF-8?q?feat:=20=EC=9D=B4=EB=AF=B8=20=EC=A1=B4?= =?UTF-8?q?=EC=9E=AC=ED=95=98=EB=8A=94=20=EC=9E=AC=EB=A3=8C=EB=A5=BC=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=ED=95=A0=20=EA=B2=BD=EC=9A=B0=20=EB=B0=9C?= =?UTF-8?q?=EC=83=9D=ED=95=98=EB=8A=94=20=EC=B6=A9=EB=8F=8C=20=EC=97=90?= =?UTF-8?q?=EB=9F=AC=EC=BD=94=EB=93=9C=20=EC=B6=94=EA=B0=80=20-=20#27=20?= =?UTF-8?q?=EC=9D=B4=EB=AF=B8=20=EB=A0=88=EC=8B=9C=ED=94=BC=EC=97=90=20?= =?UTF-8?q?=EC=A1=B4=EC=9E=AC=ED=95=98=EB=8A=94=20=EC=9E=AC=EB=A3=8C?= =?UTF-8?q?=EB=A5=BC=20=EC=B6=94=EA=B0=80=ED=95=98=EB=A0=A4=20=ED=95=A0=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20RECIPE=5FINGREDIENT=5FCONFLICT=20=EB=B0=9C?= =?UTF-8?q?=EC=83=9D.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/exception/errorcode/ErrorCode.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java index c445da4..a25a9a6 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java +++ b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java @@ -1,5 +1,6 @@ package com.hackathonteam1.refreshrator.exception.errorcode; +import com.hackathonteam1.refreshrator.entity.Recipe; import lombok.AllArgsConstructor; import lombok.Getter; @@ -31,7 +32,8 @@ public enum ErrorCode { FRIDGE_NOT_FOUND("4044","냉장고를 찾을 수 없습니다"), //ConflictException - DUPLICATED_EMAIL("4090", "이미 사용 중인 이메일입니다."); + DUPLICATED_EMAIL("4090", "이미 사용 중인 이메일입니다."), + RECIPE_INGREDIENT_CONFLICT("4091", "이미 해당 레시피에 존재하는 재료입니다."); private final String code; From 56d458f433bcbaa25ea0dab21d114d14c645a1f2 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 21 Jul 2024 02:29:01 +0900 Subject: [PATCH 091/212] =?UTF-8?q?feat:=20=EB=A0=88=EC=8B=9C=ED=94=BC?= =?UTF-8?q?=EC=97=90=20=EC=9E=AC=EB=A3=8C=20=EC=B6=94=EA=B0=80=EB=A5=BC=20?= =?UTF-8?q?=EC=9C=84=ED=95=9C=20=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80=20-#27?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/controller/RecipeController.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java index 48dd984..c31cf10 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java @@ -5,6 +5,7 @@ import com.hackathonteam1.refreshrator.dto.request.recipe.ModifyRecipeDto; import com.hackathonteam1.refreshrator.dto.request.recipe.RegisterRecipeDto; import com.hackathonteam1.refreshrator.dto.response.recipe.DetailRecipeDto; +import com.hackathonteam1.refreshrator.entity.Recipe; import com.hackathonteam1.refreshrator.entity.User; import com.hackathonteam1.refreshrator.service.RecipeService; import jakarta.validation.Valid; @@ -41,5 +42,12 @@ public ResponseEntity> modify( return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK,"레시피 수정 성공"),HttpStatus.OK); } + @PostMapping("/{recipe_id}/ingredients/{ingredient_id}") + public ResponseEntity> registerIngredientRecipe(@PathVariable("recipe_id") UUID recipeId, + @PathVariable("ingredient_id") UUID ingredientId, @AuthenticatedUser User user){ + recipeService.registerIngredientRecipe(user, recipeId, ingredientId); + return new ResponseEntity<>(ResponseDto.res(HttpStatus.CREATED, "레시피 재료 등록 성공"),HttpStatus.CREATED); + } + } From 35aea0bc7b62e701adafe3b2bf2fdf4faaa8bb6d Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 21 Jul 2024 02:30:06 +0900 Subject: [PATCH 092/212] =?UTF-8?q?feat:=20=EB=A0=88=EC=8B=9C=ED=94=BC?= =?UTF-8?q?=EC=97=90=20=EC=9E=AC=EB=A3=8C=EB=A5=BC=20=EB=8B=A8=EC=9D=BC=20?= =?UTF-8?q?=EB=93=B1=EB=A1=9D=ED=95=98=EB=8A=94=20=EB=B9=84=EC=A6=88?= =?UTF-8?q?=EB=8B=88=EC=8A=A4=20=EB=A1=9C=EC=A7=81=20=EC=9E=91=EC=84=B1=20?= =?UTF-8?q?-=20#27=20=EC=9E=AC=EB=A3=8C=EA=B0=80=20=EC=A4=91=EB=B3=B5?= =?UTF-8?q?=EC=9D=B8=20=EA=B2=BD=EC=9A=B0=20=EC=98=A4=EB=A5=98=20=EB=B0=9C?= =?UTF-8?q?=EC=83=9D,=20=EB=A9=94=EC=84=9C=EB=93=9C=EB=A5=BC=20=EC=84=A4?= =?UTF-8?q?=EB=AA=85=ED=95=98=EB=8A=94=20=EA=B0=84=EB=8B=A8=ED=95=9C=20?= =?UTF-8?q?=EC=A3=BC=EC=84=9D=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/service/RecipeService.java | 2 ++ .../service/RecipeServiceImpl.java | 26 ++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java index 453ce20..dc8439c 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java @@ -18,4 +18,6 @@ public interface RecipeService { public void modifyContent(ModifyRecipeDto modifyRecipeDto, User user, UUID recipeId); + public void registerIngredientRecipe(User user, UUID recipeId, UUID ingredientId); + } diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java index 1e4811f..2f73a28 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java @@ -7,6 +7,7 @@ import com.hackathonteam1.refreshrator.entity.IngredientRecipe; import com.hackathonteam1.refreshrator.entity.Recipe; import com.hackathonteam1.refreshrator.entity.User; +import com.hackathonteam1.refreshrator.exception.ConflictException; import com.hackathonteam1.refreshrator.exception.ForbiddenException; import com.hackathonteam1.refreshrator.exception.NotFoundException; import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; @@ -49,7 +50,7 @@ public DetailRecipeDto getDetail(UUID recipeId) { Recipe recipe = findRecipeByRecipeId(recipeId); List ingredientRecipes = findAllIngredientRecipeByRecipe(recipe); - List ingredients = ingredientRecipes.stream().map(i->i.getIngredient()).collect(Collectors.toList()); + List ingredients = findAllIngredientByIngredientRecipes(ingredientRecipes); DetailRecipeDto detailRecipeDto = DetailRecipeDto.detailRecipeDto(recipe.getName(),ingredients, recipe.getCookingStep()); @@ -72,6 +73,23 @@ public void modifyContent(ModifyRecipeDto modifyRecipeDto, User user, UUID recip recipeRepository.save(recipe); } + //레시피 재료 등록 + @Override + public void registerIngredientRecipe(User user, UUID recipeId, UUID ingredientId) { + Recipe recipe = findRecipeByRecipeId(recipeId); + checkAuth(recipe.getUser(), user); + + List ingredients = findAllIngredientByIngredientRecipes(findAllIngredientRecipeByRecipe(recipe)); + + Ingredient newIngredient = findIngredientByIngredientId(ingredientId); + + if(ingredients.stream().anyMatch(i->i.getId().equals(newIngredient.getId()))){ + throw new ConflictException(ErrorCode.RECIPE_INGREDIENT_CONFLICT); + } + + registerRecipeIngredient(newIngredient, recipe); + } + private Ingredient findIngredientByIngredientId(UUID ingredientId){ return ingredientRepository.findById(ingredientId).orElseThrow(()-> new NotFoundException(ErrorCode.INGREDIENT_NOT_FOUND)); } @@ -89,6 +107,12 @@ private Recipe findRecipeByRecipeId(UUID recipeId){ return recipeRepository.findById(recipeId).orElseThrow(()-> new NotFoundException(ErrorCode.RECIPE_NOT_FOUND)); } + //IngredientRecipe 리스트로 Ingredient 리스트 생성하는 메서드 + private List findAllIngredientByIngredientRecipes(List ingredientRecipes){ + return ingredientRecipes.stream().map(i->i.getIngredient()).collect(Collectors.toList()); + } + + //Recipe로 해당 Recipe 내에 존재하는 IngredientRecipe 리스트를 반환하는 메서드 private List findAllIngredientRecipeByRecipe(Recipe recipe){ return ingredientRecipeRepository.findAllByRecipe(recipe).orElseThrow(()-> new NotFoundException(ErrorCode.INGREDIENT_RECIPE_NOT_FOUND)); } From d17f17a68dfdc0b1a76aa0bb4328e20eeadd7723 Mon Sep 17 00:00:00 2001 From: juryheed Date: Sun, 21 Jul 2024 03:58:39 +0900 Subject: [PATCH 093/212] =?UTF-8?q?feat:=20=EC=97=90=EB=9F=AC=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=B6=94=EA=B0=80=20-=20#29=20-=EC=9E=AC=EB=A3=8C?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=EC=97=90=20=EB=8C=80=ED=95=9C=20=EA=B6=8C?= =?UTF-8?q?=ED=95=9C=EC=9D=B4=20=EC=97=86=EC=9D=84=EA=B2=BD=EC=9A=B0=20?= =?UTF-8?q?=EB=B0=9C=EC=83=9D=ED=95=98=EB=8A=94=20=EC=97=90=EB=9F=AC?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20-=EB=93=B1=EB=A1=9D=EB=90=9C=20=EC=9E=AC?= =?UTF-8?q?=EB=A3=8C=EC=A0=95=EB=B3=B4=EA=B0=80=20=EC=97=86=EB=8A=94=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20=EB=B0=9C=EC=83=9D=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC=EC=BD=94=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/exception/errorcode/ErrorCode.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java index c445da4..2626478 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java +++ b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java @@ -22,6 +22,7 @@ public enum ErrorCode { //ForbiddenException RECIPE_FORBIDDEN("4030","해당 레시피에 대한 권한이 없습니다."), + FRIDGE_ITEM_FORBIDDEN("4031","해당 재료정보에 대한 권한이 없습니다."), //NotFoundException USERID_NOT_FOUND("4040","존재하지 않는 사용자 입니다"), @@ -29,6 +30,7 @@ public enum ErrorCode { RECIPE_NOT_FOUND("4042", "레시피를 찾을 수 없습니다."), INGREDIENT_RECIPE_NOT_FOUND("4043", "레시피의 재료를 찾을 수 없습니다."), FRIDGE_NOT_FOUND("4044","냉장고를 찾을 수 없습니다"), + FRIDGE_ITEM_NOT_FOUND("4045","냉장고에 등록되 재료 정보를 찾을 수 없습니다."), //ConflictException DUPLICATED_EMAIL("4090", "이미 사용 중인 이메일입니다."); From 5c5ec5a258a4ceef3100dd14d945bef19b7e72d1 Mon Sep 17 00:00:00 2001 From: juryheed Date: Sun, 21 Jul 2024 04:05:05 +0900 Subject: [PATCH 094/212] =?UTF-8?q?feat:=20User=EC=97=94=ED=8B=B0=ED=8B=B0?= =?UTF-8?q?=20=EC=88=98=EC=A0=95=20-=20#29=20FridgeItem=20=EC=97=94?= =?UTF-8?q?=ED=8B=B0=ED=8B=B0=EC=99=80=EC=9D=98=20=EC=9D=BC=EB=8C=80?= =?UTF-8?q?=EB=8B=A4=20=EA=B4=80=EA=B3=84=EB=A5=BC=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/hackathonteam1/refreshrator/entity/User.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/User.java b/src/main/java/com/hackathonteam1/refreshrator/entity/User.java index c667835..9d0f2cb 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/entity/User.java +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/User.java @@ -30,4 +30,7 @@ public class User extends BaseEntity{ @OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) private List recipeLikes; + @OneToMany(mappedBy = "user",cascade = CascadeType.PERSIST, fetch = FetchType.LAZY) + private List fridgeItems; + } From 17322eb22b62bbddc5cb86871ed8b4f060b44f03 Mon Sep 17 00:00:00 2001 From: juryheed Date: Sun, 21 Jul 2024 04:06:17 +0900 Subject: [PATCH 095/212] =?UTF-8?q?feat:=20FridgeItem=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=20=EC=88=98=EC=A0=95=20-=20#29=20User=EC=97=94?= =?UTF-8?q?=ED=8B=B0=ED=8B=B0=EC=99=80=EC=9D=98=20=EC=9D=BC=EB=8C=80?= =?UTF-8?q?=EB=8B=A4=20=EA=B4=80=EB=A1=80=EB=A5=BC=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hackathonteam1/refreshrator/entity/FridgeItem.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/FridgeItem.java b/src/main/java/com/hackathonteam1/refreshrator/entity/FridgeItem.java index 2d7bfac..cb70e01 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/entity/FridgeItem.java +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/FridgeItem.java @@ -21,6 +21,11 @@ public class FridgeItem extends BaseEntity{ @JoinColumn(name = "ingredient_id", nullable = false) private Ingredient ingredient; + @ManyToOne(fetch = FetchType.EAGER, optional = false) + @JoinColumn(name = "user_id", nullable = false) + private User user; + + @Column(nullable = false) private LocalDate expiredDate; From d7e3d224df13e2de92fcab896ef1ca6febb1ace1 Mon Sep 17 00:00:00 2001 From: juryheed Date: Sun, 21 Jul 2024 04:07:37 +0900 Subject: [PATCH 096/212] =?UTF-8?q?refactor:=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=20import=EC=A0=9C=EA=B1=B0=20-?= =?UTF-8?q?=20#29?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/dto/request/fridge/AddFridgeDto.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/request/fridge/AddFridgeDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/request/fridge/AddFridgeDto.java index b280c84..6a0370e 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/dto/request/fridge/AddFridgeDto.java +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/request/fridge/AddFridgeDto.java @@ -1,7 +1,5 @@ package com.hackathonteam1.refreshrator.dto.request.fridge; -import com.hackathonteam1.refreshrator.entity.FridgeItem; -import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Getter; From 5bedd1a789f7bebc1297f79fcdee0bc982a57092 Mon Sep 17 00:00:00 2001 From: juryheed Date: Sun, 21 Jul 2024 04:10:42 +0900 Subject: [PATCH 097/212] =?UTF-8?q?feat:=20=EB=93=B1=EB=A1=9D=ED=95=9C=20?= =?UTF-8?q?=EC=9E=AC=EB=A3=8C=20=EC=A0=95=EB=B3=B4=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=9E=91=EC=84=B1=20-=20#29=20-=20updateI?= =?UTF-8?q?ngredientInFridge=20=EC=9E=91=EC=84=B1=20-=20=EC=9E=AC=EB=A3=8C?= =?UTF-8?q?=EC=B0=BE=EA=B8=B0=20=EB=A9=94=EC=84=9C=EB=93=9C=ED=99=94=20-?= =?UTF-8?q?=20=EB=83=89=EC=9E=A5=EA=B3=A0=20=EC=B0=BE=EA=B8=B0=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/service/FridgeService.java | 49 +++++++++++++++++-- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java b/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java index cde8d52..b81c0de 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java @@ -5,6 +5,7 @@ import com.hackathonteam1.refreshrator.entity.FridgeItem; import com.hackathonteam1.refreshrator.entity.Ingredient; import com.hackathonteam1.refreshrator.entity.User; +import com.hackathonteam1.refreshrator.exception.ForbiddenException; import com.hackathonteam1.refreshrator.exception.NotFoundException; import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; import com.hackathonteam1.refreshrator.repository.FridgeItemRepository; @@ -13,6 +14,8 @@ import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; +import java.util.UUID; + @Service @AllArgsConstructor public class FridgeService { @@ -24,17 +27,16 @@ public class FridgeService { public void addIngredientInFridge(AddFridgeDto addFridgeDto, User user){ //재료 찾기 - Ingredient ingredient=ingredientRepository.findById(addFridgeDto.getIngredientId()) - .orElseThrow(()-> new NotFoundException(ErrorCode.INGREDIENT_NOT_FOUND)); + Ingredient ingredient=findIngredient(addFridgeDto); //냉장고 찾기 - Fridge fridge=fridgeRepository.findByUser(user) - .orElseThrow(()-> new NotFoundException(ErrorCode.FRIDGE_NOT_FOUND)); + Fridge fridge=findFridge(user); //재료 정보 입력 FridgeItem fridgeItem=FridgeItem.builder() .fridge(fridge) .ingredient(ingredient) + .user(user) .expiredDate(addFridgeDto.getExpiredDate()) .quantity(addFridgeDto.getQuantity()) .storage(defindStorage(addFridgeDto.getStorage())) @@ -45,6 +47,26 @@ public void addIngredientInFridge(AddFridgeDto addFridgeDto, User user){ fridgeItemRepository.save(fridgeItem); } + public void updateIngredientInFridge(UUID id, AddFridgeDto addFridgeDto, User user){ + + //수정할 재료 찾기 + FridgeItem fridgeItem=fridgeItemRepository.findById(id) + .orElseThrow(()-> new NotFoundException(ErrorCode.FRIDGE_ITEM_NOT_FOUND)); + + //유저가 등록한 재료인지 검사 + checkAuth(user,fridgeItem.getUser()); + + //수정하기 + fridgeItem.setExpiredDate(addFridgeDto.getExpiredDate()); + fridgeItem.setQuantity(addFridgeDto.getQuantity()); + fridgeItem.setStorage(defindStorage(addFridgeDto.getStorage())); + fridgeItem.setMemo(addFridgeDto.getMemo()); + + //저장하기 + fridgeItemRepository.save(fridgeItem); + } + + //저장방법 결정 메서드 private FridgeItem.Storage defindStorage(String storage){ return switch (storage){ case "상온"-> FridgeItem.Storage.STORE_AT_ROOM_TEMPERATURE; @@ -52,4 +74,23 @@ private FridgeItem.Storage defindStorage(String storage){ default -> FridgeItem.Storage.REFRIGERATED; }; } + + //데이터베이스에서 재료id로 재료를 찾는 메서드 + private Ingredient findIngredient(AddFridgeDto addFridgeDto){ + return ingredientRepository.findById(addFridgeDto.getIngredientId()) + .orElseThrow(()-> new NotFoundException(ErrorCode.INGREDIENT_NOT_FOUND)); + } + + //데이터베이스에서 유저의 냉장고를 찾는 메서드 + private Fridge findFridge(User user){ + return fridgeRepository.findByUser(user) + .orElseThrow(()-> new NotFoundException(ErrorCode.FRIDGE_NOT_FOUND)); + } + + //권한 확인 + private void checkAuth(User writer, User user){ + if(!writer.getId().equals(user.getId())){ + throw new ForbiddenException(ErrorCode.FRIDGE_ITEM_FORBIDDEN); + } + } } From 789cb38fecd18ca522349572ad65474e9957a85b Mon Sep 17 00:00:00 2001 From: juryheed Date: Sun, 21 Jul 2024 04:13:16 +0900 Subject: [PATCH 098/212] =?UTF-8?q?feat:=20=EB=83=89=EC=9E=A5=EA=B3=A0?= =?UTF-8?q?=EC=97=90=20=EB=93=B1=EB=A1=9D=ED=95=9C=20=EC=9E=AC=EB=A3=8C?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=88=98=EC=A0=95=20=EC=BB=A8=ED=8A=B8?= =?UTF-8?q?=EB=A1=A4=EB=9F=AC=20-=20#29=20-=20=EA=B2=BD=EB=A1=9C=EB=8A=94?= =?UTF-8?q?=20/fridge/ingredients/{ingredient=5Fid}=20-=20=EC=A0=95?= =?UTF-8?q?=EC=83=81=20=EC=9E=91=EB=8F=99=EC=8B=9C=20"=EB=83=89=EC=9E=A5?= =?UTF-8?q?=EA=B3=A0=EC=97=90=20=EC=9E=AC=EB=A3=8C=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?=EC=84=B1=EA=B3=B5"=20=EB=AC=B8=EA=B5=AC=20=EC=B6=9C=EB=A0=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/FridgeController.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java index 042bea2..44dce0a 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java @@ -7,13 +7,11 @@ import com.hackathonteam1.refreshrator.service.FridgeService; import jakarta.validation.Valid; import lombok.AllArgsConstructor; -import lombok.Value; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -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 org.springframework.web.bind.annotation.*; + +import java.util.UUID; @RestController @AllArgsConstructor @@ -24,8 +22,15 @@ public class FridgeController { //냉장고에 재료 추가 @PostMapping("/ingredients") - public ResponseEntity> addIngredientInFridge(@RequestBody @Valid AddFridgeDto addFridgeDto , @AuthenticatedUser User user){ - fridgeService.addIngredientInFridge(addFridgeDto,user); - return new ResponseEntity<>(ResponseDto.res(HttpStatus.CREATED,"냉장고에 재료 등록 성공"),HttpStatus.CREATED); + public ResponseEntity> addIngredientInFridge(@RequestBody @Valid AddFridgeDto addFridgeDto, @AuthenticatedUser User user) { + fridgeService.addIngredientInFridge(addFridgeDto, user); + return new ResponseEntity<>(ResponseDto.res(HttpStatus.CREATED, "냉장고에 재료 등록 성공"), HttpStatus.CREATED); + } + + //재료 정보 수정 + @PatchMapping("/ingredients/{ingredient_id}") + public ResponseEntity> updateIngredientInFridge(@PathVariable("ingredient_id") UUID id , @RequestBody @Valid AddFridgeDto addFridgeDto, @AuthenticatedUser User user) { + fridgeService.updateIngredientInFridge(id,addFridgeDto, user); + return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "냉장고에 재료 수정 성공"), HttpStatus.OK); } } From cdc0c18dd8db3c1c39ba6906e45e06f2d90b2fe7 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 21 Jul 2024 12:36:07 +0900 Subject: [PATCH 099/212] =?UTF-8?q?feat:=20=EC=A4=91=EB=B3=B5=EB=90=9C=20?= =?UTF-8?q?=EC=9E=AC=EB=A3=8C=20=EB=AA=A9=EB=A1=9D=EC=9D=84=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=ED=95=98=EB=A0=A4=ED=95=A0=20=EB=95=8C=20=EC=98=88?= =?UTF-8?q?=EC=99=B8=EC=B2=98=EB=A6=AC=20=EC=9E=91=EC=84=B1=20-=20#27?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/exception/BadRequestException.java | 13 +++++++++++++ .../refreshrator/exception/errorcode/ErrorCode.java | 1 + 2 files changed, 14 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/exception/BadRequestException.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/exception/BadRequestException.java b/src/main/java/com/hackathonteam1/refreshrator/exception/BadRequestException.java new file mode 100644 index 0000000..9c1572c --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/exception/BadRequestException.java @@ -0,0 +1,13 @@ +package com.hackathonteam1.refreshrator.exception; + +import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; + +public class BadRequestException extends CustomException{ + public BadRequestException(ErrorCode errorCode) { + super(errorCode); + } + + public BadRequestException(ErrorCode errorCode, String detail) { + super(errorCode, detail); + } +} diff --git a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java index a25a9a6..f22c774 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java +++ b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java @@ -15,6 +15,7 @@ public enum ErrorCode { LENGTH("4003", "길이가 유효하지 않습니다."), EMAIL("4004", "이메일 형식이 유효하지 않습니다."), NOT_NULL("4005", "필수값이 공백입니다."), + DUPLICATED_RECIPE_INGREDIENT("4006","레시피에 중복되는 재료 추가할 수 없습니다."), //AuthorizedException COOKIE_NOT_FOUND("4010", "쿠키를 찾을 수 없습니다."), From 385c80fe4ff7e42ddea5b8eddaa2161dae37b5be Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 21 Jul 2024 12:37:22 +0900 Subject: [PATCH 100/212] =?UTF-8?q?feat:=20=EC=9E=AC=EB=A3=8C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=EB=A5=BC=20=EC=9C=84=ED=95=9C=20Dto=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20-=20#27=20=EC=A4=91=EB=B3=B5=20=EC=8B=9C=20?= =?UTF-8?q?=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC=EB=A5=BC=20=EC=9C=84?= =?UTF-8?q?=ED=95=9C=20=EB=A9=94=EC=84=9C=EB=93=9C=EB=8F=84=20=ED=95=A8?= =?UTF-8?q?=EA=BB=98=20=EC=9E=91=EC=84=B1.=20=EC=9D=B4=EB=8A=94=20?= =?UTF-8?q?=EB=B9=84=EC=A6=88=EB=8B=88=EC=8A=A4=20=EB=A1=9C=EC=A7=81?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EC=82=AC=EC=9A=A9=EB=90=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/recipe/IngredientRecipeDto.java | 24 +++++++++++++++++++ .../{ModifyRecipeDto.java => RecipeDto.java} | 4 +--- 2 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/IngredientRecipeDto.java rename src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/{ModifyRecipeDto.java => RecipeDto.java} (73%) diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/IngredientRecipeDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/IngredientRecipeDto.java new file mode 100644 index 0000000..ff43276 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/IngredientRecipeDto.java @@ -0,0 +1,24 @@ +package com.hackathonteam1.refreshrator.dto.request.recipe; + +import com.hackathonteam1.refreshrator.exception.BadRequestException; +import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; +import jakarta.validation.constraints.NotNull; +import lombok.Getter; + +import java.util.List; +import java.util.UUID; +import java.util.stream.Collectors; + +@Getter +public class IngredientRecipeDto { + @NotNull + private List ingredientIds; + + public List nonDupIngredientIds(){ + List nonDupIngredientIds = this.getIngredientIds().stream().distinct().collect(Collectors.toList()); + if(this.ingredientIds.size() != nonDupIngredientIds.size()){ + throw new BadRequestException(ErrorCode.DUPLICATED_RECIPE_INGREDIENT); + } + return nonDupIngredientIds; + } +} diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/ModifyRecipeDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/RecipeDto.java similarity index 73% rename from src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/ModifyRecipeDto.java rename to src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/RecipeDto.java index 7ecfc4c..37e6517 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/ModifyRecipeDto.java +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/RecipeDto.java @@ -1,7 +1,5 @@ package com.hackathonteam1.refreshrator.dto.request.recipe; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Size; import lombok.AllArgsConstructor; import lombok.Getter; @@ -10,7 +8,7 @@ @Getter @AllArgsConstructor @NoArgsConstructor -public class ModifyRecipeDto { +public class RecipeDto { @Size(min = 1, max = 20) private String name; From 55b2927097298200a0cc2958616d8380ee48564e Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 21 Jul 2024 12:38:48 +0900 Subject: [PATCH 101/212] =?UTF-8?q?refactor:=20=EB=A0=88=EC=8B=9C=ED=94=BC?= =?UTF-8?q?=20=EC=9E=AC=EB=A3=8C=EB=A5=BC=20=EB=A6=AC=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=EB=A1=9C=20=EC=B6=94=EA=B0=80=ED=95=98=EB=8A=94=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=88=98=EC=A0=95=20-=20#27=20=EB=A0=88=EC=8B=9C?= =?UTF-8?q?=ED=94=BC=20=EC=9E=AC=EB=A3=8C=EB=A5=BC=20=EB=8B=A8=EC=9D=BC=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=EA=B0=80=20=EC=95=84=EB=8B=88=EB=9D=BC,=20?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=EB=A1=9C=20=ED=95=9C=EB=B2=88?= =?UTF-8?q?=EC=97=90=20=EC=B6=94=EA=B0=80=ED=95=98=EB=8A=94=20=ED=98=95?= =?UTF-8?q?=EC=8B=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/RecipeController.java | 14 ++++---- .../refreshrator/service/RecipeService.java | 8 ++--- .../service/RecipeServiceImpl.java | 33 ++++++++++++------- 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java index c31cf10..4c28b5e 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java @@ -2,10 +2,10 @@ import com.hackathonteam1.refreshrator.annotation.AuthenticatedUser; import com.hackathonteam1.refreshrator.dto.ResponseDto; -import com.hackathonteam1.refreshrator.dto.request.recipe.ModifyRecipeDto; +import com.hackathonteam1.refreshrator.dto.request.recipe.IngredientRecipeDto; +import com.hackathonteam1.refreshrator.dto.request.recipe.RecipeDto; import com.hackathonteam1.refreshrator.dto.request.recipe.RegisterRecipeDto; import com.hackathonteam1.refreshrator.dto.response.recipe.DetailRecipeDto; -import com.hackathonteam1.refreshrator.entity.Recipe; import com.hackathonteam1.refreshrator.entity.User; import com.hackathonteam1.refreshrator.service.RecipeService; import jakarta.validation.Valid; @@ -37,15 +37,15 @@ public ResponseEntity> getDetail(@PathVariable("rec @PatchMapping("/{recipe_id}") public ResponseEntity> modify( - @RequestBody @Valid ModifyRecipeDto modifyRecipeDto, @AuthenticatedUser User user, @PathVariable("recipe_id") UUID recipeId){ - recipeService.modifyContent(modifyRecipeDto, user, recipeId); + @RequestBody @Valid RecipeDto recipeDto, @AuthenticatedUser User user, @PathVariable("recipe_id") UUID recipeId){ + recipeService.modifyContent(recipeDto, user, recipeId); return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK,"레시피 수정 성공"),HttpStatus.OK); } - @PostMapping("/{recipe_id}/ingredients/{ingredient_id}") + @PostMapping("/{recipe_id}/ingredients") public ResponseEntity> registerIngredientRecipe(@PathVariable("recipe_id") UUID recipeId, - @PathVariable("ingredient_id") UUID ingredientId, @AuthenticatedUser User user){ - recipeService.registerIngredientRecipe(user, recipeId, ingredientId); + @RequestBody @Valid IngredientRecipeDto ingredientRecipeDto, @AuthenticatedUser User user){ + recipeService.registerIngredientRecipe(user, recipeId, ingredientRecipeDto); return new ResponseEntity<>(ResponseDto.res(HttpStatus.CREATED, "레시피 재료 등록 성공"),HttpStatus.CREATED); } diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java index dc8439c..3dd4458 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java @@ -1,10 +1,10 @@ package com.hackathonteam1.refreshrator.service; -import com.hackathonteam1.refreshrator.dto.request.recipe.ModifyRecipeDto; +import com.hackathonteam1.refreshrator.dto.request.recipe.IngredientRecipeDto; +import com.hackathonteam1.refreshrator.dto.request.recipe.RecipeDto; import com.hackathonteam1.refreshrator.dto.request.recipe.RegisterRecipeDto; import com.hackathonteam1.refreshrator.dto.response.recipe.DetailRecipeDto; import com.hackathonteam1.refreshrator.entity.User; -import org.springframework.stereotype.Service; import java.util.UUID; @@ -16,8 +16,8 @@ public interface RecipeService { //레시피 상세조회 public DetailRecipeDto getDetail(UUID recipeId); - public void modifyContent(ModifyRecipeDto modifyRecipeDto, User user, UUID recipeId); + public void modifyContent(RecipeDto recipeDto, User user, UUID recipeId); - public void registerIngredientRecipe(User user, UUID recipeId, UUID ingredientId); + public void registerIngredientRecipe(User user, UUID recipeId, IngredientRecipeDto ingredientRecipeDto); } diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java index 2f73a28..e4d45df 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java @@ -1,6 +1,7 @@ package com.hackathonteam1.refreshrator.service; -import com.hackathonteam1.refreshrator.dto.request.recipe.ModifyRecipeDto; +import com.hackathonteam1.refreshrator.dto.request.recipe.IngredientRecipeDto; +import com.hackathonteam1.refreshrator.dto.request.recipe.RecipeDto; import com.hackathonteam1.refreshrator.dto.request.recipe.RegisterRecipeDto; import com.hackathonteam1.refreshrator.dto.response.recipe.DetailRecipeDto; import com.hackathonteam1.refreshrator.entity.Ingredient; @@ -19,6 +20,7 @@ import org.springframework.transaction.annotation.Transactional; +import java.util.HashSet; import java.util.List; import java.util.UUID; import java.util.stream.Collectors; @@ -59,15 +61,15 @@ public DetailRecipeDto getDetail(UUID recipeId) { //레시피명, 조리법 수정 @Override - public void modifyContent(ModifyRecipeDto modifyRecipeDto, User user, UUID recipeId) { + public void modifyContent(RecipeDto recipeDto, User user, UUID recipeId) { Recipe recipe = findRecipeByRecipeId(recipeId); checkAuth(recipe.getUser(), user); - if(modifyRecipeDto.getName()!=null){ - recipe.updateName(modifyRecipeDto.getName()); + if(recipeDto.getName()!=null){ + recipe.updateName(recipeDto.getName()); } - if(modifyRecipeDto.getCookingStep()!=null) { - recipe.updateCookingStep(modifyRecipeDto.getCookingStep()); + if(recipeDto.getCookingStep()!=null) { + recipe.updateCookingStep(recipeDto.getCookingStep()); } recipeRepository.save(recipe); @@ -75,19 +77,26 @@ public void modifyContent(ModifyRecipeDto modifyRecipeDto, User user, UUID recip //레시피 재료 등록 @Override - public void registerIngredientRecipe(User user, UUID recipeId, UUID ingredientId) { + @Transactional + public void registerIngredientRecipe(User user, UUID recipeId, IngredientRecipeDto ingredientRecipeDto) { Recipe recipe = findRecipeByRecipeId(recipeId); checkAuth(recipe.getUser(), user); + //기존에 레시피에 존재하던 재료 리스트 List ingredients = findAllIngredientByIngredientRecipes(findAllIngredientRecipeByRecipe(recipe)); - Ingredient newIngredient = findIngredientByIngredientId(ingredientId); + HashSet existingIngredients = new HashSet<>(ingredients); - if(ingredients.stream().anyMatch(i->i.getId().equals(newIngredient.getId()))){ - throw new ConflictException(ErrorCode.RECIPE_INGREDIENT_CONFLICT); - } + List newIngredients = ingredientRecipeDto.nonDupIngredientIds().stream().map(i-> + findIngredientByIngredientId(i)).collect(Collectors.toList()); - registerRecipeIngredient(newIngredient, recipe); + //기존에 레시피에 존재하던 재료인지 확인 후 추가 + newIngredients.stream().forEach(newIngredient->{ + if(existingIngredients.contains(newIngredient)){ + throw new ConflictException(ErrorCode.RECIPE_INGREDIENT_CONFLICT); + } + registerRecipeIngredient(newIngredient, recipe); + }); } private Ingredient findIngredientByIngredientId(UUID ingredientId){ From 1a6289a38d15b92ee015cb77c356a2553c36dab3 Mon Sep 17 00:00:00 2001 From: juryheed Date: Sun, 21 Jul 2024 13:57:20 +0900 Subject: [PATCH 102/212] =?UTF-8?q?fix:=20=EC=98=A4=ED=83=80=EC=88=98?= =?UTF-8?q?=EC=A0=95=20-=20#29?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/exception/errorcode/ErrorCode.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java index 2626478..6889ae3 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java +++ b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java @@ -30,7 +30,7 @@ public enum ErrorCode { RECIPE_NOT_FOUND("4042", "레시피를 찾을 수 없습니다."), INGREDIENT_RECIPE_NOT_FOUND("4043", "레시피의 재료를 찾을 수 없습니다."), FRIDGE_NOT_FOUND("4044","냉장고를 찾을 수 없습니다"), - FRIDGE_ITEM_NOT_FOUND("4045","냉장고에 등록되 재료 정보를 찾을 수 없습니다."), + FRIDGE_ITEM_NOT_FOUND("4045","냉장고에 등록된 재료 정보를 찾을 수 없습니다."), //ConflictException DUPLICATED_EMAIL("4090", "이미 사용 중인 이메일입니다."); From f5172139f80e3290c8977db2895cb67737ca7b80 Mon Sep 17 00:00:00 2001 From: juryheed Date: Sun, 21 Jul 2024 13:59:31 +0900 Subject: [PATCH 103/212] =?UTF-8?q?feat:=20=EC=97=94=ED=8B=B0=ED=8B=B0?= =?UTF-8?q?=EA=B4=80=EA=B3=84=20=EC=82=AD=EC=A0=9C=20-=20#29=20user?= =?UTF-8?q?=EC=97=94=ED=8B=B0=ED=8B=B0=EC=99=80=20FridgeItem=EC=97=94?= =?UTF-8?q?=ED=8B=B0=ED=8B=B0=EC=9D=98=20=EA=B4=80=EA=B3=84=EB=A5=BC=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hackathonteam1/refreshrator/entity/FridgeItem.java | 5 ----- .../java/com/hackathonteam1/refreshrator/entity/User.java | 4 ---- 2 files changed, 9 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/FridgeItem.java b/src/main/java/com/hackathonteam1/refreshrator/entity/FridgeItem.java index cb70e01..2d7bfac 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/entity/FridgeItem.java +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/FridgeItem.java @@ -21,11 +21,6 @@ public class FridgeItem extends BaseEntity{ @JoinColumn(name = "ingredient_id", nullable = false) private Ingredient ingredient; - @ManyToOne(fetch = FetchType.EAGER, optional = false) - @JoinColumn(name = "user_id", nullable = false) - private User user; - - @Column(nullable = false) private LocalDate expiredDate; diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/User.java b/src/main/java/com/hackathonteam1/refreshrator/entity/User.java index 9d0f2cb..699d592 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/entity/User.java +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/User.java @@ -29,8 +29,4 @@ public class User extends BaseEntity{ @OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) private List recipeLikes; - - @OneToMany(mappedBy = "user",cascade = CascadeType.PERSIST, fetch = FetchType.LAZY) - private List fridgeItems; - } From 34214d9b89f1f78b4f3b57db255921b9ee8bc68d Mon Sep 17 00:00:00 2001 From: juryheed Date: Sun, 21 Jul 2024 14:00:49 +0900 Subject: [PATCH 104/212] =?UTF-8?q?feat:=20=EA=B6=8C=ED=95=9C=EA=B2=80?= =?UTF-8?q?=EC=82=AC=20=EB=B0=A9=EB=B2=95=20=EC=88=98=EC=A0=95=20-=20#29?= =?UTF-8?q?=20=EA=B6=8C=ED=95=9C=20=EA=B2=80=EC=82=AC=EC=8B=9C=20=EB=83=89?= =?UTF-8?q?=EC=9E=A5=EA=B3=A0=EC=9D=98=20=EC=9C=A0=EC=A0=80=EC=99=80=20?= =?UTF-8?q?=ED=98=84=EC=9E=AC=EB=A1=9C=EA=B7=B8=EC=9D=B8=ED=95=9C=20?= =?UTF-8?q?=EC=9C=A0=EC=A0=80=EB=A5=BC=20=EB=B9=84=EA=B5=90=ED=95=B4?= =?UTF-8?q?=EC=84=9C=20=EA=B2=80=EC=82=AC=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hackathonteam1/refreshrator/service/FridgeService.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java b/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java index b81c0de..50af58f 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java @@ -36,7 +36,6 @@ public void addIngredientInFridge(AddFridgeDto addFridgeDto, User user){ FridgeItem fridgeItem=FridgeItem.builder() .fridge(fridge) .ingredient(ingredient) - .user(user) .expiredDate(addFridgeDto.getExpiredDate()) .quantity(addFridgeDto.getQuantity()) .storage(defindStorage(addFridgeDto.getStorage())) @@ -54,7 +53,7 @@ public void updateIngredientInFridge(UUID id, AddFridgeDto addFridgeDto, User us .orElseThrow(()-> new NotFoundException(ErrorCode.FRIDGE_ITEM_NOT_FOUND)); //유저가 등록한 재료인지 검사 - checkAuth(user,fridgeItem.getUser()); + checkAuth(fridgeItem.getFridge().getUser(),user); //수정하기 fridgeItem.setExpiredDate(addFridgeDto.getExpiredDate()); From 9c951667d6b8c600f9cdf1acff407a56fbfeb031 Mon Sep 17 00:00:00 2001 From: juryheed Date: Sun, 21 Jul 2024 15:20:44 +0900 Subject: [PATCH 105/212] =?UTF-8?q?feat:=20=EB=83=89=EC=9E=A5=EA=B3=A0?= =?UTF-8?q?=EC=97=90=20=EC=9E=AC=EB=A3=8C=20=EC=82=AD=EC=A0=9C=20=EB=B9=84?= =?UTF-8?q?=EC=A6=88=EB=8B=88=EC=8A=A4=EB=A1=9C=EC=A7=81=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20-=20#32=20-=20=EB=83=89=EC=9E=A5=EA=B3=A0=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=9E=AC=EB=A3=8C=EB=A5=BC=20=EC=B0=BE=EB=8A=94=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EB=A9=94=EC=84=9C=EB=93=9C=ED=99=94=20-?= =?UTF-8?q?=20=EB=83=89=EC=9E=A5=EA=B3=A0=EC=97=90=EC=84=9C=20=EC=9E=AC?= =?UTF-8?q?=EB=A3=8C=20=EC=82=AD=EC=A0=9C=20=EB=A1=9C=EC=A7=81=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/service/FridgeService.java | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java b/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java index 50af58f..1b55a53 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java @@ -46,11 +46,11 @@ public void addIngredientInFridge(AddFridgeDto addFridgeDto, User user){ fridgeItemRepository.save(fridgeItem); } + //냉장고에 재료 정보 수정 메서드 public void updateIngredientInFridge(UUID id, AddFridgeDto addFridgeDto, User user){ //수정할 재료 찾기 - FridgeItem fridgeItem=fridgeItemRepository.findById(id) - .orElseThrow(()-> new NotFoundException(ErrorCode.FRIDGE_ITEM_NOT_FOUND)); + FridgeItem fridgeItem=findFridgeItem(id); //유저가 등록한 재료인지 검사 checkAuth(fridgeItem.getFridge().getUser(),user); @@ -65,6 +65,18 @@ public void updateIngredientInFridge(UUID id, AddFridgeDto addFridgeDto, User us fridgeItemRepository.save(fridgeItem); } + //냉장고에 재료 삭제 메서드 + public void deleteIngredientInFridge(UUID id, User user){ + //삭제할 재료 찾기 + FridgeItem fridgeItem=findFridgeItem(id); + + //권한 확인 + checkAuth(fridgeItem.getFridge().getUser(),user); + + //삭제하기 + fridgeItemRepository.delete(fridgeItem); + } + //저장방법 결정 메서드 private FridgeItem.Storage defindStorage(String storage){ return switch (storage){ @@ -86,6 +98,12 @@ private Fridge findFridge(User user){ .orElseThrow(()-> new NotFoundException(ErrorCode.FRIDGE_NOT_FOUND)); } + //냉장고에서 요청한 재료를 찾는 메서드 + private FridgeItem findFridgeItem(UUID id){ + return fridgeItemRepository.findById(id) + .orElseThrow(()-> new NotFoundException(ErrorCode.FRIDGE_ITEM_NOT_FOUND)); + } + //권한 확인 private void checkAuth(User writer, User user){ if(!writer.getId().equals(user.getId())){ From 93dc0fa0d393c141fcb6d89d4e8301a667195bcf Mon Sep 17 00:00:00 2001 From: juryheed Date: Sun, 21 Jul 2024 15:24:39 +0900 Subject: [PATCH 106/212] =?UTF-8?q?feat:=20=EB=83=89=EC=9E=A5=EA=B3=A0?= =?UTF-8?q?=EC=97=90=20=EC=9E=AC=EB=A3=8C=20=EC=82=AD=EC=A0=9C=20=EC=BB=A8?= =?UTF-8?q?=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EC=B6=94=EA=B0=80=20=EA=B2=BD?= =?UTF-8?q?=EB=A1=9C=EB=8A=94=20/fridge/ingredients/{ingredient=5Fid}=20?= =?UTF-8?q?=EC=A0=95=EC=83=81=EC=9E=91=EB=8F=99=20=EC=99=84=EB=A3=8C?= =?UTF-8?q?=EC=8B=9C=20"=EB=83=89=EC=9E=A5=EA=B3=A0=EC=97=90=20=EC=9E=AC?= =?UTF-8?q?=EB=A3=8C=20=EC=82=AD=EC=A0=9C=20=EC=84=B1=EA=B3=B5"=20?= =?UTF-8?q?=EB=AC=B8=EC=9E=A5=20=EC=B6=9C=EB=A0=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/controller/FridgeController.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java index 44dce0a..7f4b5cd 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java @@ -27,10 +27,17 @@ public ResponseEntity> addIngredientInFridge(@RequestBody @Val return new ResponseEntity<>(ResponseDto.res(HttpStatus.CREATED, "냉장고에 재료 등록 성공"), HttpStatus.CREATED); } - //재료 정보 수정 + //냉장고에 재료 정보 수정 @PatchMapping("/ingredients/{ingredient_id}") public ResponseEntity> updateIngredientInFridge(@PathVariable("ingredient_id") UUID id , @RequestBody @Valid AddFridgeDto addFridgeDto, @AuthenticatedUser User user) { fridgeService.updateIngredientInFridge(id,addFridgeDto, user); return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "냉장고에 재료 수정 성공"), HttpStatus.OK); } + + //냉장고에 재료 삭제 + @DeleteMapping("/ingredients/{ingredient_id}") + public ResponseEntity> deleteIngredientInFridge(@PathVariable("ingredient_id") UUID id , @AuthenticatedUser User user) { + fridgeService.deleteIngredientInFridge(id, user); + return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "냉장고에 재료 삭제 성공"), HttpStatus.OK); + } } From 0288f4ee8c43c36270e8c98a983e1ef8e074ad7b Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 21 Jul 2024 16:40:14 +0900 Subject: [PATCH 107/212] =?UTF-8?q?refactor:=20=EC=A4=91=EB=B3=B5=EB=90=98?= =?UTF-8?q?=EB=8A=94=20=EB=A0=88=EC=8B=9C=ED=94=BC=20=EC=9E=AC=EB=A3=8C=20?= =?UTF-8?q?=EC=9A=94=EC=B2=AD=20=EC=8B=9C=20=EC=97=90=EB=9F=AC=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EB=A9=94=EC=84=B8=EC=A7=80=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?-=20#28?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/exception/errorcode/ErrorCode.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java index 71f8f68..650243b 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java +++ b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java @@ -15,7 +15,7 @@ public enum ErrorCode { LENGTH("4003", "길이가 유효하지 않습니다."), EMAIL("4004", "이메일 형식이 유효하지 않습니다."), NOT_NULL("4005", "필수값이 공백입니다."), - DUPLICATED_RECIPE_INGREDIENT("4006","레시피에 중복되는 재료 추가할 수 없습니다."), + DUPLICATED_RECIPE_INGREDIENT("4006","중복되는 레시피 재료 관련 요청은 불가합니다."), //AuthorizedException COOKIE_NOT_FOUND("4010", "쿠키를 찾을 수 없습니다."), From 9b23871e9cfee51fdbeb1dec386e780af5450c63 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 21 Jul 2024 16:41:20 +0900 Subject: [PATCH 108/212] =?UTF-8?q?feat:=20=EB=A0=88=EC=8B=9C=ED=94=BC=20?= =?UTF-8?q?=EC=9E=AC=EB=A3=8C=20=EC=82=AD=EC=A0=9C=EB=A5=BC=20=EC=9C=84?= =?UTF-8?q?=ED=95=9C=20=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=B6=94=EA=B0=80=20-=20#28?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/RecipeController.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java index 4c28b5e..d6e8a2d 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java @@ -2,8 +2,9 @@ import com.hackathonteam1.refreshrator.annotation.AuthenticatedUser; import com.hackathonteam1.refreshrator.dto.ResponseDto; -import com.hackathonteam1.refreshrator.dto.request.recipe.IngredientRecipeDto; -import com.hackathonteam1.refreshrator.dto.request.recipe.RecipeDto; +import com.hackathonteam1.refreshrator.dto.request.recipe.DeleteIngredientRecipesDto; +import com.hackathonteam1.refreshrator.dto.request.recipe.RegisterIngredientRecipesDto; +import com.hackathonteam1.refreshrator.dto.request.recipe.ModifyRecipeDto; import com.hackathonteam1.refreshrator.dto.request.recipe.RegisterRecipeDto; import com.hackathonteam1.refreshrator.dto.response.recipe.DetailRecipeDto; import com.hackathonteam1.refreshrator.entity.User; @@ -37,17 +38,24 @@ public ResponseEntity> getDetail(@PathVariable("rec @PatchMapping("/{recipe_id}") public ResponseEntity> modify( - @RequestBody @Valid RecipeDto recipeDto, @AuthenticatedUser User user, @PathVariable("recipe_id") UUID recipeId){ - recipeService.modifyContent(recipeDto, user, recipeId); + @RequestBody @Valid ModifyRecipeDto modifyRecipeDto, @AuthenticatedUser User user, @PathVariable("recipe_id") UUID recipeId){ + recipeService.modifyContent(modifyRecipeDto, user, recipeId); return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK,"레시피 수정 성공"),HttpStatus.OK); } @PostMapping("/{recipe_id}/ingredients") public ResponseEntity> registerIngredientRecipe(@PathVariable("recipe_id") UUID recipeId, - @RequestBody @Valid IngredientRecipeDto ingredientRecipeDto, @AuthenticatedUser User user){ - recipeService.registerIngredientRecipe(user, recipeId, ingredientRecipeDto); + @RequestBody @Valid RegisterIngredientRecipesDto registerIngredientRecipesDto, @AuthenticatedUser User user){ + recipeService.registerIngredientRecipe(user, recipeId, registerIngredientRecipesDto); return new ResponseEntity<>(ResponseDto.res(HttpStatus.CREATED, "레시피 재료 등록 성공"),HttpStatus.CREATED); } + @DeleteMapping("/{recipe_id}/ingredients") + public ResponseEntity> deleteIngredientRecipe(@PathVariable("recipe_id") UUID recipeId, + @RequestBody @Valid DeleteIngredientRecipesDto deleteIngredientRecipesDto, @AuthenticatedUser User user){ + recipeService.deleteIngredientRecipe(user, recipeId, deleteIngredientRecipesDto); + return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "레시피 재료 삭제 성공"),HttpStatus.OK); + } + } From 01373d060bfae1ccf480be11853abdee6a38dbb1 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 21 Jul 2024 16:43:06 +0900 Subject: [PATCH 109/212] =?UTF-8?q?feat:=20dto=20=EB=84=A4=EC=9D=B4?= =?UTF-8?q?=EB=B0=8D=20=EC=88=98=EC=A0=95=20-=20#28?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/recipe/{RecipeDto.java => ModifyRecipeDto.java} | 2 +- ...gredientRecipeDto.java => RegisterIngredientRecipesDto.java} | 2 +- .../refreshrator/dto/request/recipe/RegisterRecipeDto.java | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) rename src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/{RecipeDto.java => ModifyRecipeDto.java} (91%) rename src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/{IngredientRecipeDto.java => RegisterIngredientRecipesDto.java} (94%) diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/RecipeDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/ModifyRecipeDto.java similarity index 91% rename from src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/RecipeDto.java rename to src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/ModifyRecipeDto.java index 37e6517..c94f804 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/RecipeDto.java +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/ModifyRecipeDto.java @@ -8,7 +8,7 @@ @Getter @AllArgsConstructor @NoArgsConstructor -public class RecipeDto { +public class ModifyRecipeDto { @Size(min = 1, max = 20) private String name; diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/IngredientRecipeDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/RegisterIngredientRecipesDto.java similarity index 94% rename from src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/IngredientRecipeDto.java rename to src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/RegisterIngredientRecipesDto.java index ff43276..274fca7 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/IngredientRecipeDto.java +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/RegisterIngredientRecipesDto.java @@ -10,7 +10,7 @@ import java.util.stream.Collectors; @Getter -public class IngredientRecipeDto { +public class RegisterIngredientRecipesDto { @NotNull private List ingredientIds; diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/RegisterRecipeDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/RegisterRecipeDto.java index 33f942c..cdb5864 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/RegisterRecipeDto.java +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/RegisterRecipeDto.java @@ -12,7 +12,6 @@ import java.util.UUID; @Getter -@AllArgsConstructor public class RegisterRecipeDto { @Size(min = 1, max = 20) From b474a132b98515f68e1f2d465f557f0372542cc6 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 21 Jul 2024 16:44:52 +0900 Subject: [PATCH 110/212] =?UTF-8?q?feat:=20=EB=A0=88=EC=8B=9C=ED=94=BC=20?= =?UTF-8?q?=EC=9E=AC=EB=A3=8C=20=EC=82=AD=EC=A0=9C=EB=A5=BC=20=EC=9C=84?= =?UTF-8?q?=ED=95=9C=20=EB=B9=84=EC=A6=88=EB=8B=88=EC=8A=A4=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=9E=91=EC=84=B1=20-=20#28?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/service/RecipeService.java | 14 +++++-- .../service/RecipeServiceImpl.java | 39 ++++++++++++++----- 2 files changed, 40 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java index 3dd4458..2742d6b 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java @@ -1,7 +1,8 @@ package com.hackathonteam1.refreshrator.service; -import com.hackathonteam1.refreshrator.dto.request.recipe.IngredientRecipeDto; -import com.hackathonteam1.refreshrator.dto.request.recipe.RecipeDto; +import com.hackathonteam1.refreshrator.dto.request.recipe.DeleteIngredientRecipesDto; +import com.hackathonteam1.refreshrator.dto.request.recipe.RegisterIngredientRecipesDto; +import com.hackathonteam1.refreshrator.dto.request.recipe.ModifyRecipeDto; import com.hackathonteam1.refreshrator.dto.request.recipe.RegisterRecipeDto; import com.hackathonteam1.refreshrator.dto.response.recipe.DetailRecipeDto; import com.hackathonteam1.refreshrator.entity.User; @@ -16,8 +17,13 @@ public interface RecipeService { //레시피 상세조회 public DetailRecipeDto getDetail(UUID recipeId); - public void modifyContent(RecipeDto recipeDto, User user, UUID recipeId); + //레시피 내용 수정 + public void modifyContent(ModifyRecipeDto modifyRecipeDto, User user, UUID recipeId); - public void registerIngredientRecipe(User user, UUID recipeId, IngredientRecipeDto ingredientRecipeDto); + //레시피 재료 추가 + public void registerIngredientRecipe(User user, UUID recipeId, RegisterIngredientRecipesDto registerIngredientRecipesDto); + + //레시피 재료 삭제 + public void deleteIngredientRecipe(User user, UUID recipeId, DeleteIngredientRecipesDto deleteIngredientRecipesDto); } diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java index e4d45df..515bada 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java @@ -1,7 +1,8 @@ package com.hackathonteam1.refreshrator.service; -import com.hackathonteam1.refreshrator.dto.request.recipe.IngredientRecipeDto; -import com.hackathonteam1.refreshrator.dto.request.recipe.RecipeDto; +import com.hackathonteam1.refreshrator.dto.request.recipe.DeleteIngredientRecipesDto; +import com.hackathonteam1.refreshrator.dto.request.recipe.RegisterIngredientRecipesDto; +import com.hackathonteam1.refreshrator.dto.request.recipe.ModifyRecipeDto; import com.hackathonteam1.refreshrator.dto.request.recipe.RegisterRecipeDto; import com.hackathonteam1.refreshrator.dto.response.recipe.DetailRecipeDto; import com.hackathonteam1.refreshrator.entity.Ingredient; @@ -22,6 +23,7 @@ import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.UUID; import java.util.stream.Collectors; @@ -61,15 +63,15 @@ public DetailRecipeDto getDetail(UUID recipeId) { //레시피명, 조리법 수정 @Override - public void modifyContent(RecipeDto recipeDto, User user, UUID recipeId) { + public void modifyContent(ModifyRecipeDto modifyRecipeDto, User user, UUID recipeId) { Recipe recipe = findRecipeByRecipeId(recipeId); checkAuth(recipe.getUser(), user); - if(recipeDto.getName()!=null){ - recipe.updateName(recipeDto.getName()); + if(modifyRecipeDto.getName()!=null){ + recipe.updateName(modifyRecipeDto.getName()); } - if(recipeDto.getCookingStep()!=null) { - recipe.updateCookingStep(recipeDto.getCookingStep()); + if(modifyRecipeDto.getCookingStep()!=null) { + recipe.updateCookingStep(modifyRecipeDto.getCookingStep()); } recipeRepository.save(recipe); @@ -78,7 +80,7 @@ public void modifyContent(RecipeDto recipeDto, User user, UUID recipeId) { //레시피 재료 등록 @Override @Transactional - public void registerIngredientRecipe(User user, UUID recipeId, IngredientRecipeDto ingredientRecipeDto) { + public void registerIngredientRecipe(User user, UUID recipeId, RegisterIngredientRecipesDto registerIngredientRecipesDto) { Recipe recipe = findRecipeByRecipeId(recipeId); checkAuth(recipe.getUser(), user); @@ -87,7 +89,7 @@ public void registerIngredientRecipe(User user, UUID recipeId, IngredientRecipeD HashSet existingIngredients = new HashSet<>(ingredients); - List newIngredients = ingredientRecipeDto.nonDupIngredientIds().stream().map(i-> + List newIngredients = registerIngredientRecipesDto.nonDupIngredientIds().stream().map(i-> findIngredientByIngredientId(i)).collect(Collectors.toList()); //기존에 레시피에 존재하던 재료인지 확인 후 추가 @@ -99,6 +101,25 @@ public void registerIngredientRecipe(User user, UUID recipeId, IngredientRecipeD }); } + @Override + public void deleteIngredientRecipe(User user, UUID recipeId, DeleteIngredientRecipesDto deleteIngredientRecipesDto) { + Recipe recipe = findRecipeByRecipeId(recipeId); + checkAuth(recipe.getUser(),user); + + //기존 레시피의 재료들 + List existingIngredientRecipes = findAllIngredientRecipeByRecipe(recipe); + + Set existingIngredientRecipeIds = existingIngredientRecipes.stream().map(i->i.getId()).collect(Collectors.toSet()); + + deleteIngredientRecipesDto.nonDupIngredientIds().forEach(i -> { + if(!existingIngredientRecipeIds.contains(i)){ + throw new NotFoundException(ErrorCode.INGREDIENT_RECIPE_NOT_FOUND); + } + ingredientRecipeRepository.deleteById(i); + }); + + } + private Ingredient findIngredientByIngredientId(UUID ingredientId){ return ingredientRepository.findById(ingredientId).orElseThrow(()-> new NotFoundException(ErrorCode.INGREDIENT_NOT_FOUND)); } From b29a22639845bb3836669baea5d52292ff3f9246 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 21 Jul 2024 16:45:19 +0900 Subject: [PATCH 111/212] =?UTF-8?q?feat:=20=EB=A0=88=EC=8B=9C=ED=94=BC=20?= =?UTF-8?q?=EC=9E=AC=EB=A3=8C=20=EC=82=AD=EC=A0=9C=EB=A5=BC=20=EC=9C=84?= =?UTF-8?q?=ED=95=9C=20Dto=20=EC=9E=91=EC=84=B1=20-=20#28?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../recipe/DeleteIngredientRecipesDto.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/DeleteIngredientRecipesDto.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/DeleteIngredientRecipesDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/DeleteIngredientRecipesDto.java new file mode 100644 index 0000000..16baf0f --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/DeleteIngredientRecipesDto.java @@ -0,0 +1,26 @@ +package com.hackathonteam1.refreshrator.dto.request.recipe; + +import com.hackathonteam1.refreshrator.exception.BadRequestException; +import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; +import jakarta.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.List; +import java.util.UUID; +import java.util.stream.Collectors; + +@Getter +public class DeleteIngredientRecipesDto { + + @NotNull + private List ingredientRecipeIds; + + public List nonDupIngredientIds(){ + List nonDupIngredientIds = this.getIngredientRecipeIds().stream().distinct().collect(Collectors.toList()); + if(this.getIngredientRecipeIds().size() != nonDupIngredientIds.size()){ + throw new BadRequestException(ErrorCode.DUPLICATED_RECIPE_INGREDIENT); + } + return nonDupIngredientIds; + } +} From b670449130798bc14b34ae9f5ca4af8a4e9ba2ad Mon Sep 17 00:00:00 2001 From: juryheed Date: Sun, 21 Jul 2024 16:49:32 +0900 Subject: [PATCH 112/212] =?UTF-8?q?feat:=20=EB=A1=9C=EA=B7=B8=EC=95=84?= =?UTF-8?q?=EC=9B=83=20=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EA=B2=BD=EB=A1=9C=EB=8A=94=20/auth/logout?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/controller/AuthController.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java index 02b7c3b..8482cb6 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java @@ -13,10 +13,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseCookie; import org.springframework.http.ResponseEntity; -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 org.springframework.web.bind.annotation.*; import java.time.Duration; @@ -53,4 +50,16 @@ public ResponseEntity> login(@RequestBody @Valid LoginDto logi return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "로그인 완료"), HttpStatus.OK); } + + //로그아웃 + @PostMapping("/logout") + public ResponseEntity> logout(final HttpServletResponse response) { + ResponseCookie cookie = ResponseCookie.from("AccessToken", null) + .maxAge(0) + .path("/") + .build(); + response.addHeader("set-cookie", cookie.toString()); + + return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "로그아웃 완료"), HttpStatus.OK); + } } From 514f0b4ec703a3b2c39bc7af1294a6dd23ac1efb Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 21 Jul 2024 17:24:45 +0900 Subject: [PATCH 113/212] =?UTF-8?q?feat:=20=EB=A0=88=EC=8B=9C=ED=94=BC=20?= =?UTF-8?q?=EC=83=81=EC=84=B8=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20Ingredien?= =?UTF-8?q?tRecipeId=EB=A5=BC=20=EC=A1=B0=ED=9A=8C=ED=95=98=EA=B8=B0=20?= =?UTF-8?q?=EC=9C=84=ED=95=9C=20Dto=20=EC=B6=94=EA=B0=80=20-=20#37?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../recipe/IngredientRecipeResponseDto.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/IngredientRecipeResponseDto.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/IngredientRecipeResponseDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/IngredientRecipeResponseDto.java new file mode 100644 index 0000000..0597a1f --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/IngredientRecipeResponseDto.java @@ -0,0 +1,22 @@ +package com.hackathonteam1.refreshrator.dto.response.recipe; + +import com.hackathonteam1.refreshrator.dto.response.ingredient.IngredientDto; +import com.hackathonteam1.refreshrator.entity.Ingredient; +import com.hackathonteam1.refreshrator.entity.IngredientRecipe; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.UUID; + +@Getter +@AllArgsConstructor +public class IngredientRecipeResponseDto { + + private UUID id; + private IngredientDto ingredient; + + public static IngredientRecipeResponseDto changeToDto(IngredientRecipe ingredientRecipe){ + return new IngredientRecipeResponseDto(ingredientRecipe.getId(), IngredientDto.changeToDto(ingredientRecipe.getIngredient())); + } + +} From 0fc56b6456b64f5d1f9b89ac8c4a5c0934af1d5a Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 21 Jul 2024 17:26:11 +0900 Subject: [PATCH 114/212] =?UTF-8?q?refactor:=20=EC=83=88=EB=A1=9C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=EB=90=9C=20IngredientRecipeResponseDto?= =?UTF-8?q?=EB=A5=BC=20=EC=82=AC=EC=9A=A9=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20-=20#37?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/recipe/DetailRecipeDto.java | 11 +++++------ .../refreshrator/service/RecipeServiceImpl.java | 5 +---- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/DetailRecipeDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/DetailRecipeDto.java index 934da84..f4e4025 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/DetailRecipeDto.java +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/DetailRecipeDto.java @@ -1,7 +1,6 @@ package com.hackathonteam1.refreshrator.dto.response.recipe; -import com.hackathonteam1.refreshrator.dto.response.ingredient.IngredientDto; -import com.hackathonteam1.refreshrator.entity.Ingredient; +import com.hackathonteam1.refreshrator.entity.IngredientRecipe; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; @@ -14,12 +13,12 @@ @AllArgsConstructor public class DetailRecipeDto { private String name; - private List ingredients; + private List ingredientRecipes; private String cookingStep; - public static DetailRecipeDto detailRecipeDto(String name, List ingredients, String cookingStep){ - List ingredientDtos = ingredients.stream().map( - i->IngredientDto.changeToDto(i)).collect(Collectors.toList()); + public static DetailRecipeDto detailRecipeDto(String name, List ingredientRecipes, String cookingStep){ + List ingredientDtos = ingredientRecipes.stream().map( + i->IngredientRecipeResponseDto.changeToDto(i)).collect(Collectors.toList()); return new DetailRecipeDto(name, ingredientDtos, cookingStep); } } diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java index e4d45df..a4b615d 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java @@ -52,10 +52,7 @@ public DetailRecipeDto getDetail(UUID recipeId) { Recipe recipe = findRecipeByRecipeId(recipeId); List ingredientRecipes = findAllIngredientRecipeByRecipe(recipe); - List ingredients = findAllIngredientByIngredientRecipes(ingredientRecipes); - - DetailRecipeDto detailRecipeDto = DetailRecipeDto.detailRecipeDto(recipe.getName(),ingredients, recipe.getCookingStep()); - + DetailRecipeDto detailRecipeDto = DetailRecipeDto.detailRecipeDto(recipe.getName(),ingredientRecipes, recipe.getCookingStep()); return detailRecipeDto; } From 1321be211468998d0942ca3e414b6dee0a294878 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 21 Jul 2024 17:34:51 +0900 Subject: [PATCH 115/212] =?UTF-8?q?feat:=20=EB=A1=9C=EA=B7=B8=EC=95=84?= =?UTF-8?q?=EC=9B=83=20=EC=8B=9C=EC=97=90=EB=8F=84=20=EB=B3=B4=EC=95=88=20?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20=EC=84=A4=EC=A0=95=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?-#34?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hackathonteam1/refreshrator/controller/AuthController.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java index 8482cb6..a1875bc 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java @@ -57,6 +57,8 @@ public ResponseEntity> logout(final HttpServletResponse respon ResponseCookie cookie = ResponseCookie.from("AccessToken", null) .maxAge(0) .path("/") + .httpOnly(true) + .sameSite("None").secure(true) .build(); response.addHeader("set-cookie", cookie.toString()); From ffc05de292aba282ce451497d0319531801dfc11 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 21 Jul 2024 17:40:55 +0900 Subject: [PATCH 116/212] =?UTF-8?q?feat:=20=EB=A1=9C=EA=B7=B8=EC=95=84?= =?UTF-8?q?=EC=9B=83=20=EC=8B=9C=EC=97=90=EB=8F=84=20=ED=86=A0=ED=81=B0?= =?UTF-8?q?=EC=97=90=20=EB=B3=B4=EC=95=88=20=EA=B4=80=EB=A0=A8=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=EC=B6=94=EA=B0=80=20-=20#34?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hackathonteam1/refreshrator/controller/AuthController.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java index 8482cb6..a1875bc 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java @@ -57,6 +57,8 @@ public ResponseEntity> logout(final HttpServletResponse respon ResponseCookie cookie = ResponseCookie.from("AccessToken", null) .maxAge(0) .path("/") + .httpOnly(true) + .sameSite("None").secure(true) .build(); response.addHeader("set-cookie", cookie.toString()); From 09e517af6096f931c1510c08dc91dd4a2edda99c Mon Sep 17 00:00:00 2001 From: jihyeonEom Date: Sun, 21 Jul 2024 19:40:50 +0900 Subject: [PATCH 117/212] =?UTF-8?q?feat:=20IngredientController=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1=20-=20#39?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/IngredientController.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/controller/IngredientController.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/IngredientController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/IngredientController.java new file mode 100644 index 0000000..b6f261a --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/IngredientController.java @@ -0,0 +1,24 @@ +package com.hackathonteam1.refreshrator.controller; + +import com.hackathonteam1.refreshrator.dto.ResponseDto; +import lombok.AllArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +@RestController +@AllArgsConstructor +@RequestMapping("/ingredients") +public class IngredientController { + + private final IngredientService ingredientService; + + // DB에 있는 재료 전체 조회 + @GetMapping() + public ResponseEntity> addIngredientInFridge() { + IngredientListDto ingredientListDto = ingredientService.showAllIngredients(); + return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "모든 재료 조회 성공", ingredientListDto), HttpStatus.OK); + } + + // DB에 있는 재료 검색 +} From 32b6dbd8792c74171bc749c07123fbca06c3200a Mon Sep 17 00:00:00 2001 From: jihyeonEom Date: Sun, 21 Jul 2024 19:41:38 +0900 Subject: [PATCH 118/212] =?UTF-8?q?feat:=20IngredientListDto=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20-=20#39?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/ingredient/IngredientListDto.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/dto/response/ingredient/IngredientListDto.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/response/ingredient/IngredientListDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/response/ingredient/IngredientListDto.java new file mode 100644 index 0000000..6528848 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/response/ingredient/IngredientListDto.java @@ -0,0 +1,14 @@ +package com.hackathonteam1.refreshrator.dto.response.ingredient; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; + +import java.util.List; + +@Getter +@Builder +@AllArgsConstructor +public class IngredientListDto { + private List ingredients; +} From 2d7a2a4cef25042add499d25e23764d6f1df6b97 Mon Sep 17 00:00:00 2001 From: jihyeonEom Date: Sun, 21 Jul 2024 19:44:09 +0900 Subject: [PATCH 119/212] =?UTF-8?q?feat:=20IngredientService=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20-=20#39?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/IngredientController.java | 2 ++ .../service/IngredientService.java | 31 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/service/IngredientService.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/IngredientController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/IngredientController.java index b6f261a..c61e34d 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/IngredientController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/IngredientController.java @@ -1,6 +1,8 @@ package com.hackathonteam1.refreshrator.controller; import com.hackathonteam1.refreshrator.dto.ResponseDto; +import com.hackathonteam1.refreshrator.dto.response.ingredient.IngredientListDto; +import com.hackathonteam1.refreshrator.service.IngredientService; import lombok.AllArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/IngredientService.java b/src/main/java/com/hackathonteam1/refreshrator/service/IngredientService.java new file mode 100644 index 0000000..b19b070 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/service/IngredientService.java @@ -0,0 +1,31 @@ +package com.hackathonteam1.refreshrator.service; + +import com.hackathonteam1.refreshrator.dto.response.ingredient.IngredientDto; +import com.hackathonteam1.refreshrator.dto.response.ingredient.IngredientListDto; +import com.hackathonteam1.refreshrator.entity.Ingredient; +import com.hackathonteam1.refreshrator.repository.IngredientRepository; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +@Service +@AllArgsConstructor +public class IngredientService { + private final IngredientRepository ingredientRepository; + + public IngredientListDto showAllIngredients() { + List ingredients = ingredientRepository.findAll(); + List ingredientDtoList = new ArrayList<>(); + + for (Ingredient ingredient : ingredients) { + IngredientDto ingredientDto = IngredientDto.builder() + .id(ingredient.getId()) + .name(ingredient.getName()) + .build(); + ingredientDtoList.add(ingredientDto); + } + return new IngredientListDto(ingredientDtoList); + } +} From 3593f2c0ee570eb5f9960822d678a3d301db8172 Mon Sep 17 00:00:00 2001 From: jihyeonEom Date: Sun, 21 Jul 2024 19:53:20 +0900 Subject: [PATCH 120/212] =?UTF-8?q?refactor:=20=ED=95=A8=EC=88=98=EB=AA=85?= =?UTF-8?q?=20=EC=88=98=EC=A0=95=20-=20#39?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/controller/IngredientController.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/IngredientController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/IngredientController.java index c61e34d..a620371 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/IngredientController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/IngredientController.java @@ -1,6 +1,7 @@ package com.hackathonteam1.refreshrator.controller; import com.hackathonteam1.refreshrator.dto.ResponseDto; +import com.hackathonteam1.refreshrator.dto.response.ingredient.IngredientDto; import com.hackathonteam1.refreshrator.dto.response.ingredient.IngredientListDto; import com.hackathonteam1.refreshrator.service.IngredientService; import lombok.AllArgsConstructor; @@ -17,7 +18,7 @@ public class IngredientController { // DB에 있는 재료 전체 조회 @GetMapping() - public ResponseEntity> addIngredientInFridge() { + public ResponseEntity> showAllIngredients() { IngredientListDto ingredientListDto = ingredientService.showAllIngredients(); return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "모든 재료 조회 성공", ingredientListDto), HttpStatus.OK); } From 52be25a75046502f3e8490a0aacd2e9ece47a354 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 21 Jul 2024 20:28:26 +0900 Subject: [PATCH 121/212] =?UTF-8?q?feat:=20=EB=A0=88=EC=8B=9C=ED=94=BC=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=EB=A5=BC=20=EC=9C=84=ED=95=9C=20=EC=BB=A8?= =?UTF-8?q?=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EC=BD=94=EB=93=9C=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20-=20#13?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/controller/RecipeController.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java index d6e8a2d..aefedf5 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java @@ -43,6 +43,12 @@ public ResponseEntity> modify( return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK,"레시피 수정 성공"),HttpStatus.OK); } + @DeleteMapping("/{recipe_id}") + public ResponseEntity> delete(@PathVariable("recipe_id") UUID recipeId, @AuthenticatedUser User user){ + recipeService.delete(recipeId, user); + return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK,"레시피 삭제 성공"),HttpStatus.OK); + } + @PostMapping("/{recipe_id}/ingredients") public ResponseEntity> registerIngredientRecipe(@PathVariable("recipe_id") UUID recipeId, @RequestBody @Valid RegisterIngredientRecipesDto registerIngredientRecipesDto, @AuthenticatedUser User user){ From bb3d499d6ac1322c9ba2fac96194fa8d3bcd8ed3 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 21 Jul 2024 20:28:51 +0900 Subject: [PATCH 122/212] =?UTF-8?q?feat:=20=EB=A0=88=EC=8B=9C=ED=94=BC=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=EB=A5=BC=20=EC=9C=84=ED=95=9C=20=EB=B9=84?= =?UTF-8?q?=EC=A6=88=EB=8B=88=EC=8A=A4=20=EB=A1=9C=EC=A7=81=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20-=20#13?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/service/RecipeService.java | 4 ++++ .../refreshrator/service/RecipeServiceImpl.java | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java index 2742d6b..73347f3 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java @@ -5,6 +5,7 @@ import com.hackathonteam1.refreshrator.dto.request.recipe.ModifyRecipeDto; import com.hackathonteam1.refreshrator.dto.request.recipe.RegisterRecipeDto; import com.hackathonteam1.refreshrator.dto.response.recipe.DetailRecipeDto; +import com.hackathonteam1.refreshrator.entity.Recipe; import com.hackathonteam1.refreshrator.entity.User; import java.util.UUID; @@ -20,6 +21,9 @@ public interface RecipeService { //레시피 내용 수정 public void modifyContent(ModifyRecipeDto modifyRecipeDto, User user, UUID recipeId); + //레시피 삭제 + public void delete(UUID recipeId, User user); + //레시피 재료 추가 public void registerIngredientRecipe(User user, UUID recipeId, RegisterIngredientRecipesDto registerIngredientRecipesDto); diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java index e10714d..cd4544e 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java @@ -74,6 +74,14 @@ public void modifyContent(ModifyRecipeDto modifyRecipeDto, User user, UUID recip recipeRepository.save(recipe); } + //레시피 삭제 + @Override + public void delete(UUID recipeId, User user) { + Recipe recipe = findRecipeByRecipeId(recipeId); + checkAuth(recipe.getUser(), user); + recipeRepository.delete(recipe); + } + //레시피 재료 등록 @Override @Transactional From 9b91b3beb190e9f025441c632589e5fe31ee2427 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 21 Jul 2024 20:37:28 +0900 Subject: [PATCH 123/212] =?UTF-8?q?fix:=20RecipeLike=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=20-=20#43=20RecipeLike=EC=97=94=ED=8B=B0=ED=8B=B0=EB=8A=94=20?= =?UTF-8?q?=EC=BF=BC=EB=A6=AC=20=EC=98=88=EC=95=BD=EC=96=B4=EC=9D=B8=20Lik?= =?UTF-8?q?e=EB=A5=BC=20=ED=94=BC=ED=95=98=EA=B3=A0=EC=9E=90=20=EC=97=94?= =?UTF-8?q?=ED=8B=B0=ED=8B=B0=20=EB=AA=85=EC=9D=84=20RecipeLike=EB=A1=9C?= =?UTF-8?q?=20=EC=9E=91=EC=84=B1=ED=96=88=EC=97=88=EB=8A=94=EB=8D=B0,=20?= =?UTF-8?q?=EC=B2=98=EC=9D=8C=EC=97=90=20@entity(name=3D"like")=EB=A1=9C?= =?UTF-8?q?=20=EC=9E=91=EC=84=B1=ED=96=88=EB=8D=98=20=EB=B6=80=EB=B6=84?= =?UTF-8?q?=EC=9D=84=20=EB=86=93=EC=B3=90=EC=84=9C=20=EC=9D=B4=EB=A5=BC=20?= =?UTF-8?q?@entity(name=20=3D=20"recipe=5Flike")=EB=A1=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hackathonteam1/refreshrator/entity/RecipeLike.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/RecipeLike.java b/src/main/java/com/hackathonteam1/refreshrator/entity/RecipeLike.java index 269b472..227cdb1 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/entity/RecipeLike.java +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/RecipeLike.java @@ -9,7 +9,7 @@ import lombok.NoArgsConstructor; import lombok.Setter; -@Entity(name = "like") +@Entity(name = "recipe_like") @Getter @Setter @NoArgsConstructor From b97f5c8966edf10e3f684ec026126fcb73100564 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 21 Jul 2024 20:38:03 +0900 Subject: [PATCH 124/212] =?UTF-8?q?fix:=20Recipe=20=EC=88=98=EC=A0=95=20-?= =?UTF-8?q?=20#43=20Recipe=20=EC=97=94=ED=8B=B0=ED=8B=B0=20=EB=82=B4?= =?UTF-8?q?=EC=97=90=20=EB=88=84=EB=9D=BD=EB=90=9C=20IngredientRecipe=20On?= =?UTF-8?q?eToMany=ED=95=84=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hackathonteam1/refreshrator/entity/Recipe.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/Recipe.java b/src/main/java/com/hackathonteam1/refreshrator/entity/Recipe.java index 9b29fcc..3491264 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/entity/Recipe.java +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/Recipe.java @@ -25,6 +25,9 @@ public class Recipe extends BaseEntity{ @OneToMany(mappedBy = "recipe", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) private List recipeLikes; + @OneToMany(mappedBy = "recipe", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) + private List ingredientRecipes; + @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) @JoinColumn(name = "image_id") private Image image; From 3e35bcaf52f1178150ab78cb116a8ac90a27d1af Mon Sep 17 00:00:00 2001 From: jihyeonEom Date: Sun, 21 Jul 2024 21:46:17 +0900 Subject: [PATCH 125/212] =?UTF-8?q?feat:=20=EC=9E=AC=EB=A3=8C=20=EA=B2=80?= =?UTF-8?q?=EC=83=89=20API=20=EC=B6=94=EA=B0=80=20-=20#45?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/IngredientController.java | 6 +++++- .../service/IngredientService.java | 21 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/IngredientController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/IngredientController.java index a620371..53ab111 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/IngredientController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/IngredientController.java @@ -1,7 +1,6 @@ package com.hackathonteam1.refreshrator.controller; import com.hackathonteam1.refreshrator.dto.ResponseDto; -import com.hackathonteam1.refreshrator.dto.response.ingredient.IngredientDto; import com.hackathonteam1.refreshrator.dto.response.ingredient.IngredientListDto; import com.hackathonteam1.refreshrator.service.IngredientService; import lombok.AllArgsConstructor; @@ -24,4 +23,9 @@ public ResponseEntity> showAllIngredients() { } // DB에 있는 재료 검색 + @GetMapping("/search") + public ResponseEntity> searchIngredientByName(@RequestParam String name) { + IngredientListDto ingredientListDto = ingredientService.searchIngredientByName(name); + return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "재료 검색 성공", ingredientListDto), HttpStatus.OK); + } } diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/IngredientService.java b/src/main/java/com/hackathonteam1/refreshrator/service/IngredientService.java index b19b070..957990c 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/IngredientService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/IngredientService.java @@ -3,6 +3,8 @@ import com.hackathonteam1.refreshrator.dto.response.ingredient.IngredientDto; import com.hackathonteam1.refreshrator.dto.response.ingredient.IngredientListDto; import com.hackathonteam1.refreshrator.entity.Ingredient; +import com.hackathonteam1.refreshrator.exception.NotFoundException; +import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; import com.hackathonteam1.refreshrator.repository.IngredientRepository; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; @@ -28,4 +30,23 @@ public IngredientListDto showAllIngredients() { } return new IngredientListDto(ingredientDtoList); } + + public IngredientListDto searchIngredientByName(String name) { + List ingredients = ingredientRepository.findAll(); + List ingredientDtoList = new ArrayList<>(); + + for(Ingredient ingredient : ingredients) { + if(ingredient.getName().contains(name)) { // 해당 검색어를 포함하는 모든 재료를 찾는다. + IngredientDto ingredientDto = IngredientDto.builder() + .id(ingredient.getId()) + .name(ingredient.getName()) + .build(); + ingredientDtoList.add(ingredientDto); + } + } + if(ingredientDtoList.isEmpty()) { + throw new NotFoundException(ErrorCode.INGREDIENT_NOT_FOUND); + } + return new IngredientListDto(ingredientDtoList); + } } From 797a65d40dc050125358475f2abd88d021767acf Mon Sep 17 00:00:00 2001 From: juryheed Date: Mon, 22 Jul 2024 20:26:21 +0900 Subject: [PATCH 126/212] =?UTF-8?q?feat:=20=EC=9E=AC=EB=A3=8C=20=EB=8B=A8?= =?UTF-8?q?=EA=B1=B4=EC=A1=B0=ED=9A=8C=20Dto=EC=9E=91=EC=84=B1=20-=20#49?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fridgeItem/FridgeItemResponseData.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/dto/response/fridgeItem/FridgeItemResponseData.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/response/fridgeItem/FridgeItemResponseData.java b/src/main/java/com/hackathonteam1/refreshrator/dto/response/fridgeItem/FridgeItemResponseData.java new file mode 100644 index 0000000..50ace0a --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/response/fridgeItem/FridgeItemResponseData.java @@ -0,0 +1,29 @@ +package com.hackathonteam1.refreshrator.dto.response.fridgeItem; + +import com.hackathonteam1.refreshrator.entity.FridgeItem; +import com.hackathonteam1.refreshrator.entity.Ingredient; +import lombok.Builder; +import lombok.Getter; + +import java.time.LocalDate; + +@Builder +@Getter +public class FridgeItemResponseData { + + private String ingredientName; + private LocalDate expiredDate; + private Integer quantity; + private FridgeItem.Storage storage; + private String memo; + + public static FridgeItemResponseData fromFridgeItem(FridgeItem fridgeItem) { + return FridgeItemResponseData.builder() + .ingredientName(fridgeItem.getIngredient().getName()) + .expiredDate(fridgeItem.getExpiredDate()) + .quantity(fridgeItem.getQuantity()) + .storage(fridgeItem.getStorage()) + .memo(fridgeItem.getMemo()) + .build(); + } +} From 1cd961358cd82b4c87dd92092ba76716f6583286 Mon Sep 17 00:00:00 2001 From: juryheed Date: Mon, 22 Jul 2024 20:28:43 +0900 Subject: [PATCH 127/212] =?UTF-8?q?feat:=20=EC=9E=AC=EB=A3=8C=20=EB=8B=A8?= =?UTF-8?q?=EA=B1=B4=EC=A1=B0=ED=9A=8C=20=EB=B9=84=EC=A7=80=EB=8B=88?= =?UTF-8?q?=EC=8A=A4=20=EB=A1=9C=EC=A7=81=20=EC=9E=91=EC=84=B1=20-=20#49?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/service/FridgeService.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java b/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java index 1b55a53..eb9a81c 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java @@ -1,6 +1,7 @@ package com.hackathonteam1.refreshrator.service; import com.hackathonteam1.refreshrator.dto.request.fridge.AddFridgeDto; +import com.hackathonteam1.refreshrator.dto.response.fridgeItem.FridgeItemResponseData; import com.hackathonteam1.refreshrator.entity.Fridge; import com.hackathonteam1.refreshrator.entity.FridgeItem; import com.hackathonteam1.refreshrator.entity.Ingredient; @@ -77,6 +78,19 @@ public void deleteIngredientInFridge(UUID id, User user){ fridgeItemRepository.delete(fridgeItem); } + //냉장고에 있는 재료 단건 조회 메서드 + public FridgeItemResponseData detailIngredientInFridge(UUID id,User user){ + //조회할 재료 찾기 + FridgeItem fridgeItem=findFridgeItem(id); + + //권한 확인 + checkAuth(fridgeItem.getFridge().getUser(),user); + + //조회 하기 + return FridgeItemResponseData.fromFridgeItem(fridgeItem); + } + + //저장방법 결정 메서드 private FridgeItem.Storage defindStorage(String storage){ return switch (storage){ From fb302dabf2a05191792e90af2040fe18400e8588 Mon Sep 17 00:00:00 2001 From: juryheed Date: Mon, 22 Jul 2024 20:29:39 +0900 Subject: [PATCH 128/212] =?UTF-8?q?feat:=20=EC=9E=AC=EB=A3=8C=20=EB=8B=A8?= =?UTF-8?q?=EA=B1=B4=EC=A1=B0=ED=9A=8C=20=EC=BB=A8=ED=8A=B8=EB=A1=A4?= =?UTF-8?q?=EB=9F=AC=20=EC=9E=91=EC=84=B1=20-=20#49=20=EA=B2=BD=EB=A1=9C?= =?UTF-8?q?=EB=8A=94=20/fridge/ingredients/{ingredients=5Fid}?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/controller/FridgeController.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java index 7f4b5cd..0aac3a8 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java @@ -3,6 +3,7 @@ import com.hackathonteam1.refreshrator.annotation.AuthenticatedUser; import com.hackathonteam1.refreshrator.dto.ResponseDto; import com.hackathonteam1.refreshrator.dto.request.fridge.AddFridgeDto; +import com.hackathonteam1.refreshrator.dto.response.fridgeItem.FridgeItemResponseData; import com.hackathonteam1.refreshrator.entity.User; import com.hackathonteam1.refreshrator.service.FridgeService; import jakarta.validation.Valid; @@ -40,4 +41,11 @@ public ResponseEntity> deleteIngredientInFridge(@PathVariable( fridgeService.deleteIngredientInFridge(id, user); return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "냉장고에 재료 삭제 성공"), HttpStatus.OK); } + + //냉장고에 있는 재료 단건 조회 메서드 + @GetMapping("/ingredients/{ingredient_id}") + public ResponseEntity> detailIngredientInFridge(@PathVariable("ingredient_id") UUID id , @AuthenticatedUser User user) { + FridgeItemResponseData fridgeItemResponseData = fridgeService.detailIngredientInFridge(id, user); + return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "냉장고에 재료 조회 성공",fridgeItemResponseData),HttpStatus.OK); + } } From 4b25995b434cf3989459c9c19d6e0b818a07d947 Mon Sep 17 00:00:00 2001 From: jihyeonEom Date: Mon, 22 Jul 2024 22:02:46 +0900 Subject: [PATCH 129/212] =?UTF-8?q?feat:=20=EB=83=89=EC=9E=A5=EA=B3=A0?= =?UTF-8?q?=EC=97=90=20=EC=9E=88=EB=8A=94=20=EB=AA=A8=EB=93=A0=20=EC=9E=AC?= =?UTF-8?q?=EB=A3=8C=20=EC=A1=B0=ED=9A=8C=20API=20=EC=B6=94=EA=B0=80=20-?= =?UTF-8?q?=20#52?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/FridgeController.java | 10 ++++++++ .../refreshrator/service/FridgeService.java | 24 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java index 7f4b5cd..354869e 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java @@ -3,6 +3,8 @@ import com.hackathonteam1.refreshrator.annotation.AuthenticatedUser; import com.hackathonteam1.refreshrator.dto.ResponseDto; import com.hackathonteam1.refreshrator.dto.request.fridge.AddFridgeDto; +import com.hackathonteam1.refreshrator.dto.response.ingredient.IngredientDto; +import com.hackathonteam1.refreshrator.dto.response.ingredient.IngredientListDto; import com.hackathonteam1.refreshrator.entity.User; import com.hackathonteam1.refreshrator.service.FridgeService; import jakarta.validation.Valid; @@ -40,4 +42,12 @@ public ResponseEntity> deleteIngredientInFridge(@PathVariable( fridgeService.deleteIngredientInFridge(id, user); return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "냉장고에 재료 삭제 성공"), HttpStatus.OK); } + + // 냉장고에 있는 모든 재료 조회 + @GetMapping("/ingredients") + public ResponseEntity> getIngredientsInFridge(@AuthenticatedUser User user) { + IngredientListDto ingredientListDto = fridgeService.getIngredientsInFridge(user); + return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "냉장고에 있는 모든 재료 조회 성공", ingredientListDto), HttpStatus.OK); + } + } diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java b/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java index 1b55a53..368e383 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java @@ -1,6 +1,8 @@ package com.hackathonteam1.refreshrator.service; import com.hackathonteam1.refreshrator.dto.request.fridge.AddFridgeDto; +import com.hackathonteam1.refreshrator.dto.response.ingredient.IngredientDto; +import com.hackathonteam1.refreshrator.dto.response.ingredient.IngredientListDto; import com.hackathonteam1.refreshrator.entity.Fridge; import com.hackathonteam1.refreshrator.entity.FridgeItem; import com.hackathonteam1.refreshrator.entity.Ingredient; @@ -14,6 +16,8 @@ import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.List; import java.util.UUID; @Service @@ -77,6 +81,26 @@ public void deleteIngredientInFridge(UUID id, User user){ fridgeItemRepository.delete(fridgeItem); } + // 냉장고에 모든 재료 조회 + public IngredientListDto getIngredientsInFridge(User user) { + // 유저의 냉장고 찾기 + Fridge fridge = findFridge(user); + + // 권힌 확인 + checkAuth(fridge.getUser(),user); + + List ingredientDtoList = new ArrayList<>(); + + for(FridgeItem fridgeItem : fridge.getFridgeItem()){ + IngredientDto ingredientDto = IngredientDto.builder() + .id(fridgeItem.getIngredient().getId()) + .name(fridgeItem.getIngredient().getName()) + .build(); + ingredientDtoList.add(ingredientDto); + } + return new IngredientListDto(ingredientDtoList); + } + //저장방법 결정 메서드 private FridgeItem.Storage defindStorage(String storage){ return switch (storage){ From d4d630a5c4efe32e3f92d7197be9f5c6b21cdb0d Mon Sep 17 00:00:00 2001 From: jher235 Date: Mon, 22 Jul 2024 22:48:45 +0900 Subject: [PATCH 130/212] =?UTF-8?q?feat:=20=EB=B0=B0=ED=8F=AC=EB=A5=BC=20?= =?UTF-8?q?=EC=9C=84=ED=95=9C=20=EB=8F=84=EC=BB=A4=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20-#48=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EB=95=8C=EB=AC=B8=EC=97=90=20Build?= =?UTF-8?q?=EA=B0=80=20=EB=90=98=EC=A7=80=20=EC=95=8A=EC=95=84=20test?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=EC=9D=84=20=EC=A3=BC=EC=84=9D=EC=B2=98?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 4 ++++ .../RefreshratorApplicationTests.java | 18 +++++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..76171a8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,4 @@ +FROM openjdk:17-jdk +ARG JAR_FILE=build/libs/*.jar +COPY ${JAR_FILE} app.jar +ENTRYPOINT ["java", "-Dspring.profiles.active=docker", "-Duser.timezone=Asia/Seoul", "-jar", "app.jar"] diff --git a/src/test/java/com/hackathonteam1/refreshrator/RefreshratorApplicationTests.java b/src/test/java/com/hackathonteam1/refreshrator/RefreshratorApplicationTests.java index 32dba6c..5ed0a67 100644 --- a/src/test/java/com/hackathonteam1/refreshrator/RefreshratorApplicationTests.java +++ b/src/test/java/com/hackathonteam1/refreshrator/RefreshratorApplicationTests.java @@ -2,12 +2,12 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -class RefreshratorApplicationTests { - - @Test - void contextLoads() { - } - -} +// +//@SpringBootTest +//class RefreshratorApplicationTests { +// +// @Test +// void contextLoads() { +// } +// +//} From e0ade58e3b38b8f0850ef7512f49245d68c5a5ec Mon Sep 17 00:00:00 2001 From: juryheed Date: Mon, 22 Jul 2024 23:35:15 +0900 Subject: [PATCH 131/212] =?UTF-8?q?feat:=20User=EC=99=80=20Fridge=EC=9D=98?= =?UTF-8?q?=20=EA=B4=80=EA=B3=84=20=EC=88=98=EC=A0=95=20-=20#51=20User?= =?UTF-8?q?=EA=B0=80=20=EC=82=AD=EC=A0=9C=EB=90=98=EB=A9=B4=20Fridge?= =?UTF-8?q?=EB=8F=84=20=EC=82=AD=EC=A0=9C=EB=90=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hackathonteam1/refreshrator/entity/Fridge.java | 5 ++--- .../java/com/hackathonteam1/refreshrator/entity/User.java | 3 +++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/Fridge.java b/src/main/java/com/hackathonteam1/refreshrator/entity/Fridge.java index a5358d9..181d0c9 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/entity/Fridge.java +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/Fridge.java @@ -18,8 +18,7 @@ public class Fridge extends BaseEntity{ @OneToMany(mappedBy = "fridge", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) private List fridgeItem; - @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) - @JoinColumn(name = "user_id") + @OneToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id",nullable = false) private User user; - } diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/User.java b/src/main/java/com/hackathonteam1/refreshrator/entity/User.java index 699d592..5aa28de 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/entity/User.java +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/User.java @@ -29,4 +29,7 @@ public class User extends BaseEntity{ @OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) private List recipeLikes; + + @OneToOne(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) + private Fridge fridge; } From 6dff8c32f26d2caa382b7556d8ec733ffee28f41 Mon Sep 17 00:00:00 2001 From: juryheed Date: Mon, 22 Jul 2024 23:36:24 +0900 Subject: [PATCH 132/212] =?UTF-8?q?feat:=20=ED=9A=8C=EC=9B=90=ED=83=88?= =?UTF-8?q?=ED=87=B4=20=EB=B9=84=EC=A6=88=EB=8B=88=EC=8A=A4=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=9E=91=EC=84=B1=20-=20#51?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hackathonteam1/refreshrator/service/AuthService.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java b/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java index de06fc1..b010087 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java @@ -52,6 +52,12 @@ public void signin(SigninDto signinDto){ fridgeRepository.save(fridge); } + //회원탈퇴 + public void leave(User user){ + //탈퇴 + userRepository.delete(user); + } + //로그인 public TokenResponseDto login(LoginDto loginDto){ From cddcfc4509c501548a9023241966455b14443672 Mon Sep 17 00:00:00 2001 From: juryheed Date: Mon, 22 Jul 2024 23:44:12 +0900 Subject: [PATCH 133/212] =?UTF-8?q?feat:=20=ED=9A=8C=EC=9B=90=ED=83=88?= =?UTF-8?q?=ED=87=B4=20=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20-=20#51=20=EA=B2=BD=EB=A1=9C=EB=8A=94=20auth/leave?= =?UTF-8?q?=20user=EA=B0=80=20=ED=85=8C=EC=9D=B4=EB=B8=94=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=82=AD=EC=A0=9C=EB=90=98=EB=A9=B4=20=ED=82=A4?= =?UTF-8?q?=ED=82=A4=20=EB=A7=8C=EB=A3=8C=EB=A1=9C=20=EC=9D=B8=ED=95=B4=20?= =?UTF-8?q?=EC=9E=90=EB=8F=99=20=EB=A1=9C=EA=B7=B8=EC=95=84=EC=9B=83?= =?UTF-8?q?=EC=9D=B4=20=EB=90=98=EA=B2=8C=20=ED=96=88=EC=9D=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/AuthController.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java index a1875bc..3057bdf 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java @@ -1,11 +1,13 @@ package com.hackathonteam1.refreshrator.controller; +import com.hackathonteam1.refreshrator.annotation.AuthenticatedUser; import com.hackathonteam1.refreshrator.authentication.AuthenticationExtractor; import com.hackathonteam1.refreshrator.authentication.JwtEncoder; import com.hackathonteam1.refreshrator.dto.ResponseDto; import com.hackathonteam1.refreshrator.dto.request.auth.LoginDto; import com.hackathonteam1.refreshrator.dto.request.auth.SigninDto; import com.hackathonteam1.refreshrator.dto.response.auth.TokenResponseDto; +import com.hackathonteam1.refreshrator.entity.User; import com.hackathonteam1.refreshrator.service.AuthService; import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.Valid; @@ -33,6 +35,22 @@ public ResponseEntity> signup(@RequestBody @Valid SigninDto si return new ResponseEntity<>(ResponseDto.res(HttpStatus.CREATED, "회원 가입 완료"), HttpStatus.CREATED); } + //회원 탈퇴 + @DeleteMapping("/leave") + public ResponseEntity> leave(@AuthenticatedUser User user,HttpServletResponse response) { + authService.leave(user); + + ResponseCookie cookie = ResponseCookie.from("AccessToken", null) + .maxAge(0) + .path("/") + .httpOnly(true) + .sameSite("None").secure(true) + .build(); + response.addHeader("set-cookie", cookie.toString()); + + return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "회원 탈퇴 완료"), HttpStatus.OK); + } + //로그인 @PostMapping("/login") public ResponseEntity> login(@RequestBody @Valid LoginDto loginDto, HttpServletResponse response) { @@ -53,7 +71,7 @@ public ResponseEntity> login(@RequestBody @Valid LoginDto logi //로그아웃 @PostMapping("/logout") - public ResponseEntity> logout(final HttpServletResponse response) { + public ResponseEntity> logout(@AuthenticatedUser User user, final HttpServletResponse response) { ResponseCookie cookie = ResponseCookie.from("AccessToken", null) .maxAge(0) .path("/") From 65f9356e14abd6d05f1fe541b576ce965a21475a Mon Sep 17 00:00:00 2001 From: juryheed Date: Mon, 22 Jul 2024 23:45:47 +0900 Subject: [PATCH 134/212] =?UTF-8?q?feat:=20=EC=9D=B8=ED=84=B0=EC=85=89?= =?UTF-8?q?=ED=84=B0=20=EA=B2=BD=EB=A1=9C=20=EC=84=A4=EC=A0=95=20-=20#51?= =?UTF-8?q?=20=EC=9D=B8=ED=84=B0=EC=85=89=ED=84=B0=20=EA=B2=BD=EB=A1=9C?= =?UTF-8?q?=EC=97=90=20auth/leave=EB=A5=BC=20=EB=93=B1=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/config/AuthenticationConfig.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/config/AuthenticationConfig.java b/src/main/java/com/hackathonteam1/refreshrator/config/AuthenticationConfig.java index a3cf1af..94a6795 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/config/AuthenticationConfig.java +++ b/src/main/java/com/hackathonteam1/refreshrator/config/AuthenticationConfig.java @@ -21,8 +21,8 @@ public class AuthenticationConfig implements WebMvcConfigurer { @Override public void addInterceptors(final InterceptorRegistry registry) { registry.addInterceptor(authenticationInterceptor) - .addPathPatterns("/fridge/**","/recipes/**") - .excludePathPatterns("/auth/signin", "/auth/login","/auth/logout"); + .addPathPatterns("/fridge/**","/recipes/**","/auth/leave","/auth/logout") + .excludePathPatterns("/auth/signin", "/auth/login"); } //컨트롤러 메서드 파라미터에 인증된 유저가 들어가도록 함 From 1639582e3df809584a0f46e3a6e79ee4111a5c4b Mon Sep 17 00:00:00 2001 From: jher235 Date: Tue, 23 Jul 2024 01:45:30 +0900 Subject: [PATCH 135/212] =?UTF-8?q?feat:=20=ED=8E=98=EC=9D=B4=EC=A7=80?= =?UTF-8?q?=EB=84=A4=EC=9D=B4=EC=85=98=20Dto=20=EC=9E=91=EC=84=B1=20-=20#5?= =?UTF-8?q?5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/dto/response/PaginationDto.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/dto/response/PaginationDto.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/response/PaginationDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/response/PaginationDto.java new file mode 100644 index 0000000..1661a75 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/response/PaginationDto.java @@ -0,0 +1,16 @@ +package com.hackathonteam1.refreshrator.dto.response; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.springframework.data.domain.Page; + +@Getter +@AllArgsConstructor +public class PaginationDto { + private int currentPage; + private int totalPage; + + public static PaginationDto paginationDto(Page page){ + return new PaginationDto(page.getNumber(), page.getTotalPages()-1); + } +} From 727f8c42ae949978e23bc33fedc4a9231ceaef2c Mon Sep 17 00:00:00 2001 From: jher235 Date: Tue, 23 Jul 2024 01:45:55 +0900 Subject: [PATCH 136/212] =?UTF-8?q?feat:=20=EB=A0=88=EC=8B=9C=ED=94=BC=20D?= =?UTF-8?q?to=20=EC=9E=91=EC=84=B1=20-=20#55=20=EB=AA=A9=EB=A1=9D=EC=97=90?= =?UTF-8?q?=20=EC=82=AC=EC=9A=A9=EB=90=A0=20=EB=A0=88=EC=8B=9C=ED=94=BC=20?= =?UTF-8?q?Dto.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/recipe/RecipeDto.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/RecipeDto.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/RecipeDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/RecipeDto.java new file mode 100644 index 0000000..6304f07 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/RecipeDto.java @@ -0,0 +1,16 @@ +package com.hackathonteam1.refreshrator.dto.response.recipe; + +import com.hackathonteam1.refreshrator.entity.Recipe; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class RecipeDto { + + private String name; + private int likeCount; + public static RecipeDto mapping(Recipe recipe){ + return new RecipeDto(recipe.getName(), recipe.getLikeCount()); + } +} From 204141d78a18ee1749e2434da1b947608019069d Mon Sep 17 00:00:00 2001 From: jher235 Date: Tue, 23 Jul 2024 01:46:45 +0900 Subject: [PATCH 137/212] =?UTF-8?q?feat:=20=EB=A0=88=EC=8B=9C=ED=94=BC=20?= =?UTF-8?q?=EB=AA=A9=EB=A1=9D=20Dto=20=EC=9E=91=EC=84=B1=20-=20#55=20?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=EB=84=A4=EC=9D=B4=EC=85=98=EA=B3=BC?= =?UTF-8?q?=20=EB=A0=88=EC=8B=9C=ED=94=BC=EB=A5=BC=20=EB=8B=B4=EB=8A=94=20?= =?UTF-8?q?Dto=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/recipe/RecipeListDto.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/RecipeListDto.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/RecipeListDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/RecipeListDto.java new file mode 100644 index 0000000..34b920f --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/RecipeListDto.java @@ -0,0 +1,28 @@ +package com.hackathonteam1.refreshrator.dto.response.recipe; + +import com.hackathonteam1.refreshrator.dto.response.PaginationDto; +import com.hackathonteam1.refreshrator.entity.Recipe; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import org.springframework.data.domain.Page; + +import java.util.List; +import java.util.stream.Collectors; + +@Getter +@AllArgsConstructor +@Builder +public class RecipeListDto { + private List recipeList; + private PaginationDto pagination; + + public static RecipeListDto mapping(Page page){ + return RecipeListDto.builder() + .recipeList(page.stream() + .map((i-> RecipeDto.mapping(i))) + .collect(Collectors.toList())) + .pagination(PaginationDto.paginationDto(page)) + .build(); + } +} From b6c3702fa83f41d2e9e4e624402510cad833de64 Mon Sep 17 00:00:00 2001 From: jher235 Date: Tue, 23 Jul 2024 01:47:17 +0900 Subject: [PATCH 138/212] =?UTF-8?q?feat:=20=EC=A1=B4=EC=9E=AC=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=20=ED=8E=98=EC=9D=B4=EC=A7=80=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20=EC=98=A4=EB=A5=98=20-=20#55?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/exception/errorcode/ErrorCode.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java index 650243b..6dd91a5 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java +++ b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java @@ -33,6 +33,7 @@ public enum ErrorCode { INGREDIENT_RECIPE_NOT_FOUND("4043", "레시피의 재료를 찾을 수 없습니다."), FRIDGE_NOT_FOUND("4044","냉장고를 찾을 수 없습니다"), FRIDGE_ITEM_NOT_FOUND("4045","냉장고에 등록된 재료 정보를 찾을 수 없습니다."), + PAGE_NOT_FOUND("4046", "페이지를 찾을 수 없습니다"), //ConflictException DUPLICATED_EMAIL("4090", "이미 사용 중인 이메일입니다."), From 554c0f0289e1439f95a375320eb7027a2f07b39a Mon Sep 17 00:00:00 2001 From: jher235 Date: Tue, 23 Jul 2024 01:48:27 +0900 Subject: [PATCH 139/212] =?UTF-8?q?feat:=20=EC=A1=B4=EC=9E=AC=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=20=ED=85=8C=EC=9D=B4=EB=B8=94?= =?UTF-8?q?=EC=9D=84=20=EC=B6=9C=EB=A0=A5=20=EC=8B=9C=20=EC=A0=9C=EC=99=B8?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=9E=98=EB=AA=BB=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=ED=95=9C=20=EA=B1=B8=20=EC=88=98=EC=A0=95=20=20-=20#5?= =?UTF-8?q?5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/hackathonteam1/refreshrator/entity/Image.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/Image.java b/src/main/java/com/hackathonteam1/refreshrator/entity/Image.java index 6d7ecf8..e162d34 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/entity/Image.java +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/Image.java @@ -13,7 +13,6 @@ @AllArgsConstructor @NoArgsConstructor @Builder -@ToString(exclude = "recipe") public class Image extends BaseEntity{ @Column(nullable = false) From f2e6db3fb10d52d2ad8da8242660d810fcc28189 Mon Sep 17 00:00:00 2001 From: jher235 Date: Tue, 23 Jul 2024 01:50:10 +0900 Subject: [PATCH 140/212] =?UTF-8?q?feat:=20=EB=A0=88=EC=8B=9C=ED=94=BC=20?= =?UTF-8?q?=ED=95=84=EB=93=9C=EC=97=90=20@Formula=20=EC=82=AC=EC=9A=A9=20-?= =?UTF-8?q?=20#55=20@Formula=EB=A5=BC=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EC=97=AC=20=EC=A1=B0=ED=9A=8C=EC=8B=9C=20=EC=BF=BC=EB=A6=AC?= =?UTF-8?q?=EB=A5=BC=20=ED=86=B5=ED=95=B4=20=EC=A2=8B=EC=95=84=EC=9A=94=20?= =?UTF-8?q?=EA=B0=9C=EC=88=98=EB=A5=BC=20=EA=B0=80=EC=A0=B8=EC=98=AC=20?= =?UTF-8?q?=EC=88=98=20=EC=9E=88=EB=8F=84=EB=A1=9D=20=EC=84=A4=EC=A0=95?= =?UTF-8?q?=ED=95=A8.=20->=20=EB=8B=A4=EB=A7=8C=20=EC=84=B1=EB=8A=A5?= =?UTF-8?q?=EC=83=81=20=EB=AC=B8=EC=A0=9C=EA=B0=80=20=EC=83=9D=EA=B8=B8=20?= =?UTF-8?q?=EC=88=98=20=EC=9E=88=EA=B8=B0=20=EB=95=8C=EB=AC=B8=EC=97=90(n+?= =?UTF-8?q?1)=20=EC=B6=94=ED=9B=84=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= =?UTF-8?q?=EC=9D=B4=20=ED=95=84=EC=9A=94=ED=95=A0=20=EA=B2=83=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=B4=EC=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hackathonteam1/refreshrator/entity/Recipe.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/Recipe.java b/src/main/java/com/hackathonteam1/refreshrator/entity/Recipe.java index 3491264..4adbb5f 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/entity/Recipe.java +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/Recipe.java @@ -2,6 +2,7 @@ import jakarta.persistence.*; import lombok.*; +import org.hibernate.annotations.Formula; import java.util.List; @@ -32,6 +33,9 @@ public class Recipe extends BaseEntity{ @JoinColumn(name = "image_id") private Image image; + @Formula("(select count(rl.id) from recipe_like rl where rl.recipe_id = id)") + private int likeCount; + public void updateName(String name){ this.name = name; } From 72d351ebe214f0aff2df7d760ad235a774402b1b Mon Sep 17 00:00:00 2001 From: jher235 Date: Tue, 23 Jul 2024 01:50:44 +0900 Subject: [PATCH 141/212] =?UTF-8?q?feat:=20=EB=A0=88=EC=8B=9C=ED=94=BC=20?= =?UTF-8?q?=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=EB=A5=BC=20=EC=9C=84?= =?UTF-8?q?=ED=95=9C=20=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20-=20#55?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/controller/RecipeController.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java index aefedf5..bef1245 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java @@ -7,6 +7,7 @@ import com.hackathonteam1.refreshrator.dto.request.recipe.ModifyRecipeDto; import com.hackathonteam1.refreshrator.dto.request.recipe.RegisterRecipeDto; import com.hackathonteam1.refreshrator.dto.response.recipe.DetailRecipeDto; +import com.hackathonteam1.refreshrator.dto.response.recipe.RecipeListDto; import com.hackathonteam1.refreshrator.entity.User; import com.hackathonteam1.refreshrator.service.RecipeService; import jakarta.validation.Valid; @@ -23,6 +24,13 @@ public class RecipeController { private final RecipeService recipeService; + @GetMapping + public ResponseEntity> getList(@RequestParam(name = "keyword",defaultValue = "")String keyword, @RequestParam(name = "type", defaultValue = "newest")String type, + @RequestParam(name = "page", defaultValue = "0")int page, @RequestParam(name = "size", defaultValue = "10")int size){ + RecipeListDto recipeListDto = recipeService.getList(keyword, type, page, size); + return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK,"레시피 목록 조회 성공", recipeListDto),HttpStatus.OK); + } + @PostMapping public ResponseEntity> register( @RequestBody @Valid RegisterRecipeDto registerRecipeDto, @AuthenticatedUser User user){ @@ -63,5 +71,4 @@ public ResponseEntity> deleteIngredientRecipe(@PathVariable("r return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "레시피 재료 삭제 성공"),HttpStatus.OK); } - } From 31df3fc4eaf60d0a1934895dc961193e40fa04c1 Mon Sep 17 00:00:00 2001 From: jher235 Date: Tue, 23 Jul 2024 01:51:13 +0900 Subject: [PATCH 142/212] =?UTF-8?q?feat:=20=EB=A0=88=EC=8B=9C=ED=94=BC=20?= =?UTF-8?q?=EA=B2=80=EC=83=89=20=EB=B0=8F=20=ED=8E=98=EC=9D=B4=EC=A7=80=20?= =?UTF-8?q?=EB=84=A4=EC=9D=B4=EC=85=98=EC=9D=84=20=EC=9C=84=ED=95=9C=20Jpa?= =?UTF-8?q?Repo=20=EC=9E=91=EC=84=B1=20-=20#55?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/repository/RecipeRepository.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/repository/RecipeRepository.java b/src/main/java/com/hackathonteam1/refreshrator/repository/RecipeRepository.java index f55b37b..b0109f3 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/repository/RecipeRepository.java +++ b/src/main/java/com/hackathonteam1/refreshrator/repository/RecipeRepository.java @@ -1,9 +1,13 @@ package com.hackathonteam1.refreshrator.repository; import com.hackathonteam1.refreshrator.entity.Recipe; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import java.util.UUID; public interface RecipeRepository extends JpaRepository { + Page findAllByNameContaining(String keyword, Pageable pageable); + Page findAll(Pageable pageable); } From 44160c30604898c13873b7ec4e9383264bb800e5 Mon Sep 17 00:00:00 2001 From: jher235 Date: Tue, 23 Jul 2024 01:51:28 +0900 Subject: [PATCH 143/212] =?UTF-8?q?feat:=20=EB=A0=88=EC=8B=9C=ED=94=BC=20?= =?UTF-8?q?=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=EB=A5=BC=20=EC=9C=84?= =?UTF-8?q?=ED=95=9C=20=EB=B9=84=EC=A6=88=EB=8B=88=EC=8A=A4=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=9E=91=EC=84=B1=20-=20#55?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/service/RecipeService.java | 4 +++ .../service/RecipeServiceImpl.java | 34 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java index 73347f3..ad826c6 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java @@ -5,6 +5,7 @@ import com.hackathonteam1.refreshrator.dto.request.recipe.ModifyRecipeDto; import com.hackathonteam1.refreshrator.dto.request.recipe.RegisterRecipeDto; import com.hackathonteam1.refreshrator.dto.response.recipe.DetailRecipeDto; +import com.hackathonteam1.refreshrator.dto.response.recipe.RecipeListDto; import com.hackathonteam1.refreshrator.entity.Recipe; import com.hackathonteam1.refreshrator.entity.User; @@ -12,6 +13,9 @@ public interface RecipeService { + //레시피 목록 조회 + public RecipeListDto getList(String keyword, String type, int page, int size); + //레시피 등록 public void register(RegisterRecipeDto registerRecipeDto, User user); diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java index cd4544e..58f463f 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java @@ -5,6 +5,7 @@ import com.hackathonteam1.refreshrator.dto.request.recipe.ModifyRecipeDto; import com.hackathonteam1.refreshrator.dto.request.recipe.RegisterRecipeDto; import com.hackathonteam1.refreshrator.dto.response.recipe.DetailRecipeDto; +import com.hackathonteam1.refreshrator.dto.response.recipe.RecipeListDto; import com.hackathonteam1.refreshrator.entity.Ingredient; import com.hackathonteam1.refreshrator.entity.IngredientRecipe; import com.hackathonteam1.refreshrator.entity.Recipe; @@ -17,6 +18,10 @@ import com.hackathonteam1.refreshrator.repository.IngredientRepository; import com.hackathonteam1.refreshrator.repository.RecipeRepository; import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -34,6 +39,29 @@ public class RecipeServiceImpl implements RecipeService{ private final IngredientRepository ingredientRepository; private final IngredientRecipeRepository ingredientRecipeRepository; + @Override + public RecipeListDto getList(String keyword, String type, int page, int size) { + + Sort sort; + if (type.equals("newest")){ + sort = Sort.by(Sort.Order.desc("createdAt")); + }else{ + sort = Sort.by(Sort.Order.desc("likeCount")); + } + + Pageable pageable = PageRequest.of(page, size, sort); + + if(keyword.equals("")){ + Page recipePage = recipeRepository.findAll(pageable); + checkValidPage(recipePage, page); + return RecipeListDto.mapping(recipePage); + } + + Page recipePage = recipeRepository.findAllByNameContaining(keyword, pageable); + checkValidPage(recipePage, page); + return RecipeListDto.mapping(recipePage); + } + @Override @Transactional public void register(RegisterRecipeDto registerRecipeDto, User user) { @@ -158,4 +186,10 @@ private void checkAuth(User writer, User user){ throw new ForbiddenException(ErrorCode.RECIPE_FORBIDDEN); } } + + private void checkValidPage(Page pages, int page){ + if(pages.getTotalPages() <= page && page != 0){ + throw new NotFoundException(ErrorCode.PAGE_NOT_FOUND); + } + } } From 0f22cd417b35323b8c297c485f6eac0f36aa486f Mon Sep 17 00:00:00 2001 From: jher235 Date: Tue, 23 Jul 2024 02:01:19 +0900 Subject: [PATCH 144/212] =?UTF-8?q?feat:=20=ED=8E=98=EC=9D=B4=EC=A7=80?= =?UTF-8?q?=EB=84=A4=EC=9D=B4=EC=85=98=20=EB=B2=88=ED=98=B8=20=EC=B6=9C?= =?UTF-8?q?=EB=A0=A5=20=EC=88=98=EC=A0=95=20-=20#55?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hackathonteam1/refreshrator/dto/response/PaginationDto.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/response/PaginationDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/response/PaginationDto.java index 1661a75..87f0df1 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/dto/response/PaginationDto.java +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/response/PaginationDto.java @@ -11,6 +11,6 @@ public class PaginationDto { private int totalPage; public static PaginationDto paginationDto(Page page){ - return new PaginationDto(page.getNumber(), page.getTotalPages()-1); + return new PaginationDto(page.getNumber(), page.getTotalPages()); } } From 79b75c0596297e15e6477e63b633c4a4152dc108 Mon Sep 17 00:00:00 2001 From: jihyeonEom Date: Tue, 23 Jul 2024 16:53:54 +0900 Subject: [PATCH 145/212] =?UTF-8?q?feat:=20fridge=20item=20dto=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80,=20=EB=83=89=EC=9E=A5=EA=B3=A0=EC=97=90=20=EC=9E=88?= =?UTF-8?q?=EB=8A=94=20=EB=AA=A8=EB=93=A0=20=EC=9E=AC=EB=A3=8C=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EA=B8=B0=EB=8A=A5=20=EC=88=98=EC=A0=95=20-=20#52?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/FridgeController.java | 9 ++--- .../dto/response/fridge/FridgeItemDto.java | 14 +++++++ .../response/fridge/FridgeItemListDto.java | 17 +++++++++ .../refreshrator/service/FridgeService.java | 37 ++++++++++++++----- 4 files changed, 63 insertions(+), 14 deletions(-) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/dto/response/fridge/FridgeItemDto.java create mode 100644 src/main/java/com/hackathonteam1/refreshrator/dto/response/fridge/FridgeItemListDto.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java index 354869e..34911fa 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java @@ -3,8 +3,7 @@ import com.hackathonteam1.refreshrator.annotation.AuthenticatedUser; import com.hackathonteam1.refreshrator.dto.ResponseDto; import com.hackathonteam1.refreshrator.dto.request.fridge.AddFridgeDto; -import com.hackathonteam1.refreshrator.dto.response.ingredient.IngredientDto; -import com.hackathonteam1.refreshrator.dto.response.ingredient.IngredientListDto; +import com.hackathonteam1.refreshrator.dto.response.fridge.FridgeItemListDto; import com.hackathonteam1.refreshrator.entity.User; import com.hackathonteam1.refreshrator.service.FridgeService; import jakarta.validation.Valid; @@ -45,9 +44,9 @@ public ResponseEntity> deleteIngredientInFridge(@PathVariable( // 냉장고에 있는 모든 재료 조회 @GetMapping("/ingredients") - public ResponseEntity> getIngredientsInFridge(@AuthenticatedUser User user) { - IngredientListDto ingredientListDto = fridgeService.getIngredientsInFridge(user); - return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "냉장고에 있는 모든 재료 조회 성공", ingredientListDto), HttpStatus.OK); + public ResponseEntity> getIngredientsInFridge(@AuthenticatedUser User user) { + FridgeItemListDto fridgeItemListDto = fridgeService.getIngredientsInFridge(user); + return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "냉장고에 있는 모든 재료 조회 성공", fridgeItemListDto), HttpStatus.OK); } } diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/response/fridge/FridgeItemDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/response/fridge/FridgeItemDto.java new file mode 100644 index 0000000..43bf3b4 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/response/fridge/FridgeItemDto.java @@ -0,0 +1,14 @@ +package com.hackathonteam1.refreshrator.dto.response.fridge; + +import lombok.Builder; +import lombok.Getter; + +import java.util.UUID; + +@Builder +@Getter +public class FridgeItemDto { + private UUID id; + private String ingredientName; + private UUID ingredientId; +} diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/response/fridge/FridgeItemListDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/response/fridge/FridgeItemListDto.java new file mode 100644 index 0000000..409b151 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/response/fridge/FridgeItemListDto.java @@ -0,0 +1,17 @@ +package com.hackathonteam1.refreshrator.dto.response.fridge; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; + +import java.util.List; + +@Getter +@Builder +@AllArgsConstructor +public class FridgeItemListDto { + private List coldStorage; // 냉장 + private List frozen; // 냉동 + private List ambient; // 실온 + private List ExpirationDate; // 유통기한 만료 +} diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java b/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java index 368e383..7c8117e 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java @@ -1,8 +1,8 @@ package com.hackathonteam1.refreshrator.service; import com.hackathonteam1.refreshrator.dto.request.fridge.AddFridgeDto; -import com.hackathonteam1.refreshrator.dto.response.ingredient.IngredientDto; -import com.hackathonteam1.refreshrator.dto.response.ingredient.IngredientListDto; +import com.hackathonteam1.refreshrator.dto.response.fridge.FridgeItemDto; +import com.hackathonteam1.refreshrator.dto.response.fridge.FridgeItemListDto; import com.hackathonteam1.refreshrator.entity.Fridge; import com.hackathonteam1.refreshrator.entity.FridgeItem; import com.hackathonteam1.refreshrator.entity.Ingredient; @@ -16,6 +16,7 @@ import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; +import java.time.LocalDate; import java.util.ArrayList; import java.util.List; import java.util.UUID; @@ -82,23 +83,41 @@ public void deleteIngredientInFridge(UUID id, User user){ } // 냉장고에 모든 재료 조회 - public IngredientListDto getIngredientsInFridge(User user) { + public FridgeItemListDto getIngredientsInFridge(User user) { // 유저의 냉장고 찾기 Fridge fridge = findFridge(user); // 권힌 확인 checkAuth(fridge.getUser(),user); - List ingredientDtoList = new ArrayList<>(); + List coldStorageList = new ArrayList<>(); // 냉장 재료 리스트 + List frozenStorageList = new ArrayList<>(); // 냉동 재료 리스트 + List ambientStorageList = new ArrayList<>(); // 실온 재료 리스트 + List expirationDateList = new ArrayList<>(); // 유통 기한 만료 재료 리스트 for(FridgeItem fridgeItem : fridge.getFridgeItem()){ - IngredientDto ingredientDto = IngredientDto.builder() - .id(fridgeItem.getIngredient().getId()) - .name(fridgeItem.getIngredient().getName()) + FridgeItemDto fridgeItemDto = FridgeItemDto.builder() + .id(fridgeItem.getId()) + .ingredientId(fridgeItem.getIngredient().getId()) + .ingredientName(fridgeItem.getIngredient().getName()) .build(); - ingredientDtoList.add(ingredientDto); + + if(LocalDate.now().isAfter(fridgeItem.getExpiredDate())){ + // 유통 기한 만료 재료 + expirationDateList.add(fridgeItemDto); + } else if(fridgeItem.getStorage().equals(FridgeItem.Storage.STORE_AT_ROOM_TEMPERATURE)){ + // 실온 보관인 경우 + ambientStorageList.add(fridgeItemDto); + } else if(fridgeItem.getStorage().equals(FridgeItem.Storage.REFRIGERATED)){ + // 냉장 보관인 경우 + coldStorageList.add(fridgeItemDto); + } else if(fridgeItem.getStorage().equals(FridgeItem.Storage.FROZEN)){ + // 냉동 보관인 경우 + frozenStorageList.add(fridgeItemDto); + } + } - return new IngredientListDto(ingredientDtoList); + return new FridgeItemListDto(coldStorageList, frozenStorageList, ambientStorageList, expirationDateList); } //저장방법 결정 메서드 From 5fc07cf3d8f74c169300d0b876702252d9d74029 Mon Sep 17 00:00:00 2001 From: juryheed Date: Tue, 23 Jul 2024 19:51:22 +0900 Subject: [PATCH 146/212] =?UTF-8?q?refactor:=20=EB=B3=80=EC=88=98=EB=AA=85?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD=20-=20#49=20=EB=B3=80=EC=88=98=EB=AA=85?= =?UTF-8?q?=EC=9D=84=20id=EC=97=90=EC=84=9C=20fridgeItemId=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/service/FridgeService.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java b/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java index eb9a81c..3d5d6fa 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java @@ -48,10 +48,10 @@ public void addIngredientInFridge(AddFridgeDto addFridgeDto, User user){ } //냉장고에 재료 정보 수정 메서드 - public void updateIngredientInFridge(UUID id, AddFridgeDto addFridgeDto, User user){ + public void updateIngredientInFridge(UUID fridgeItemId, AddFridgeDto addFridgeDto, User user){ //수정할 재료 찾기 - FridgeItem fridgeItem=findFridgeItem(id); + FridgeItem fridgeItem=findFridgeItem(fridgeItemId); //유저가 등록한 재료인지 검사 checkAuth(fridgeItem.getFridge().getUser(),user); @@ -67,9 +67,9 @@ public void updateIngredientInFridge(UUID id, AddFridgeDto addFridgeDto, User us } //냉장고에 재료 삭제 메서드 - public void deleteIngredientInFridge(UUID id, User user){ + public void deleteIngredientInFridge(UUID fridgeItemId, User user){ //삭제할 재료 찾기 - FridgeItem fridgeItem=findFridgeItem(id); + FridgeItem fridgeItem=findFridgeItem(fridgeItemId); //권한 확인 checkAuth(fridgeItem.getFridge().getUser(),user); @@ -79,9 +79,9 @@ public void deleteIngredientInFridge(UUID id, User user){ } //냉장고에 있는 재료 단건 조회 메서드 - public FridgeItemResponseData detailIngredientInFridge(UUID id,User user){ + public FridgeItemResponseData detailIngredientInFridge(UUID fridgeItemId,User user){ //조회할 재료 찾기 - FridgeItem fridgeItem=findFridgeItem(id); + FridgeItem fridgeItem=findFridgeItem(fridgeItemId); //권한 확인 checkAuth(fridgeItem.getFridge().getUser(),user); From f0e5c4d5bb183d291c0a744fdc6bc42fb99000ec Mon Sep 17 00:00:00 2001 From: juryheed Date: Tue, 23 Jul 2024 19:53:34 +0900 Subject: [PATCH 147/212] =?UTF-8?q?refactor:=20=EA=B2=BD=EB=A1=9C=EC=9D=98?= =?UTF-8?q?=20=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD=20-=20#49=20?= =?UTF-8?q?=EB=83=89=EC=9E=A5=EA=B3=A0=EC=97=90=20=EC=A0=95=EB=B3=B4=20?= =?UTF-8?q?=EC=88=98=EC=A0=95,=20=EC=82=AD=EC=A0=9C,=20=EB=8B=A8=EA=B1=B4?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=EC=8B=9C=20pathvariable=EB=A1=9C=20=EB=B0=9B?= =?UTF-8?q?=EB=8D=98=20ingredient=5Fid=EB=A5=BC=20fridge=5Fitem=5Fid?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/controller/FridgeController.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java index 0aac3a8..95fdb11 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java @@ -29,22 +29,22 @@ public ResponseEntity> addIngredientInFridge(@RequestBody @Val } //냉장고에 재료 정보 수정 - @PatchMapping("/ingredients/{ingredient_id}") - public ResponseEntity> updateIngredientInFridge(@PathVariable("ingredient_id") UUID id , @RequestBody @Valid AddFridgeDto addFridgeDto, @AuthenticatedUser User user) { + @PatchMapping("/ingredients/{fridge_item_id}") + public ResponseEntity> updateIngredientInFridge(@PathVariable("fridge_item_id") UUID id , @RequestBody @Valid AddFridgeDto addFridgeDto, @AuthenticatedUser User user) { fridgeService.updateIngredientInFridge(id,addFridgeDto, user); return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "냉장고에 재료 수정 성공"), HttpStatus.OK); } //냉장고에 재료 삭제 - @DeleteMapping("/ingredients/{ingredient_id}") - public ResponseEntity> deleteIngredientInFridge(@PathVariable("ingredient_id") UUID id , @AuthenticatedUser User user) { + @DeleteMapping("/ingredients/{fridge_item_id}") + public ResponseEntity> deleteIngredientInFridge(@PathVariable("fridge_item_id") UUID id , @AuthenticatedUser User user) { fridgeService.deleteIngredientInFridge(id, user); return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "냉장고에 재료 삭제 성공"), HttpStatus.OK); } //냉장고에 있는 재료 단건 조회 메서드 - @GetMapping("/ingredients/{ingredient_id}") - public ResponseEntity> detailIngredientInFridge(@PathVariable("ingredient_id") UUID id , @AuthenticatedUser User user) { + @GetMapping("/ingredients/{fridge_item_id}") + public ResponseEntity> detailIngredientInFridge(@PathVariable("fridge_item_id") UUID id , @AuthenticatedUser User user) { FridgeItemResponseData fridgeItemResponseData = fridgeService.detailIngredientInFridge(id, user); return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "냉장고에 재료 조회 성공",fridgeItemResponseData),HttpStatus.OK); } From 0fc67b81cffadeabc9dca9c62e3650fbc5d70c68 Mon Sep 17 00:00:00 2001 From: jihyeonEom Date: Wed, 24 Jul 2024 00:13:12 +0900 Subject: [PATCH 148/212] =?UTF-8?q?feat:=20=EB=A0=88=EC=8B=9C=ED=94=BC?= =?UTF-8?q?=EC=97=90=20=EC=A2=8B=EC=95=84=EC=9A=94=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?API=20=EC=B6=94=EA=B0=80=20-=20#62?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/RecipeController.java | 6 +++++ .../refreshrator/entity/User.java | 2 +- .../exception/errorcode/ErrorCode.java | 4 ++- .../refreshrator/service/RecipeService.java | 4 +++ .../service/RecipeServiceImpl.java | 27 ++++++++++++++++--- 5 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java index aefedf5..e97daeb 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java @@ -63,5 +63,11 @@ public ResponseEntity> deleteIngredientRecipe(@PathVariable("r return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "레시피 재료 삭제 성공"),HttpStatus.OK); } + // 레시피에 좋아요 추가 + @PostMapping("/{recipe_id}/like") + public ResponseEntity> addLikeToRecipe(@PathVariable("recipe_id") UUID recipeId, @AuthenticatedUser User user){ + recipeService.addLikeToRecipe(user, recipeId); + return new ResponseEntity<>(ResponseDto.res(HttpStatus.CREATED, "레시피에 좋아요 추가 성공"),HttpStatus.CREATED); + } } diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/User.java b/src/main/java/com/hackathonteam1/refreshrator/entity/User.java index 699d592..058ccb5 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/entity/User.java +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/User.java @@ -27,6 +27,6 @@ public class User extends BaseEntity{ @OneToMany(mappedBy = "user", cascade = CascadeType.PERSIST, fetch = FetchType.LAZY) private List recipes; - @OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) + @OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER) private List recipeLikes; } diff --git a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java index 650243b..0b2349a 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java +++ b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java @@ -36,7 +36,9 @@ public enum ErrorCode { //ConflictException DUPLICATED_EMAIL("4090", "이미 사용 중인 이메일입니다."), - RECIPE_INGREDIENT_CONFLICT("4091", "이미 해당 레시피에 존재하는 재료입니다."); + RECIPE_INGREDIENT_CONFLICT("4091", "이미 해당 레시피에 존재하는 재료입니다."), + USER_ALREADY_ADD_LIKE("4092", "해당 레시피는 이미 좋아요를 누른 레시피입니다."); + private final String code; diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java index 73347f3..62dcf94 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java @@ -30,4 +30,8 @@ public interface RecipeService { //레시피 재료 삭제 public void deleteIngredientRecipe(User user, UUID recipeId, DeleteIngredientRecipesDto deleteIngredientRecipesDto); + // 레시피에 좋아요 추가 + public void addLikeToRecipe(User user, UUID recipeId); + + // 레시피에 좋아요 삭제 } diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java index cd4544e..205ccc8 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java @@ -5,10 +5,7 @@ import com.hackathonteam1.refreshrator.dto.request.recipe.ModifyRecipeDto; import com.hackathonteam1.refreshrator.dto.request.recipe.RegisterRecipeDto; import com.hackathonteam1.refreshrator.dto.response.recipe.DetailRecipeDto; -import com.hackathonteam1.refreshrator.entity.Ingredient; -import com.hackathonteam1.refreshrator.entity.IngredientRecipe; -import com.hackathonteam1.refreshrator.entity.Recipe; -import com.hackathonteam1.refreshrator.entity.User; +import com.hackathonteam1.refreshrator.entity.*; import com.hackathonteam1.refreshrator.exception.ConflictException; import com.hackathonteam1.refreshrator.exception.ForbiddenException; import com.hackathonteam1.refreshrator.exception.NotFoundException; @@ -138,6 +135,28 @@ private void registerRecipeIngredient(Ingredient ingredient, Recipe recipe){ ingredientRecipeRepository.save(ingredientRecipe); } + // 레시피에 좋아요 추가 + @Override + public void addLikeToRecipe(User user, UUID recipeId){ + // 유저가 이미 좋아요를 누른 레시피인지 확인 + this.isUserAlreadyAddLike(user, recipeId); + // 좋아요를 누른 레시피가 아니라면 좋아요 추가 + Recipe recipe = findRecipeByRecipeId(recipeId); + RecipeLike recipeLike = new RecipeLike(user, recipe); + recipe.getRecipeLikes().add(recipeLike); + this.recipeRepository.save(recipe); + } + + // 유저가 이미 좋아요를 누른 레시피인지 확인 + public void isUserAlreadyAddLike(User user, UUID recipeId){ + List recipeLikes = user.getRecipeLikes(); + for(RecipeLike recipeLike : recipeLikes){ + if(recipeLike.getRecipe().getId().equals(recipeId)){ + throw new ConflictException(ErrorCode.USER_ALREADY_ADD_LIKE); + } + } + } + private Recipe findRecipeByRecipeId(UUID recipeId){ return recipeRepository.findById(recipeId).orElseThrow(()-> new NotFoundException(ErrorCode.RECIPE_NOT_FOUND)); } From ab84900b9c21483efb121949e3869baa372591bf Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 00:55:54 +0900 Subject: [PATCH 149/212] =?UTF-8?q?feat:=20S3=EC=97=90=20AmazonS3Client?= =?UTF-8?q?=EC=9D=84=20=EC=82=AC=EC=9A=A9=ED=95=98=EA=B8=B0=20=EC=9C=84?= =?UTF-8?q?=ED=95=9C=20config=20-=20#61?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/config/S3Config.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/config/S3Config.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/config/S3Config.java b/src/main/java/com/hackathonteam1/refreshrator/config/S3Config.java new file mode 100644 index 0000000..ed23f80 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/config/S3Config.java @@ -0,0 +1,33 @@ +package com.hackathonteam1.refreshrator.config; + +import com.amazonaws.auth.AWSStaticCredentialsProvider; +import com.amazonaws.auth.BasicAWSCredentials; +import com.amazonaws.services.s3.AmazonS3Client; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + + +@Configuration +public class S3Config { + @Value("${cloud.aws.credentials.access-key}") + private String accessKey; + + @Value("${cloud.aws.credentials.secret-key}") + private String secretKey; + + @Value("${cloud.aws.region.static}") + private String region; + + @Bean + public AmazonS3Client amazonS3Client(){ + BasicAWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey); + + return (AmazonS3Client) AmazonS3Client.builder() + .standard() + .withRegion(region) + .withCredentials(new AWSStaticCredentialsProvider(credentials)) + .build(); + } + +} From 4e57552106c1b893063dd68bad269b021fdd078f Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 00:56:21 +0900 Subject: [PATCH 150/212] =?UTF-8?q?feat:=20S3=EC=97=90=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80=20=EB=93=B1=EB=A1=9D=EC=9D=84=20=EC=9C=84?= =?UTF-8?q?=ED=95=9C=20=EB=B9=84=EC=A6=88=EB=8B=88=EC=8A=A4=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20-=20#61?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/service/RecipeService.java | 6 ++- .../service/RecipeServiceImpl.java | 39 ++++++++++++++++-- .../refreshrator/util/S3Uploader.java | 41 +++++++++++++++++++ 3 files changed, 81 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/util/S3Uploader.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java index 73347f3..c9fb6b7 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java @@ -4,9 +4,10 @@ import com.hackathonteam1.refreshrator.dto.request.recipe.RegisterIngredientRecipesDto; import com.hackathonteam1.refreshrator.dto.request.recipe.ModifyRecipeDto; import com.hackathonteam1.refreshrator.dto.request.recipe.RegisterRecipeDto; +import com.hackathonteam1.refreshrator.dto.response.file.ImageDto; import com.hackathonteam1.refreshrator.dto.response.recipe.DetailRecipeDto; -import com.hackathonteam1.refreshrator.entity.Recipe; import com.hackathonteam1.refreshrator.entity.User; +import org.springframework.web.multipart.MultipartFile; import java.util.UUID; @@ -30,4 +31,7 @@ public interface RecipeService { //레시피 재료 삭제 public void deleteIngredientRecipe(User user, UUID recipeId, DeleteIngredientRecipesDto deleteIngredientRecipesDto); + //파일(이미지) 등록 + public ImageDto registerImage(MultipartFile file); + } diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java index cd4544e..074977c 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java @@ -4,23 +4,27 @@ import com.hackathonteam1.refreshrator.dto.request.recipe.RegisterIngredientRecipesDto; import com.hackathonteam1.refreshrator.dto.request.recipe.ModifyRecipeDto; import com.hackathonteam1.refreshrator.dto.request.recipe.RegisterRecipeDto; +import com.hackathonteam1.refreshrator.dto.response.file.ImageDto; import com.hackathonteam1.refreshrator.dto.response.recipe.DetailRecipeDto; -import com.hackathonteam1.refreshrator.entity.Ingredient; -import com.hackathonteam1.refreshrator.entity.IngredientRecipe; -import com.hackathonteam1.refreshrator.entity.Recipe; -import com.hackathonteam1.refreshrator.entity.User; +import com.hackathonteam1.refreshrator.entity.*; import com.hackathonteam1.refreshrator.exception.ConflictException; +import com.hackathonteam1.refreshrator.exception.FileStorageException; import com.hackathonteam1.refreshrator.exception.ForbiddenException; import com.hackathonteam1.refreshrator.exception.NotFoundException; import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; +import com.hackathonteam1.refreshrator.repository.ImageRepository; import com.hackathonteam1.refreshrator.repository.IngredientRecipeRepository; import com.hackathonteam1.refreshrator.repository.IngredientRepository; import com.hackathonteam1.refreshrator.repository.RecipeRepository; +import com.hackathonteam1.refreshrator.util.S3Uploader; import lombok.RequiredArgsConstructor; +import org.springframework.http.MediaType; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -33,6 +37,8 @@ public class RecipeServiceImpl implements RecipeService{ private final RecipeRepository recipeRepository; private final IngredientRepository ingredientRepository; private final IngredientRecipeRepository ingredientRecipeRepository; + private final S3Uploader s3Uploader; + private final ImageRepository imageRepository; @Override @Transactional @@ -125,6 +131,31 @@ public void deleteIngredientRecipe(User user, UUID recipeId, DeleteIngredientRec } + @Override + public ImageDto registerImage(MultipartFile file) { + + if(!file.getContentType().equals(MediaType.IMAGE_GIF_VALUE) && + !file.getContentType().equals(MediaType.IMAGE_PNG_VALUE) && + !file.getContentType().equals(MediaType.IMAGE_JPEG_VALUE) ){ + throw new FileStorageException(ErrorCode.FILE_TYPE_ERROR); + } + + String url; + try { + url = s3Uploader.upload(file); + } catch (IOException e) { + throw new FileStorageException(ErrorCode.FILE_STORAGE_ERROR, e.getMessage()); + } + + Image image = Image.builder() + .url(url) + .build(); + + imageRepository.save(image); + ImageDto imageDto = ImageDto.mapping(image); + return imageDto; + } + private Ingredient findIngredientByIngredientId(UUID ingredientId){ return ingredientRepository.findById(ingredientId).orElseThrow(()-> new NotFoundException(ErrorCode.INGREDIENT_NOT_FOUND)); } diff --git a/src/main/java/com/hackathonteam1/refreshrator/util/S3Uploader.java b/src/main/java/com/hackathonteam1/refreshrator/util/S3Uploader.java new file mode 100644 index 0000000..d92a99d --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/util/S3Uploader.java @@ -0,0 +1,41 @@ +package com.hackathonteam1.refreshrator.util; + +import com.amazonaws.services.s3.AmazonS3Client; +import com.amazonaws.services.s3.model.*; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.util.UUID; + +@Slf4j +@Component +@RequiredArgsConstructor +public class S3Uploader { + private final AmazonS3Client amazonS3Client; + + @Value("${cloud.aws.s3.bucket}") + public String bucket; + + + public String upload(MultipartFile multipartFile) throws IOException { + String fileName = multipartFile.getName() + UUID.randomUUID(); + + ObjectMetadata metadata = new ObjectMetadata(); + metadata.setContentLength(multipartFile.getSize()); + metadata.setContentType(multipartFile.getContentType()); + + amazonS3Client.putObject(bucket, fileName, multipartFile.getInputStream(), metadata); + return amazonS3Client.getUrl(bucket, fileName).toString(); + } + + + public void removeS3File(String fileName){ + final DeleteObjectRequest deleteObjectRequest = new DeleteObjectRequest(bucket, fileName); + amazonS3Client.deleteObject(deleteObjectRequest); + } + +} From 2c4359b59da5099211e047a9123c4fa30030522f Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 00:56:46 +0900 Subject: [PATCH 151/212] =?UTF-8?q?feat:=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EA=B0=9D=EC=B2=B4=EB=A5=BC=20=EC=A0=80=EC=9E=A5=ED=95=98?= =?UTF-8?q?=EA=B8=B0=20=EC=9C=84=ED=95=9C=20Jpa=EB=A0=88=ED=8F=AC=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20-=20#61?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/repository/ImageRepository.java | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/repository/ImageRepository.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/repository/ImageRepository.java b/src/main/java/com/hackathonteam1/refreshrator/repository/ImageRepository.java new file mode 100644 index 0000000..6fbef8e --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/repository/ImageRepository.java @@ -0,0 +1,9 @@ +package com.hackathonteam1.refreshrator.repository; + +import com.hackathonteam1.refreshrator.entity.Image; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.UUID; + +public interface ImageRepository extends JpaRepository { +} From 31e50c875c5f21d46a66d3865c3049608ea8d367 Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 00:57:03 +0900 Subject: [PATCH 152/212] =?UTF-8?q?feat:=20S3=EB=A5=BC=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=ED=95=98=EA=B8=B0=20=EC=9C=84=ED=95=9C=20=EC=9D=98?= =?UTF-8?q?=EC=A1=B4=EC=84=B1=20=EC=B6=94=EA=B0=80=20-=20#61?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.gradle b/build.gradle index 1e6c71a..95fa937 100644 --- a/build.gradle +++ b/build.gradle @@ -38,6 +38,8 @@ dependencies { implementation 'io.jsonwebtoken:jjwt-impl:0.11.5'//JWT implementation 'io.jsonwebtoken:jjwt-jackson:0.11.5'//JWT implementation 'javax.xml.bind:jaxb-api:2.3.1'//JAXB + + implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'//AWS } tasks.named('test') { From 916573ce944e0c8d66c3a60becbe2d181a2fde36 Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 00:57:49 +0900 Subject: [PATCH 153/212] =?UTF-8?q?feat:=20=ED=8C=8C=EC=9D=BC=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20=EC=98=A4=EB=A5=98=20=EC=B6=94=EA=B0=80=20-=20#61?= =?UTF-8?q?=20=ED=8C=8C=EC=9D=BC=20=ED=98=95=EC=8B=9D=EC=9D=B4=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80=EA=B0=80=20=EC=95=84=EB=8B=8C=20=EA=B2=BD?= =?UTF-8?q?=EC=9A=B0,=20=ED=8C=8C=EC=9D=BC=20=EC=97=85=EB=A1=9C=EB=93=9C?= =?UTF-8?q?=EC=97=90=20=EC=8B=A4=ED=8C=A8=ED=95=9C=20=EA=B2=BD=EC=9A=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/exception/errorcode/ErrorCode.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java index 650243b..e302c98 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java +++ b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java @@ -16,6 +16,7 @@ public enum ErrorCode { EMAIL("4004", "이메일 형식이 유효하지 않습니다."), NOT_NULL("4005", "필수값이 공백입니다."), DUPLICATED_RECIPE_INGREDIENT("4006","중복되는 레시피 재료 관련 요청은 불가합니다."), + FILE_TYPE_ERROR("4007", "유효하지 않은 파일 형식입니다."), //AuthorizedException COOKIE_NOT_FOUND("4010", "쿠키를 찾을 수 없습니다."), @@ -36,8 +37,10 @@ public enum ErrorCode { //ConflictException DUPLICATED_EMAIL("4090", "이미 사용 중인 이메일입니다."), - RECIPE_INGREDIENT_CONFLICT("4091", "이미 해당 레시피에 존재하는 재료입니다."); + RECIPE_INGREDIENT_CONFLICT("4091", "이미 해당 레시피에 존재하는 재료입니다."), + //InternetException + FILE_STORAGE_ERROR("5000", "파일을 업로드할 수 없습니다."); private final String code; private final String message; From 778035538dc85ffcafdb98f4371b383280458af3 Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 00:58:07 +0900 Subject: [PATCH 154/212] =?UTF-8?q?feat:=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EC=97=85=EB=A1=9C=EB=93=9C=EB=A5=BC=20=EC=9C=84=ED=95=9C=20?= =?UTF-8?q?=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EC=9E=91=EC=84=B1=20-?= =?UTF-8?q?=20#61?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/controller/RecipeController.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java index aefedf5..384a496 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java @@ -6,14 +6,17 @@ import com.hackathonteam1.refreshrator.dto.request.recipe.RegisterIngredientRecipesDto; import com.hackathonteam1.refreshrator.dto.request.recipe.ModifyRecipeDto; import com.hackathonteam1.refreshrator.dto.request.recipe.RegisterRecipeDto; +import com.hackathonteam1.refreshrator.dto.response.file.ImageDto; import com.hackathonteam1.refreshrator.dto.response.recipe.DetailRecipeDto; import com.hackathonteam1.refreshrator.entity.User; import com.hackathonteam1.refreshrator.service.RecipeService; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import java.util.UUID; @@ -63,5 +66,11 @@ public ResponseEntity> deleteIngredientRecipe(@PathVariable("r return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "레시피 재료 삭제 성공"),HttpStatus.OK); } + @PostMapping(value = "/images", consumes = MediaType.MULTIPART_FORM_DATA_VALUE ) + public ResponseEntity> registerFile( + @RequestPart MultipartFile file){ + ImageDto imageDto = recipeService.registerImage(file); + return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "이미지 등록 성공", imageDto),HttpStatus.OK); + } } From 394094bb2988c62f24135d14e4be2e255cf94830 Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 00:58:26 +0900 Subject: [PATCH 155/212] =?UTF-8?q?feat:=20=ED=8C=8C=EC=9D=BC=20=EC=A0=80?= =?UTF-8?q?=EC=9E=A5=20=EA=B4=80=EB=A0=A8=20=EC=98=88=EC=99=B8=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20-=20#61?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/FileStorageException.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/exception/FileStorageException.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/exception/FileStorageException.java b/src/main/java/com/hackathonteam1/refreshrator/exception/FileStorageException.java new file mode 100644 index 0000000..0097d7f --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/exception/FileStorageException.java @@ -0,0 +1,15 @@ +package com.hackathonteam1.refreshrator.exception; + +import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; + +public class FileStorageException extends CustomException{ + + + public FileStorageException(ErrorCode errorCode) { + super(errorCode); + } + + public FileStorageException(ErrorCode errorCode, String detail) { + super(errorCode, detail); + } +} From a5f32e791ee4c27d7f1a58262b49a594a4647a04 Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 00:58:49 +0900 Subject: [PATCH 156/212] =?UTF-8?q?feat:=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EA=B0=9D=EC=B2=B4=20Response=EB=A5=BC=20=EC=9C=84=ED=95=9C=20D?= =?UTF-8?q?to=20=EC=9E=91=EC=84=B1=20-=20#61?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/file/ImageDto.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/dto/response/file/ImageDto.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/response/file/ImageDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/response/file/ImageDto.java new file mode 100644 index 0000000..7055ae7 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/response/file/ImageDto.java @@ -0,0 +1,21 @@ +package com.hackathonteam1.refreshrator.dto.response.file; + +import com.hackathonteam1.refreshrator.entity.Image; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; + +import java.util.UUID; + +@Getter +@Builder +@AllArgsConstructor +public class ImageDto { + + private UUID id; + private String url; + + public static ImageDto mapping(Image image){ + return new ImageDto(image.getId(), image.getUrl()); + } +} From 2b03372f439815e5ef0fd040c2bfa70862107b40 Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 02:42:26 +0900 Subject: [PATCH 157/212] =?UTF-8?q?feat:=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=EB=A5=BC=20=EC=9C=84=ED=95=9C=20Dto=20-#66?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/file/DeleteImageDto.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/dto/request/file/DeleteImageDto.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/request/file/DeleteImageDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/request/file/DeleteImageDto.java new file mode 100644 index 0000000..322bdc7 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/request/file/DeleteImageDto.java @@ -0,0 +1,14 @@ +package com.hackathonteam1.refreshrator.dto.request.file; + +import jakarta.validation.constraints.NotNull; +import lombok.Getter; + +import java.util.UUID; + +@Getter +public class DeleteImageDto { + @NotNull + private UUID imageId; + @NotNull + private UUID recipeId; +} From 362e3c756ae948d071724821f3dd87be5f0c4b98 Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 02:44:43 +0900 Subject: [PATCH 158/212] =?UTF-8?q?feat:=20=EC=9D=B4=EB=AF=B8=EC=A7=80?= =?UTF-8?q?=EA=B0=80=20=ED=95=B4=EB=8B=B9=20=EB=A0=88=EC=8B=9C=ED=94=BC?= =?UTF-8?q?=EC=9D=98=20=EC=9D=B4=EB=AF=B8=EC=A7=80=EA=B0=80=20=EC=95=84?= =?UTF-8?q?=EB=8B=8C=20=EA=B2=BD=EC=9A=B0=20=EC=97=90=EB=9F=AC=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=9E=91=EC=84=B1=20-#66?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/exception/errorcode/ErrorCode.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java index e302c98..b62c93e 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java +++ b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java @@ -17,6 +17,7 @@ public enum ErrorCode { NOT_NULL("4005", "필수값이 공백입니다."), DUPLICATED_RECIPE_INGREDIENT("4006","중복되는 레시피 재료 관련 요청은 불가합니다."), FILE_TYPE_ERROR("4007", "유효하지 않은 파일 형식입니다."), + IMAGE_NOT_IN_RECIPE("4008", "해당 레시피에 속한 이미지가 아닙니다."), //AuthorizedException COOKIE_NOT_FOUND("4010", "쿠키를 찾을 수 없습니다."), @@ -34,13 +35,14 @@ public enum ErrorCode { INGREDIENT_RECIPE_NOT_FOUND("4043", "레시피의 재료를 찾을 수 없습니다."), FRIDGE_NOT_FOUND("4044","냉장고를 찾을 수 없습니다"), FRIDGE_ITEM_NOT_FOUND("4045","냉장고에 등록된 재료 정보를 찾을 수 없습니다."), + IMAGE_NOT_FOUND("4046","이미지를 찾을 수 없습니다"), //ConflictException DUPLICATED_EMAIL("4090", "이미 사용 중인 이메일입니다."), RECIPE_INGREDIENT_CONFLICT("4091", "이미 해당 레시피에 존재하는 재료입니다."), //InternetException - FILE_STORAGE_ERROR("5000", "파일을 업로드할 수 없습니다."); + FILE_STORAGE_ERROR("5000", "파일을 업로드할 수 없습니다."); private final String code; private final String message; From 2783dbf5071b58b371e30f9cb94176a4fa099d1a Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 02:57:03 +0900 Subject: [PATCH 159/212] =?UTF-8?q?feat:=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=20=EC=8B=9C=20Dto=EB=8C=80=EC=8B=A0=20pathva?= =?UTF-8?q?riable=EC=9D=84=20=EC=82=AC=EC=9A=A9=ED=95=98=EA=B8=B0=EB=A1=9C?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD=20-#66=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20dto=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/controller/RecipeController.java | 7 +++++++ .../dto/request/file/DeleteImageDto.java | 14 -------------- 2 files changed, 7 insertions(+), 14 deletions(-) delete mode 100644 src/main/java/com/hackathonteam1/refreshrator/dto/request/file/DeleteImageDto.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java index 384a496..f074883 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java @@ -73,4 +73,11 @@ public ResponseEntity> registerFile( return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "이미지 등록 성공", imageDto),HttpStatus.OK); } + @DeleteMapping(value = "/images/{image_Id}") + public ResponseEntity> deleteFile( + @PathVariable UUID image_Id,@AuthenticatedUser User user){ + recipeService.deleteImage(image_Id, user); + return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "이미지 삭제 성공"),HttpStatus.OK); + } + } diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/request/file/DeleteImageDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/request/file/DeleteImageDto.java deleted file mode 100644 index 322bdc7..0000000 --- a/src/main/java/com/hackathonteam1/refreshrator/dto/request/file/DeleteImageDto.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.hackathonteam1.refreshrator.dto.request.file; - -import jakarta.validation.constraints.NotNull; -import lombok.Getter; - -import java.util.UUID; - -@Getter -public class DeleteImageDto { - @NotNull - private UUID imageId; - @NotNull - private UUID recipeId; -} From 8e9bb0915eab8698de7e9b7c2258b617a3783f38 Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 02:57:53 +0900 Subject: [PATCH 160/212] =?UTF-8?q?feat:=20=EC=9D=B4=EB=AF=B8=EC=A7=80?= =?UTF-8?q?=EA=B0=80=20=EC=A1=B4=EC=9E=AC=ED=95=98=EC=A7=80=20=EC=95=8A?= =?UTF-8?q?=EB=8A=94=20=EB=A0=88=EC=8B=9C=ED=94=BC=EC=97=90=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80=20=EC=82=AD=EC=A0=9C=EB=A5=BC=20=EC=9A=94?= =?UTF-8?q?=EC=B2=AD=ED=95=98=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20=EC=97=90?= =?UTF-8?q?=EB=9F=AC=EC=BD=94=EB=93=9C=20=EC=9E=91=EC=84=B1=20-#66?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/exception/errorcode/ErrorCode.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java index b62c93e..52b4886 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java +++ b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java @@ -17,7 +17,7 @@ public enum ErrorCode { NOT_NULL("4005", "필수값이 공백입니다."), DUPLICATED_RECIPE_INGREDIENT("4006","중복되는 레시피 재료 관련 요청은 불가합니다."), FILE_TYPE_ERROR("4007", "유효하지 않은 파일 형식입니다."), - IMAGE_NOT_IN_RECIPE("4008", "해당 레시피에 속한 이미지가 아닙니다."), + IMAGE_NOT_IN_RECIPE("4008", "이미지가 존재하지 않는 레시피입니다."), //AuthorizedException COOKIE_NOT_FOUND("4010", "쿠키를 찾을 수 없습니다."), From e55d577d564c9ee527adba663c1b58eb60f53217 Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 02:58:19 +0900 Subject: [PATCH 161/212] =?UTF-8?q?feat:=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EC=97=94=ED=8B=B0=ED=8B=B0=20=EB=82=B4=EB=B6=80=EC=97=90=20?= =?UTF-8?q?=EB=A0=88=EC=8B=9C=ED=94=BC=EC=99=80=EC=9D=98=20=EC=97=B0?= =?UTF-8?q?=EA=B4=80=EA=B4=80=EA=B3=84=20=EC=9E=91=EC=84=B1=20-#66?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hackathonteam1/refreshrator/entity/Image.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/Image.java b/src/main/java/com/hackathonteam1/refreshrator/entity/Image.java index 6d7ecf8..35158f2 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/entity/Image.java +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/Image.java @@ -13,10 +13,11 @@ @AllArgsConstructor @NoArgsConstructor @Builder -@ToString(exclude = "recipe") public class Image extends BaseEntity{ @Column(nullable = false) private String url; //aws s3의 url + @OneToOne(mappedBy = "image", cascade = CascadeType.PERSIST) + private Recipe recipe; } From 75e8e8a3ed5260622aecd6aa989bfbb5d0162885 Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 02:59:14 +0900 Subject: [PATCH 162/212] =?UTF-8?q?feat:=20=EB=A0=88=EC=8B=9C=ED=94=BC=20?= =?UTF-8?q?=EC=97=94=ED=8B=B0=ED=8B=B0=20=EB=82=B4=EB=B6=80=EC=97=90=20?= =?UTF-8?q?=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=9E=91=EC=84=B1=20-=20#66=20?= =?UTF-8?q?=EC=9D=B4=EB=AF=B8=EC=A7=80=EB=A5=BC=20=ED=8F=AC=ED=95=A8?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EA=B0=9D=EC=B2=B4=EC=9D=B8=EC=A7=80=20?= =?UTF-8?q?=ED=8C=90=EB=8B=A8=ED=95=98=EB=8A=94=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C,=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EC=82=AD=EC=A0=9C?= =?UTF-8?q?=EB=A5=BC=20=EC=9C=84=ED=95=B4=20fk=EA=B0=92=EC=9D=84=20null?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD=ED=95=98=EB=8A=94=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hackathonteam1/refreshrator/entity/Recipe.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/Recipe.java b/src/main/java/com/hackathonteam1/refreshrator/entity/Recipe.java index 3491264..5e78996 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/entity/Recipe.java +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/Recipe.java @@ -39,4 +39,11 @@ public void updateCookingStep(String cookingStep){ this.cookingStep = cookingStep; } + public Boolean isContainingImage(){ + return this.getImage()!=null; + } + + public void deleteImage(){ + this.image = null; + } } From 33c40074b462c26b0121d5c60fb41afb670d2d96 Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 02:59:32 +0900 Subject: [PATCH 163/212] =?UTF-8?q?feat:=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=EB=A5=BC=20=EB=B9=84=EC=A6=88=EB=8B=88?= =?UTF-8?q?=EC=8A=A4=20=EB=A1=9C=EC=A7=81=20=EC=9E=91=EC=84=B1-#66?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/service/RecipeService.java | 3 +++ .../service/RecipeServiceImpl.java | 25 ++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java index c9fb6b7..61e0d9f 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java @@ -34,4 +34,7 @@ public interface RecipeService { //파일(이미지) 등록 public ImageDto registerImage(MultipartFile file); + //파일(이미지) 삭제 + public void deleteImage(UUID imageId, User user); + } diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java index 074977c..491182c 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java @@ -7,10 +7,7 @@ import com.hackathonteam1.refreshrator.dto.response.file.ImageDto; import com.hackathonteam1.refreshrator.dto.response.recipe.DetailRecipeDto; import com.hackathonteam1.refreshrator.entity.*; -import com.hackathonteam1.refreshrator.exception.ConflictException; -import com.hackathonteam1.refreshrator.exception.FileStorageException; -import com.hackathonteam1.refreshrator.exception.ForbiddenException; -import com.hackathonteam1.refreshrator.exception.NotFoundException; +import com.hackathonteam1.refreshrator.exception.*; import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; import com.hackathonteam1.refreshrator.repository.ImageRepository; import com.hackathonteam1.refreshrator.repository.IngredientRecipeRepository; @@ -18,6 +15,7 @@ import com.hackathonteam1.refreshrator.repository.RecipeRepository; import com.hackathonteam1.refreshrator.util.S3Uploader; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -156,6 +154,25 @@ public ImageDto registerImage(MultipartFile file) { return imageDto; } + @Override + public void deleteImage(UUID imageId, User user) { + Image image = findImageByImageId(imageId); + Recipe recipe = image.getRecipe(); + + if(!recipe.isContainingImage()){ + throw new BadRequestException(ErrorCode.IMAGE_NOT_IN_RECIPE); + } + + checkAuth(recipe.getUser(), user); + recipe.deleteImage(); + s3Uploader.removeS3File(image.getUrl().split("/")[3]); + imageRepository.delete(image); + } + + private Image findImageByImageId(UUID imageId){ + return imageRepository.findById(imageId).orElseThrow(()->new NotFoundException(ErrorCode.IMAGE_NOT_FOUND)); + } + private Ingredient findIngredientByIngredientId(UUID ingredientId){ return ingredientRepository.findById(ingredientId).orElseThrow(()-> new NotFoundException(ErrorCode.INGREDIENT_NOT_FOUND)); } From 6a902dca958b185145388d632e675b516f7d285e Mon Sep 17 00:00:00 2001 From: jihyeonEom Date: Wed, 24 Jul 2024 15:10:10 +0900 Subject: [PATCH 164/212] =?UTF-8?q?feat:=20fetchType.Eager=EC=97=90?= =?UTF-8?q?=EC=84=9C=20Lazy=EB=A1=9C=20=EB=90=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20-=20#62?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/controller/RecipeController.java | 1 + .../hackathonteam1/refreshrator/entity/User.java | 2 +- .../refreshrator/service/RecipeServiceImpl.java | 14 ++++++++------ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java index e97daeb..902236f 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java @@ -13,6 +13,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import java.util.UUID; diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/User.java b/src/main/java/com/hackathonteam1/refreshrator/entity/User.java index 058ccb5..699d592 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/entity/User.java +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/User.java @@ -27,6 +27,6 @@ public class User extends BaseEntity{ @OneToMany(mappedBy = "user", cascade = CascadeType.PERSIST, fetch = FetchType.LAZY) private List recipes; - @OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER) + @OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) private List recipeLikes; } diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java index 205ccc8..ab44e3a 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java @@ -26,6 +26,7 @@ @Service @RequiredArgsConstructor +@Transactional public class RecipeServiceImpl implements RecipeService{ private final RecipeRepository recipeRepository; private final IngredientRepository ingredientRepository; @@ -138,20 +139,21 @@ private void registerRecipeIngredient(Ingredient ingredient, Recipe recipe){ // 레시피에 좋아요 추가 @Override public void addLikeToRecipe(User user, UUID recipeId){ + Recipe recipe = findRecipeByRecipeId(recipeId); + // 유저가 이미 좋아요를 누른 레시피인지 확인 - this.isUserAlreadyAddLike(user, recipeId); + this.isUserAlreadyAddLike(user, recipe); + // 좋아요를 누른 레시피가 아니라면 좋아요 추가 - Recipe recipe = findRecipeByRecipeId(recipeId); RecipeLike recipeLike = new RecipeLike(user, recipe); recipe.getRecipeLikes().add(recipeLike); this.recipeRepository.save(recipe); } // 유저가 이미 좋아요를 누른 레시피인지 확인 - public void isUserAlreadyAddLike(User user, UUID recipeId){ - List recipeLikes = user.getRecipeLikes(); - for(RecipeLike recipeLike : recipeLikes){ - if(recipeLike.getRecipe().getId().equals(recipeId)){ + public void isUserAlreadyAddLike(User user, Recipe recipe){ + for (RecipeLike recipeLike : recipe.getRecipeLikes()) { + if(recipeLike.getUser().getId().equals(user.getId())){ throw new ConflictException(ErrorCode.USER_ALREADY_ADD_LIKE); } } From b5bea553cab097d1511080725423adb8c9122502 Mon Sep 17 00:00:00 2001 From: jihyeonEom Date: Wed, 24 Jul 2024 15:23:52 +0900 Subject: [PATCH 165/212] =?UTF-8?q?fix:=20import=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/controller/FridgeController.java | 1 + .../com/hackathonteam1/refreshrator/service/FridgeService.java | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java index b6f2c74..e695208 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/FridgeController.java @@ -4,6 +4,7 @@ import com.hackathonteam1.refreshrator.dto.ResponseDto; import com.hackathonteam1.refreshrator.dto.request.fridge.AddFridgeDto; import com.hackathonteam1.refreshrator.dto.response.fridge.FridgeItemListDto; +import com.hackathonteam1.refreshrator.dto.response.fridgeItem.FridgeItemResponseData; import com.hackathonteam1.refreshrator.entity.User; import com.hackathonteam1.refreshrator.service.FridgeService; import jakarta.validation.Valid; diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java b/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java index a9437f3..9161797 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java @@ -3,6 +3,7 @@ import com.hackathonteam1.refreshrator.dto.request.fridge.AddFridgeDto; import com.hackathonteam1.refreshrator.dto.response.fridge.FridgeItemDto; import com.hackathonteam1.refreshrator.dto.response.fridge.FridgeItemListDto; +import com.hackathonteam1.refreshrator.dto.response.fridgeItem.FridgeItemResponseData; import com.hackathonteam1.refreshrator.entity.Fridge; import com.hackathonteam1.refreshrator.entity.FridgeItem; import com.hackathonteam1.refreshrator.entity.Ingredient; @@ -121,7 +122,7 @@ public FridgeItemListDto getIngredientsInFridge(User user) { } //냉장고에 있는 재료 단건 조회 메서드 - public FridgeItemResponseData detailIngredientInFridge(UUID fridgeItemId,User user){ + public FridgeItemResponseData detailIngredientInFridge(UUID fridgeItemId, User user){ //조회할 재료 찾기 FridgeItem fridgeItem=findFridgeItem(fridgeItemId); From 2279f0b230f9c8e7230fe80daa14d399c328e7e9 Mon Sep 17 00:00:00 2001 From: jihyeonEom Date: Wed, 24 Jul 2024 15:25:58 +0900 Subject: [PATCH 166/212] =?UTF-8?q?feat:=20RecipeLikeRepository=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20-=20#62?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/repository/RecipeLikeRepository.java | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/repository/RecipeLikeRepository.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/repository/RecipeLikeRepository.java b/src/main/java/com/hackathonteam1/refreshrator/repository/RecipeLikeRepository.java new file mode 100644 index 0000000..94b0f3b --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/repository/RecipeLikeRepository.java @@ -0,0 +1,11 @@ +package com.hackathonteam1.refreshrator.repository; + +import com.hackathonteam1.refreshrator.entity.RecipeLike; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.UUID; + +public interface RecipeLikeRepository extends JpaRepository { + +} + From 44cc4adf8ddcd71e4176a1f5100637045b43dbb5 Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 15:26:05 +0900 Subject: [PATCH 167/212] =?UTF-8?q?feat:=20=EB=83=89=EC=9E=A5=EA=B3=A0=20?= =?UTF-8?q?=EC=95=84=EC=9D=B4=ED=85=9C=20=EB=A7=8C=EB=A3=8C=EB=A5=BC=20?= =?UTF-8?q?=ED=99=95=EC=9D=B8=ED=95=98=EA=B8=B0=20=EC=9C=84=ED=95=9C=20?= =?UTF-8?q?=EB=82=B4=EB=B6=80=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20-=20#59?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hackathonteam1/refreshrator/entity/FridgeItem.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/FridgeItem.java b/src/main/java/com/hackathonteam1/refreshrator/entity/FridgeItem.java index 2d7bfac..d2b6f4a 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/entity/FridgeItem.java +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/FridgeItem.java @@ -37,4 +37,7 @@ public class FridgeItem extends BaseEntity{ public enum Storage{ STORE_AT_ROOM_TEMPERATURE, REFRIGERATED, FROZEN; } -} + public boolean isExpired(){ + return this.expiredDate.isAfter(LocalDate.now()); + } +} \ No newline at end of file From 155e837b20c1ccad57a670cac2b9e0421cc7727f Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 15:27:47 +0900 Subject: [PATCH 168/212] =?UTF-8?q?feat:=20=EB=A0=88=EC=8B=9C=ED=94=BC=20?= =?UTF-8?q?=EC=B6=94=EC=B2=9C=EC=9D=84=20=EC=9C=84=ED=95=9C=20=EC=BB=A8?= =?UTF-8?q?=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EC=9E=91=EC=84=B1=20-=20#59=20pa?= =?UTF-8?q?ge:=20=ED=98=84=EC=9E=AC=20=ED=8E=98=EC=9D=B4=EC=A7=80=20size:?= =?UTF-8?q?=20=ED=8E=98=EC=9D=B4=EC=A7=80=EC=97=90=20=ED=91=9C=EC=8B=9C?= =?UTF-8?q?=EB=90=98=EB=8A=94=20=EA=B0=9D=EC=B2=B4=20=EC=88=98=20match:=20?= =?UTF-8?q?=EB=A0=88=EC=8B=9C=ED=94=BC=20=EC=9E=AC=EB=A3=8C=EC=99=80=20?= =?UTF-8?q?=EB=83=89=EC=9E=A5=EA=B3=A0=20=EC=95=84=EC=9D=B4=ED=85=9C?= =?UTF-8?q?=EC=9D=B4=20=EB=AA=87=EA=B0=9C=20=EC=9D=BC=EC=B9=98=ED=95=98?= =?UTF-8?q?=EB=8A=94=EC=A7=80=20=EC=84=A4=EC=A0=95=20->=20=EA=B8=B0?= =?UTF-8?q?=EB=B3=B8=EA=B0=92=EC=9D=80=20Integer.Max=5FValue=EB=A1=9C=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=ED=95=98=EC=A7=80=20=EC=95=8A=EC=9D=84=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20=EB=83=89=EC=9E=A5=EA=B3=A0=EC=97=90=20?= =?UTF-8?q?=EC=9E=AC=EB=A3=8C=EA=B0=80=20=EB=AA=A8=EB=91=90=20=EC=A1=B4?= =?UTF-8?q?=EC=9E=AC=ED=95=98=EB=8A=94=20=EB=A0=88=EC=8B=9C=ED=94=BC?= =?UTF-8?q?=EB=A7=8C=20=EB=B3=B4=EC=97=AC=EC=A4=8C.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/controller/RecipeController.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java index bef1245..4562c87 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java @@ -71,4 +71,14 @@ public ResponseEntity> deleteIngredientRecipe(@PathVariable("r return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "레시피 재료 삭제 성공"),HttpStatus.OK); } + @GetMapping("/recommendations") + public ResponseEntity> getRecommendations( + @RequestParam(name = "page", defaultValue = "0")int page, + @RequestParam(name = "size", defaultValue = "10")int size, + @RequestParam(name = "match", defaultValue = "2147483647")int match, + @AuthenticatedUser User user){ + RecipeListDto recipeListDto = recipeService.getRecommendation(page, size, match, user); + return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK,"추천 레시피 목록 조회 성공", recipeListDto),HttpStatus.OK); + } + } From 56bc905b65c3598409694c163f29dbeb6fea8397 Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 15:31:42 +0900 Subject: [PATCH 169/212] =?UTF-8?q?feat:=20=EC=B6=94=EC=B2=9C=20=EB=A0=88?= =?UTF-8?q?=EC=8B=9C=ED=94=BC=EB=A5=BC=20=EA=B0=80=EC=A0=B8=EC=98=A4?= =?UTF-8?q?=EB=8A=94=20JpaRepo=20=EC=BB=A4=EC=8A=A4=ED=85=80=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EC=9E=91=EC=84=B1=20-=20#59?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/repository/RecipeRepository.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/repository/RecipeRepository.java b/src/main/java/com/hackathonteam1/refreshrator/repository/RecipeRepository.java index b0109f3..e2d3313 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/repository/RecipeRepository.java +++ b/src/main/java/com/hackathonteam1/refreshrator/repository/RecipeRepository.java @@ -1,13 +1,21 @@ package com.hackathonteam1.refreshrator.repository; +import com.hackathonteam1.refreshrator.entity.Ingredient; import com.hackathonteam1.refreshrator.entity.Recipe; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import java.util.List; +import java.util.Set; import java.util.UUID; public interface RecipeRepository extends JpaRepository { Page findAllByNameContaining(String keyword, Pageable pageable); + + @Query("SELECT r FROM recipe r JOIN r.ingredientRecipes ir JOIN ir.ingredient i WHERE i IN :ingredients GROUP BY r.id HAVING COUNT(i) >= :match OR COUNT(i) = SIZE(r.ingredientRecipes)") + Page findAllByIngredientRecipesContain(@Param("ingredients") Set ingredients, @Param("match") int match, Pageable pageable); Page findAll(Pageable pageable); } From 7d9faa8d4700d81cde886fefe92d999fbcf7ab1c Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 16:14:24 +0900 Subject: [PATCH 170/212] =?UTF-8?q?feat:=20=EC=9C=A0=ED=9A=A8=EA=B8=B0?= =?UTF-8?q?=EA=B0=84=20=EB=A7=8C=EB=A3=8C=20=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20-=20#59?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hackathonteam1/refreshrator/entity/FridgeItem.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/FridgeItem.java b/src/main/java/com/hackathonteam1/refreshrator/entity/FridgeItem.java index d2b6f4a..c0f226c 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/entity/FridgeItem.java +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/FridgeItem.java @@ -38,6 +38,6 @@ public enum Storage{ STORE_AT_ROOM_TEMPERATURE, REFRIGERATED, FROZEN; } public boolean isExpired(){ - return this.expiredDate.isAfter(LocalDate.now()); + return LocalDate.now().isAfter(this.expiredDate); } } \ No newline at end of file From 6c388d888c2fcfb40f7900b951625ac6612192d2 Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 16:14:42 +0900 Subject: [PATCH 171/212] =?UTF-8?q?feat:=20=EC=BB=A8=ED=8A=B8=EB=A1=A4?= =?UTF-8?q?=EB=9F=AC=EC=97=90=20=EC=A0=95=EB=A0=AC=20=EC=A1=B0=EA=B1=B4=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20-=20#59?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/controller/RecipeController.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java index 4562c87..018bd00 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java @@ -76,8 +76,9 @@ public ResponseEntity> getRecommendations( @RequestParam(name = "page", defaultValue = "0")int page, @RequestParam(name = "size", defaultValue = "10")int size, @RequestParam(name = "match", defaultValue = "2147483647")int match, + @RequestParam(name = "type", defaultValue = "newest")String type, @AuthenticatedUser User user){ - RecipeListDto recipeListDto = recipeService.getRecommendation(page, size, match, user); + RecipeListDto recipeListDto = recipeService.getRecommendation(page, size, match, type, user); return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK,"추천 레시피 목록 조회 성공", recipeListDto),HttpStatus.OK); } From bce73e37bc501213d95ffd73fb9e9b348abc98ff Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 16:15:31 +0900 Subject: [PATCH 172/212] =?UTF-8?q?feat:=20=EB=A0=88=EC=8B=9C=ED=94=BC=20?= =?UTF-8?q?=EC=B6=94=EC=B2=9C=ED=95=98=EB=8A=94=20=EB=B9=84=EC=A6=88?= =?UTF-8?q?=EB=8B=88=EC=8A=A4=20=EB=A1=9C=EC=A7=81=20=EC=9E=91=EC=84=B1=20?= =?UTF-8?q?-=20#59?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/service/RecipeService.java | 3 ++ .../service/RecipeServiceImpl.java | 33 ++++++++++++++++--- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java index ad826c6..2a819bc 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java @@ -34,4 +34,7 @@ public interface RecipeService { //레시피 재료 삭제 public void deleteIngredientRecipe(User user, UUID recipeId, DeleteIngredientRecipesDto deleteIngredientRecipesDto); + //추천 레시피 목록 조회 + public RecipeListDto getRecommendation(int page, int size, int match, String type, User user); + } diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java index 58f463f..4890948 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java @@ -6,14 +6,12 @@ import com.hackathonteam1.refreshrator.dto.request.recipe.RegisterRecipeDto; import com.hackathonteam1.refreshrator.dto.response.recipe.DetailRecipeDto; import com.hackathonteam1.refreshrator.dto.response.recipe.RecipeListDto; -import com.hackathonteam1.refreshrator.entity.Ingredient; -import com.hackathonteam1.refreshrator.entity.IngredientRecipe; -import com.hackathonteam1.refreshrator.entity.Recipe; -import com.hackathonteam1.refreshrator.entity.User; +import com.hackathonteam1.refreshrator.entity.*; import com.hackathonteam1.refreshrator.exception.ConflictException; import com.hackathonteam1.refreshrator.exception.ForbiddenException; import com.hackathonteam1.refreshrator.exception.NotFoundException; import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; +import com.hackathonteam1.refreshrator.repository.FridgeRepository; import com.hackathonteam1.refreshrator.repository.IngredientRecipeRepository; import com.hackathonteam1.refreshrator.repository.IngredientRepository; import com.hackathonteam1.refreshrator.repository.RecipeRepository; @@ -38,6 +36,7 @@ public class RecipeServiceImpl implements RecipeService{ private final RecipeRepository recipeRepository; private final IngredientRepository ingredientRepository; private final IngredientRecipeRepository ingredientRecipeRepository; + private final FridgeRepository fridgeRepository; @Override public RecipeListDto getList(String keyword, String type, int page, int size) { @@ -153,6 +152,32 @@ public void deleteIngredientRecipe(User user, UUID recipeId, DeleteIngredientRec } + @Override + public RecipeListDto getRecommendation(int page, int size, int match, String type, User user) { + Set userFridgeItems = findFridgeByUser(user).getFridgeItem().stream() + .filter(fridgeItem -> !fridgeItem.isExpired()) + .collect(Collectors.toSet()); + + Set usersIngredients = userFridgeItems.stream().map(i -> i.getIngredient()).collect(Collectors.toSet()); + + Sort sort; + if (type.equals("popularity")){ + sort = Sort.by(Sort.Order.desc("likeCount")); + }else{ + sort = Sort.by(Sort.Order.desc("createdAt")); + } + + Pageable pageable = PageRequest.of(page,size,sort); + + Page resultPages = recipeRepository.findAllByIngredientRecipesContain(usersIngredients, match, pageable); + RecipeListDto recipeListDto = RecipeListDto.mapping(resultPages); + return recipeListDto; + } + + private Fridge findFridgeByUser(User user){ + return fridgeRepository.findByUser(user).orElseThrow(()-> new NotFoundException(ErrorCode.FRIDGE_NOT_FOUND)); + } + private Ingredient findIngredientByIngredientId(UUID ingredientId){ return ingredientRepository.findById(ingredientId).orElseThrow(()-> new NotFoundException(ErrorCode.INGREDIENT_NOT_FOUND)); } From 18b7a74a29cdc1a2c60c12d9279138eded254962 Mon Sep 17 00:00:00 2001 From: jihyeonEom Date: Wed, 24 Jul 2024 16:30:25 +0900 Subject: [PATCH 173/212] =?UTF-8?q?feat:=20=EB=82=B4=EA=B0=80=20=EC=A2=8B?= =?UTF-8?q?=EC=95=84=EC=9A=94=20=EB=88=84=EB=A5=B8=20=EB=A0=88=EC=8B=9C?= =?UTF-8?q?=ED=94=BC=20=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20API=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20-=20#69=20-=20AuthenticationConfig?= =?UTF-8?q?=EC=97=90=20uri=20=EC=B6=94=EA=B0=80=20-=20RecipeResponseDto=20?= =?UTF-8?q?&=20RecipeListResponseDto=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/AuthenticationConfig.java | 2 +- .../controller/AuthController.java | 8 ++++ .../response/recipe/RecipeListReponseDto.java | 14 +++++++ .../response/recipe/RecipeResponseDto.java | 15 ++++++++ .../repository/RecipeLikeRepository.java | 12 ++++++ .../refreshrator/service/AuthService.java | 38 +++++++++++++++++++ .../refreshrator/service/RecipeService.java | 1 - 7 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/RecipeListReponseDto.java create mode 100644 src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/RecipeResponseDto.java create mode 100644 src/main/java/com/hackathonteam1/refreshrator/repository/RecipeLikeRepository.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/config/AuthenticationConfig.java b/src/main/java/com/hackathonteam1/refreshrator/config/AuthenticationConfig.java index 94a6795..275d652 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/config/AuthenticationConfig.java +++ b/src/main/java/com/hackathonteam1/refreshrator/config/AuthenticationConfig.java @@ -21,7 +21,7 @@ public class AuthenticationConfig implements WebMvcConfigurer { @Override public void addInterceptors(final InterceptorRegistry registry) { registry.addInterceptor(authenticationInterceptor) - .addPathPatterns("/fridge/**","/recipes/**","/auth/leave","/auth/logout") + .addPathPatterns("/fridge/**","/recipes/**","/auth/leave","/auth/logout", "/auth/likes") .excludePathPatterns("/auth/signin", "/auth/login"); } diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java index 3057bdf..ca55440 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java @@ -7,6 +7,7 @@ import com.hackathonteam1.refreshrator.dto.request.auth.LoginDto; import com.hackathonteam1.refreshrator.dto.request.auth.SigninDto; import com.hackathonteam1.refreshrator.dto.response.auth.TokenResponseDto; +import com.hackathonteam1.refreshrator.dto.response.recipe.RecipeListReponseDto; import com.hackathonteam1.refreshrator.entity.User; import com.hackathonteam1.refreshrator.service.AuthService; import jakarta.servlet.http.HttpServletResponse; @@ -82,4 +83,11 @@ public ResponseEntity> logout(@AuthenticatedUser User user, fi return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "로그아웃 완료"), HttpStatus.OK); } + + // 좋아요 누른 레시피 목록 조회 + @GetMapping("/likes") + public ResponseEntity> showAllRecipeLikes(@AuthenticatedUser User user) { + RecipeListReponseDto recipeListReponseDto = authService.showAllRecipeLikes(user); + return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "좋아요 누른 레시피 목록 조회 성공", recipeListReponseDto), HttpStatus.OK); + } } diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/RecipeListReponseDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/RecipeListReponseDto.java new file mode 100644 index 0000000..d603ecb --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/RecipeListReponseDto.java @@ -0,0 +1,14 @@ +package com.hackathonteam1.refreshrator.dto.response.recipe; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; + +import java.util.List; + +@Getter +@Builder +@AllArgsConstructor +public class RecipeListReponseDto { + private List recipeResponseDtoList; +} diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/RecipeResponseDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/RecipeResponseDto.java new file mode 100644 index 0000000..2295a8c --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/RecipeResponseDto.java @@ -0,0 +1,15 @@ +package com.hackathonteam1.refreshrator.dto.response.recipe; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; + +import java.util.UUID; + +@Getter +@Builder +@AllArgsConstructor +public class RecipeResponseDto { + private UUID recipeId; // 레시피 Id + private String name; // 레시피 이름 +} diff --git a/src/main/java/com/hackathonteam1/refreshrator/repository/RecipeLikeRepository.java b/src/main/java/com/hackathonteam1/refreshrator/repository/RecipeLikeRepository.java new file mode 100644 index 0000000..295b49e --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/repository/RecipeLikeRepository.java @@ -0,0 +1,12 @@ +package com.hackathonteam1.refreshrator.repository; + + +import com.hackathonteam1.refreshrator.entity.RecipeLike; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.UUID; + +@Repository +public interface RecipeLikeRepository extends JpaRepository { +} diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java b/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java index b010087..9457b0a 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java @@ -5,16 +5,24 @@ import com.hackathonteam1.refreshrator.dto.request.auth.LoginDto; import com.hackathonteam1.refreshrator.dto.request.auth.SigninDto; import com.hackathonteam1.refreshrator.dto.response.auth.TokenResponseDto; +import com.hackathonteam1.refreshrator.dto.response.recipe.RecipeListReponseDto; +import com.hackathonteam1.refreshrator.dto.response.recipe.RecipeResponseDto; import com.hackathonteam1.refreshrator.entity.Fridge; +import com.hackathonteam1.refreshrator.entity.RecipeLike; import com.hackathonteam1.refreshrator.entity.User; import com.hackathonteam1.refreshrator.exception.ConflictException; import com.hackathonteam1.refreshrator.exception.ForbiddenException; import com.hackathonteam1.refreshrator.exception.NotFoundException; import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; import com.hackathonteam1.refreshrator.repository.FridgeRepository; +import com.hackathonteam1.refreshrator.repository.RecipeLikeRepository; import com.hackathonteam1.refreshrator.repository.UserRepository; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.List; @Service @AllArgsConstructor @@ -23,6 +31,7 @@ public class AuthService { private final FridgeRepository fridgeRepository; private final PasswordHashEncryption passwordHashEncryption; private final JwtTokenProvider jwtTokenProvider; + private final RecipeLikeRepository recipeLikeRepository; //회원가입 public void signin(SigninDto signinDto){ @@ -79,4 +88,33 @@ public TokenResponseDto login(LoginDto loginDto){ return new TokenResponseDto(accessToken); } + + // 좋아요 누른 레시피 목록 조회 + public RecipeListReponseDto showAllRecipeLikes(User user) { +// List recipeLikes = this.findMyLikeList(user); + List recipeListReponseDtos = new ArrayList<>(); + + List recipeLikes = this.findMyLikeList(user); + + for(RecipeLike recipeLike : recipeLikes){ + RecipeResponseDto recipeResponseDto = RecipeResponseDto.builder() + .recipeId(recipeLike.getRecipe().getId()) + .name(recipeLike.getRecipe().getName()) + .build(); + recipeListReponseDtos.add(recipeResponseDto); + } + return new RecipeListReponseDto(recipeListReponseDtos); + } + + public List findMyLikeList(User user) { + List recipeLikes = this.recipeLikeRepository.findAll(); + List result = new ArrayList<>(); + for(RecipeLike recipeLike : recipeLikes){ + if(user.getId().equals(recipeLike.getUser().getId())){ + result.add(recipeLike); + } + } + return result; + + } } diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java index 73347f3..c817e77 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java @@ -5,7 +5,6 @@ import com.hackathonteam1.refreshrator.dto.request.recipe.ModifyRecipeDto; import com.hackathonteam1.refreshrator.dto.request.recipe.RegisterRecipeDto; import com.hackathonteam1.refreshrator.dto.response.recipe.DetailRecipeDto; -import com.hackathonteam1.refreshrator.entity.Recipe; import com.hackathonteam1.refreshrator.entity.User; import java.util.UUID; From e3893c812928d8e76b9bb134f0d93fc3c4a9e397 Mon Sep 17 00:00:00 2001 From: jihyeonEom Date: Wed, 24 Jul 2024 16:38:31 +0900 Subject: [PATCH 174/212] =?UTF-8?q?refactor:=20RecipeLikeRepository?= =?UTF-8?q?=EC=97=90=20=EB=A9=94=EC=86=8C=EB=93=9C=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?-=20#69?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/RecipeLikeRepository.java | 3 +++ .../refreshrator/service/AuthService.java | 15 +-------------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/repository/RecipeLikeRepository.java b/src/main/java/com/hackathonteam1/refreshrator/repository/RecipeLikeRepository.java index 295b49e..1da7a25 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/repository/RecipeLikeRepository.java +++ b/src/main/java/com/hackathonteam1/refreshrator/repository/RecipeLikeRepository.java @@ -2,11 +2,14 @@ import com.hackathonteam1.refreshrator.entity.RecipeLike; +import com.hackathonteam1.refreshrator.entity.User; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; +import java.util.List; import java.util.UUID; @Repository public interface RecipeLikeRepository extends JpaRepository { + List findAllByUser(User user); } diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java b/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java index 9457b0a..7f92114 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java @@ -91,10 +91,9 @@ public TokenResponseDto login(LoginDto loginDto){ // 좋아요 누른 레시피 목록 조회 public RecipeListReponseDto showAllRecipeLikes(User user) { -// List recipeLikes = this.findMyLikeList(user); List recipeListReponseDtos = new ArrayList<>(); - List recipeLikes = this.findMyLikeList(user); + List recipeLikes = this.recipeLikeRepository.findAllByUser(user); for(RecipeLike recipeLike : recipeLikes){ RecipeResponseDto recipeResponseDto = RecipeResponseDto.builder() @@ -105,16 +104,4 @@ public RecipeListReponseDto showAllRecipeLikes(User user) { } return new RecipeListReponseDto(recipeListReponseDtos); } - - public List findMyLikeList(User user) { - List recipeLikes = this.recipeLikeRepository.findAll(); - List result = new ArrayList<>(); - for(RecipeLike recipeLike : recipeLikes){ - if(user.getId().equals(recipeLike.getUser().getId())){ - result.add(recipeLike); - } - } - return result; - - } } From 06a33b73c79d079ac420c8d0716b9dba38b95661 Mon Sep 17 00:00:00 2001 From: jihyeonEom Date: Wed, 24 Jul 2024 16:51:42 +0900 Subject: [PATCH 175/212] =?UTF-8?q?fix:=20=EB=88=84=EB=9D=BD=EB=90=9C=20im?= =?UTF-8?q?port=20=EC=B6=94=EA=B0=80=20-=20#72?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/exception/errorcode/ErrorCode.java | 2 +- .../refreshrator/service/RecipeServiceImpl.java | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java index 4a8be93..f62033c 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java +++ b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java @@ -42,7 +42,7 @@ public enum ErrorCode { //ConflictException DUPLICATED_EMAIL("4090", "이미 사용 중인 이메일입니다."), RECIPE_INGREDIENT_CONFLICT("4091", "이미 해당 레시피에 존재하는 재료입니다."), - USER_ALREADY_ADD_LIKE("4092", "해당 레시피는 이미 좋아요를 누른 레시피입니다."); + USER_ALREADY_ADD_LIKE("4092", "해당 레시피는 이미 좋아요를 누른 레시피입니다."), //InternetException FILE_STORAGE_ERROR("5000", "파일을 업로드할 수 없습니다."); diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java index 45fdedf..30f7259 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java @@ -14,10 +14,7 @@ import com.hackathonteam1.refreshrator.entity.Recipe; import com.hackathonteam1.refreshrator.entity.User; -import com.hackathonteam1.refreshrator.exception.ConflictException; -import com.hackathonteam1.refreshrator.exception.FileStorageException; -import com.hackathonteam1.refreshrator.exception.ForbiddenException; -import com.hackathonteam1.refreshrator.exception.NotFoundException; +import com.hackathonteam1.refreshrator.exception.*; import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; import com.hackathonteam1.refreshrator.repository.ImageRepository; From a5f9ae1610a95b4376509012012147e6c57ed836 Mon Sep 17 00:00:00 2001 From: jihyeonEom Date: Wed, 24 Jul 2024 17:12:14 +0900 Subject: [PATCH 176/212] =?UTF-8?q?feat:=20=EB=A0=88=EC=8B=9C=ED=94=BC=20?= =?UTF-8?q?=EC=A2=8B=EC=95=84=EC=9A=94=20=EC=82=AD=EC=A0=9C=20API=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20-=20#64?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/RecipeController.java | 10 +++++-- .../exception/errorcode/ErrorCode.java | 1 + .../refreshrator/service/RecipeService.java | 1 + .../service/RecipeServiceImpl.java | 26 ++++++++++++++++--- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java index c6c9d5b..0cfcac5 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/RecipeController.java @@ -16,7 +16,6 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; -import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -76,11 +75,18 @@ public ResponseEntity> deleteIngredientRecipe(@PathVariable("r } // 레시피에 좋아요 추가 - @PostMapping("/{recipe_id}/like") + @PostMapping("/{recipe_id}/likes") public ResponseEntity> addLikeToRecipe(@PathVariable("recipe_id") UUID recipeId, @AuthenticatedUser User user){ recipeService.addLikeToRecipe(user, recipeId); return new ResponseEntity<>(ResponseDto.res(HttpStatus.CREATED, "레시피에 좋아요 추가 성공"),HttpStatus.CREATED); } + + // 레시피에 좋아요 삭제 + @DeleteMapping("{recipe_id}/likes") + public ResponseEntity> deleteLikeFromRecipe(@PathVariable("recipe_id") UUID recipeId, @AuthenticatedUser User user){ + recipeService.deleteLikeFromRecipe(user, recipeId); + return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "레시피에 좋아요 삭제 성공"),HttpStatus.OK); + } @PostMapping(value = "/images", consumes = MediaType.MULTIPART_FORM_DATA_VALUE ) public ResponseEntity> registerFile( diff --git a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java index f62033c..7be6cf5 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java +++ b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java @@ -37,6 +37,7 @@ public enum ErrorCode { FRIDGE_ITEM_NOT_FOUND("4045","냉장고에 등록된 재료 정보를 찾을 수 없습니다."), PAGE_NOT_FOUND("4046", "페이지를 찾을 수 없습니다"), IMAGE_NOT_FOUND("4047","이미지를 찾을 수 없습니다"), + RECIPE_LIKE_NOT_FOUND("4048", "좋아요를 누른 레시피가 아닙니다."), //ConflictException diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java index 24f46c8..2ac9742 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java @@ -41,6 +41,7 @@ public interface RecipeService { public void addLikeToRecipe(User user, UUID recipeId); // 레시피에 좋아요 삭제 + public void deleteLikeFromRecipe(User user, UUID recipeId); //파일(이미지) 등록 public ImageDto registerImage(MultipartFile file); diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java index 30f7259..4bbdc99 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java @@ -17,10 +17,7 @@ import com.hackathonteam1.refreshrator.exception.*; import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; -import com.hackathonteam1.refreshrator.repository.ImageRepository; -import com.hackathonteam1.refreshrator.repository.IngredientRecipeRepository; -import com.hackathonteam1.refreshrator.repository.IngredientRepository; -import com.hackathonteam1.refreshrator.repository.RecipeRepository; +import com.hackathonteam1.refreshrator.repository.*; import com.hackathonteam1.refreshrator.util.S3Uploader; import lombok.RequiredArgsConstructor; @@ -52,6 +49,7 @@ public class RecipeServiceImpl implements RecipeService{ private final IngredientRecipeRepository ingredientRecipeRepository; private final S3Uploader s3Uploader; private final ImageRepository imageRepository; + private final RecipeLikeRepository recipeLikeRepository; @Override public RecipeListDto getList(String keyword, String type, int page, int size) { @@ -238,6 +236,16 @@ public void addLikeToRecipe(User user, UUID recipeId){ this.recipeRepository.save(recipe); } + // 레시피에 좋아요 삭제 + @Override + public void deleteLikeFromRecipe(User user, UUID recipeId){ + Recipe recipe = findRecipeByRecipeId(recipeId); + // 해당 레시피에서 내가 누른 좋아요 반환 + RecipeLike recipeLike = this.findMyRecipeLike(user, recipe); + recipe.getUser().getRecipeLikes().remove(recipeLike); + this.recipeLikeRepository.delete(recipeLike); + } + // 유저가 이미 좋아요를 누른 레시피인지 확인 public void isUserAlreadyAddLike(User user, Recipe recipe){ for (RecipeLike recipeLike : recipe.getRecipeLikes()) { @@ -247,6 +255,16 @@ public void isUserAlreadyAddLike(User user, Recipe recipe){ } } + // 해당 레시피에서 내가 누른 좋아요 반환 + public RecipeLike findMyRecipeLike(User user, Recipe recipe){ + for (RecipeLike recipeLike : recipe.getRecipeLikes()) { + if(recipeLike.getUser().getId().equals(user.getId())){ + return recipeLike; + } + } + throw new NotFoundException(ErrorCode.RECIPE_LIKE_NOT_FOUND); + } + private Recipe findRecipeByRecipeId(UUID recipeId){ return recipeRepository.findById(recipeId).orElseThrow(()-> new NotFoundException(ErrorCode.RECIPE_NOT_FOUND)); } From 10f4fdd5cb41a3f0b43c7e236e0a7217f694b62c Mon Sep 17 00:00:00 2001 From: jihyeonEom Date: Wed, 24 Jul 2024 17:21:50 +0900 Subject: [PATCH 177/212] =?UTF-8?q?refactor:=20DB=EC=97=90=20=EC=9E=88?= =?UTF-8?q?=EB=8A=94=20=EC=9E=AC=EB=A3=8C=20=EC=A0=84=EC=B2=B4=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20API=20=EC=82=AD=EC=A0=9C=20-=20#47?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/IngredientController.java | 9 +-------- .../refreshrator/service/IngredientService.java | 14 -------------- .../refreshrator/service/RecipeServiceImpl.java | 1 - 3 files changed, 1 insertion(+), 23 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/IngredientController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/IngredientController.java index 53ab111..7d52a89 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/IngredientController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/IngredientController.java @@ -15,15 +15,8 @@ public class IngredientController { private final IngredientService ingredientService; - // DB에 있는 재료 전체 조회 - @GetMapping() - public ResponseEntity> showAllIngredients() { - IngredientListDto ingredientListDto = ingredientService.showAllIngredients(); - return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "모든 재료 조회 성공", ingredientListDto), HttpStatus.OK); - } - // DB에 있는 재료 검색 - @GetMapping("/search") + @GetMapping() public ResponseEntity> searchIngredientByName(@RequestParam String name) { IngredientListDto ingredientListDto = ingredientService.searchIngredientByName(name); return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "재료 검색 성공", ingredientListDto), HttpStatus.OK); diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/IngredientService.java b/src/main/java/com/hackathonteam1/refreshrator/service/IngredientService.java index 957990c..89fde95 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/IngredientService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/IngredientService.java @@ -17,20 +17,6 @@ public class IngredientService { private final IngredientRepository ingredientRepository; - public IngredientListDto showAllIngredients() { - List ingredients = ingredientRepository.findAll(); - List ingredientDtoList = new ArrayList<>(); - - for (Ingredient ingredient : ingredients) { - IngredientDto ingredientDto = IngredientDto.builder() - .id(ingredient.getId()) - .name(ingredient.getName()) - .build(); - ingredientDtoList.add(ingredientDto); - } - return new IngredientListDto(ingredientDtoList); - } - public IngredientListDto searchIngredientByName(String name) { List ingredients = ingredientRepository.findAll(); List ingredientDtoList = new ArrayList<>(); diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java index 7d8c742..80bca28 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java @@ -15,7 +15,6 @@ import com.hackathonteam1.refreshrator.entity.Recipe; import com.hackathonteam1.refreshrator.entity.User; import com.hackathonteam1.refreshrator.entity.Fridge; -import com.hackathonteam1.refreshrator.entity.FrdigeItem; import com.hackathonteam1.refreshrator.entity.Image; import com.hackathonteam1.refreshrator.exception.*; From d96c4b8a8beace30c26e243ba32ac47fef7f85fb Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 18:34:16 +0900 Subject: [PATCH 178/212] =?UTF-8?q?feat:=20=EC=82=AC=EC=9A=A9=20=EC=95=88?= =?UTF-8?q?=ED=95=98=EB=8A=94=20Dto=20=EC=A0=9C=EA=B1=B0=20-=20#76=20?= =?UTF-8?q?=EA=B8=B0=EC=A1=B4=EC=97=90=20=EC=A1=B4=EC=9E=AC=ED=95=98?= =?UTF-8?q?=EB=8A=94=20recipeDto=EB=A1=9C=20=EB=B0=94=EA=BF=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/recipe/RecipeListReponseDto.java | 14 -------------- .../dto/response/recipe/RecipeResponseDto.java | 15 --------------- 2 files changed, 29 deletions(-) delete mode 100644 src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/RecipeListReponseDto.java delete mode 100644 src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/RecipeResponseDto.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/RecipeListReponseDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/RecipeListReponseDto.java deleted file mode 100644 index d603ecb..0000000 --- a/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/RecipeListReponseDto.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.hackathonteam1.refreshrator.dto.response.recipe; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; - -import java.util.List; - -@Getter -@Builder -@AllArgsConstructor -public class RecipeListReponseDto { - private List recipeResponseDtoList; -} diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/RecipeResponseDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/RecipeResponseDto.java deleted file mode 100644 index 2295a8c..0000000 --- a/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/RecipeResponseDto.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.hackathonteam1.refreshrator.dto.response.recipe; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; - -import java.util.UUID; - -@Getter -@Builder -@AllArgsConstructor -public class RecipeResponseDto { - private UUID recipeId; // 레시피 Id - private String name; // 레시피 이름 -} From 1641305d59407f5beee13f68e6e71c55b18a2436 Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 18:37:03 +0900 Subject: [PATCH 179/212] =?UTF-8?q?refactor:=20=EB=A0=88=EC=8B=9C=ED=94=BC?= =?UTF-8?q?=EB=A5=BC=20response=ED=95=B4=EC=A3=BC=EB=8A=94=20Dto=EC=97=90?= =?UTF-8?q?=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20dto=20=ED=95=84=EB=93=9C?= =?UTF-8?q?=EB=A5=BC=20=EC=B6=94=EA=B0=80=ED=95=A8.=20-=20#76?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/dto/request/recipe/ModifyRecipeDto.java | 6 +++++- .../refreshrator/dto/request/recipe/RegisterRecipeDto.java | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/ModifyRecipeDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/ModifyRecipeDto.java index c94f804..5c6c74c 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/ModifyRecipeDto.java +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/ModifyRecipeDto.java @@ -5,6 +5,8 @@ import lombok.Getter; import lombok.NoArgsConstructor; +import java.util.UUID; + @Getter @AllArgsConstructor @NoArgsConstructor @@ -13,6 +15,8 @@ public class ModifyRecipeDto { @Size(min = 1, max = 20) private String name; - @Size(min = 1) + @Size(max = 5000) private String cookingStep; + + private UUID imageId; } diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/RegisterRecipeDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/RegisterRecipeDto.java index cdb5864..60a9ae4 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/RegisterRecipeDto.java +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/RegisterRecipeDto.java @@ -7,11 +7,14 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; +import lombok.NoArgsConstructor; import java.util.List; import java.util.UUID; @Getter +@AllArgsConstructor +@NoArgsConstructor public class RegisterRecipeDto { @Size(min = 1, max = 20) @@ -21,8 +24,10 @@ public class RegisterRecipeDto { @NotNull private List ingredientIds; - @Size(min = 1) + @Size(max = 5000) @NotBlank private String cookingStep; + private UUID imageId; + } From 9ba4692cf352434d1d9331d9ebdbf53adb5a805d Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 18:38:40 +0900 Subject: [PATCH 180/212] =?UTF-8?q?refactor:=20=EB=A0=88=EC=8B=9C=ED=94=BC?= =?UTF-8?q?=20=EC=9D=B4=EB=A6=84=20=EA=B8=80=EC=9E=90=EC=88=98=20=EC=A0=9C?= =?UTF-8?q?=ED=95=9C=20=EC=83=9D=EC=84=B1=20-=20#76?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/dto/request/recipe/ModifyRecipeDto.java | 2 +- .../refreshrator/dto/request/recipe/RegisterRecipeDto.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/ModifyRecipeDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/ModifyRecipeDto.java index 5c6c74c..a88b5d2 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/ModifyRecipeDto.java +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/ModifyRecipeDto.java @@ -12,7 +12,7 @@ @NoArgsConstructor public class ModifyRecipeDto { - @Size(min = 1, max = 20) + @Size(min = 1, max = 15) private String name; @Size(max = 5000) diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/RegisterRecipeDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/RegisterRecipeDto.java index 60a9ae4..d428f05 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/RegisterRecipeDto.java +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/request/recipe/RegisterRecipeDto.java @@ -17,7 +17,7 @@ @NoArgsConstructor public class RegisterRecipeDto { - @Size(min = 1, max = 20) + @Size(min = 1, max = 15) @NotBlank private String name; From a858781625905df2b9a357d38b6f19ce72f5c245 Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 18:39:57 +0900 Subject: [PATCH 181/212] =?UTF-8?q?refactor:=20Recipe=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=20=EB=82=B4=EB=B6=80=20=EB=A6=AC=ED=8C=A9=ED=86=A0?= =?UTF-8?q?=EB=A7=81=20-=20#76=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EC=97=85?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=8A=B8=20=ED=95=98=EB=8A=94=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EC=9E=91=EC=84=B1=20image=EB=A5=BC=20null?= =?UTF-8?q?able=EB=A1=9C=20=EC=84=A4=EC=A0=95=20cookingStep=EC=9D=98=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20=EA=B8=80=EC=9E=90=20=EC=88=98=EA=B0=80=20?= =?UTF-8?q?=EB=A7=8E=EC=9D=84=20=EC=88=98=20=EC=9E=88=EA=B8=B0=20=EB=95=8C?= =?UTF-8?q?=EB=AC=B8=EC=97=90=20=ED=95=84=EB=93=9C=EC=97=90=20Lob=ED=83=80?= =?UTF-8?q?=EC=9E=85=EC=9C=BC=EB=A1=9C=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hackathonteam1/refreshrator/entity/Recipe.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/Recipe.java b/src/main/java/com/hackathonteam1/refreshrator/entity/Recipe.java index 0494265..30c7f5c 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/entity/Recipe.java +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/Recipe.java @@ -1,5 +1,8 @@ package com.hackathonteam1.refreshrator.entity; +import com.hackathonteam1.refreshrator.exception.ConflictException; +import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; +import io.micrometer.common.lang.Nullable; import jakarta.persistence.*; import lombok.*; import org.hibernate.annotations.Formula; @@ -18,6 +21,7 @@ public class Recipe extends BaseEntity{ private String name; @Column(nullable = false) + @Lob private String cookingStep; @ManyToOne(fetch = FetchType.LAZY, optional = false) @@ -31,6 +35,7 @@ public class Recipe extends BaseEntity{ @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) @JoinColumn(name = "image_id") + @Nullable private Image image; @Formula("(select count(rl.id) from recipe_like rl where rl.recipe_id = id)") @@ -42,6 +47,12 @@ public void updateName(String name){ public void updateCookingStep(String cookingStep){ this.cookingStep = cookingStep; } + public void updateImage(Image image){ + if(this.image != null){ + throw new ConflictException(ErrorCode.RECIPE_IMAGE_CONFLICT); + } + this.image = image; + } public Boolean isContainingImage(){ return this.getImage()!=null; From 1a32ce7a726c289ad280b9dfb344a20d39bf577e Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 18:40:40 +0900 Subject: [PATCH 182/212] =?UTF-8?q?refactor:=20=EB=A0=88=EC=8B=9C=ED=94=BC?= =?UTF-8?q?=20Dto=20=EC=88=98=EC=A0=95=20-=20#76=20=EB=A0=88=EC=8B=9C?= =?UTF-8?q?=ED=94=BC=20=EC=95=84=EC=9D=B4=EB=94=94=EC=99=80=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80=20=ED=95=84=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/dto/response/recipe/RecipeDto.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/RecipeDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/RecipeDto.java index 6304f07..5fabf14 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/RecipeDto.java +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/RecipeDto.java @@ -1,16 +1,21 @@ package com.hackathonteam1.refreshrator.dto.response.recipe; +import com.hackathonteam1.refreshrator.dto.response.file.ImageDto; import com.hackathonteam1.refreshrator.entity.Recipe; import lombok.AllArgsConstructor; import lombok.Getter; +import java.util.UUID; + @Getter @AllArgsConstructor public class RecipeDto { + private UUID recipeId; private String name; private int likeCount; + private ImageDto image; public static RecipeDto mapping(Recipe recipe){ - return new RecipeDto(recipe.getName(), recipe.getLikeCount()); + return new RecipeDto(recipe.getId(), recipe.getName(), recipe.getLikeCount(),ImageDto.mapping(recipe.getImage())); } } From 9e273431417f6d9aa6dbc5963510fbd3b559d302 Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 18:41:14 +0900 Subject: [PATCH 183/212] =?UTF-8?q?refactor:=20=EC=9D=B4=EB=AF=B8=EC=A7=80?= =?UTF-8?q?=20Dto=20=EC=88=98=EC=A0=95=20-=20#76=20=EC=9D=B4=EB=AF=B8?= =?UTF-8?q?=EC=A7=80=EA=B0=80=20null=EC=9D=B4=EC=96=B4=EB=8F=84=20?= =?UTF-8?q?=EA=B4=9C=EC=B0=AE=EB=8F=84=EB=A1=9D=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/dto/response/file/ImageDto.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/response/file/ImageDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/response/file/ImageDto.java index 7055ae7..51c0435 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/dto/response/file/ImageDto.java +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/response/file/ImageDto.java @@ -16,6 +16,9 @@ public class ImageDto { private String url; public static ImageDto mapping(Image image){ + if(image==null){ + return null; + } return new ImageDto(image.getId(), image.getUrl()); } } From d7a32de5265074679bbccfb7d01ca3427e875178 Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 18:41:57 +0900 Subject: [PATCH 184/212] =?UTF-8?q?feat:=20ErrorCode=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?=20-=20#76=20=ED=95=9C=20=EB=A0=88=EC=8B=9C=ED=94=BC=EC=97=90?= =?UTF-8?q?=20=EC=9D=B4=EB=AF=B8=EC=A7=80=EB=A5=BC=20=EC=A4=91=EB=B3=B5?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EB=93=B1=EB=A1=9D=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20=EC=97=90=EB=9F=AC=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/exception/errorcode/ErrorCode.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java index f62033c..f107e16 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java +++ b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java @@ -43,6 +43,7 @@ public enum ErrorCode { DUPLICATED_EMAIL("4090", "이미 사용 중인 이메일입니다."), RECIPE_INGREDIENT_CONFLICT("4091", "이미 해당 레시피에 존재하는 재료입니다."), USER_ALREADY_ADD_LIKE("4092", "해당 레시피는 이미 좋아요를 누른 레시피입니다."), + RECIPE_IMAGE_CONFLICT("4093", "레시피에 이미지가 이미 존재합니다."), //InternetException FILE_STORAGE_ERROR("5000", "파일을 업로드할 수 없습니다."); From 205506065b780c1aba8a54ea87a259db096fc05f Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 18:42:20 +0900 Subject: [PATCH 185/212] =?UTF-8?q?refactor:=20=ED=8E=98=EC=9D=B4=EC=A7=80?= =?UTF-8?q?=EB=84=A4=EC=9D=B4=EC=85=98=EC=9D=84=20=EC=9C=84=ED=95=B4=20Jpa?= =?UTF-8?q?Repo=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=88=98=EC=A0=95=20-=20#?= =?UTF-8?q?76?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/repository/RecipeLikeRepository.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/repository/RecipeLikeRepository.java b/src/main/java/com/hackathonteam1/refreshrator/repository/RecipeLikeRepository.java index 1da7a25..8071738 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/repository/RecipeLikeRepository.java +++ b/src/main/java/com/hackathonteam1/refreshrator/repository/RecipeLikeRepository.java @@ -3,6 +3,8 @@ import com.hackathonteam1.refreshrator.entity.RecipeLike; import com.hackathonteam1.refreshrator.entity.User; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @@ -11,5 +13,5 @@ @Repository public interface RecipeLikeRepository extends JpaRepository { - List findAllByUser(User user); + Page findAllByUser(User user, Pageable pageable); } From 7aa314bb257f9f9afb84caa9b63b4e025acf878e Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 18:43:07 +0900 Subject: [PATCH 186/212] =?UTF-8?q?refactor:=20=EB=A0=88=EC=8B=9C=ED=94=BC?= =?UTF-8?q?=20=EC=A2=8B=EC=95=84=EC=9A=94=20=EB=AA=A9=EB=A1=9D=EC=9D=84=20?= =?UTF-8?q?=EB=B6=88=EB=9F=AC=EC=98=AC=20=EB=95=8C=20=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=20=EB=84=A4=EC=9D=B4=EC=85=98=EC=9D=84=20=EC=9C=84?= =?UTF-8?q?=ED=95=9C=20requestparam=20=EC=B6=94=EA=B0=80-=20#76?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/controller/AuthController.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java index ca55440..bf17b48 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java @@ -7,7 +7,7 @@ import com.hackathonteam1.refreshrator.dto.request.auth.LoginDto; import com.hackathonteam1.refreshrator.dto.request.auth.SigninDto; import com.hackathonteam1.refreshrator.dto.response.auth.TokenResponseDto; -import com.hackathonteam1.refreshrator.dto.response.recipe.RecipeListReponseDto; +import com.hackathonteam1.refreshrator.dto.response.recipe.RecipeListDto; import com.hackathonteam1.refreshrator.entity.User; import com.hackathonteam1.refreshrator.service.AuthService; import jakarta.servlet.http.HttpServletResponse; @@ -86,8 +86,10 @@ public ResponseEntity> logout(@AuthenticatedUser User user, fi // 좋아요 누른 레시피 목록 조회 @GetMapping("/likes") - public ResponseEntity> showAllRecipeLikes(@AuthenticatedUser User user) { - RecipeListReponseDto recipeListReponseDto = authService.showAllRecipeLikes(user); - return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "좋아요 누른 레시피 목록 조회 성공", recipeListReponseDto), HttpStatus.OK); + public ResponseEntity> showAllRecipeLikes(@AuthenticatedUser User user, + @RequestParam(name = "page", defaultValue = "0")int page, + @RequestParam(name = "size", defaultValue = "10")int size) { + RecipeListDto recipeListDto = authService.showAllRecipeLikes(user, page, size); + return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "좋아요 누른 레시피 목록 조회 성공", recipeListDto), HttpStatus.OK); } } From 6006238e4def0a9c9c7a5a1369c09731bdce8d5a Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 18:43:40 +0900 Subject: [PATCH 187/212] =?UTF-8?q?refactor:=20=EC=A2=8B=EC=95=84=EC=9A=94?= =?UTF-8?q?=20=EB=88=84=EB=A5=B8=20=EB=A0=88=EC=8B=9C=ED=94=BC=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20=EB=B9=84=EC=A6=88=EB=8B=88?= =?UTF-8?q?=EC=8A=A4=20=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95=20-=20#76?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/service/AuthService.java | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java b/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java index 7f92114..0d4a15f 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java @@ -5,9 +5,10 @@ import com.hackathonteam1.refreshrator.dto.request.auth.LoginDto; import com.hackathonteam1.refreshrator.dto.request.auth.SigninDto; import com.hackathonteam1.refreshrator.dto.response.auth.TokenResponseDto; -import com.hackathonteam1.refreshrator.dto.response.recipe.RecipeListReponseDto; -import com.hackathonteam1.refreshrator.dto.response.recipe.RecipeResponseDto; +import com.hackathonteam1.refreshrator.dto.response.recipe.RecipeDto; +import com.hackathonteam1.refreshrator.dto.response.recipe.RecipeListDto; import com.hackathonteam1.refreshrator.entity.Fridge; +import com.hackathonteam1.refreshrator.entity.Recipe; import com.hackathonteam1.refreshrator.entity.RecipeLike; import com.hackathonteam1.refreshrator.entity.User; import com.hackathonteam1.refreshrator.exception.ConflictException; @@ -18,11 +19,12 @@ import com.hackathonteam1.refreshrator.repository.RecipeLikeRepository; import com.hackathonteam1.refreshrator.repository.UserRepository; import lombok.AllArgsConstructor; +import org.springframework.data.domain.*; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; @Service @AllArgsConstructor @@ -90,18 +92,18 @@ public TokenResponseDto login(LoginDto loginDto){ } // 좋아요 누른 레시피 목록 조회 - public RecipeListReponseDto showAllRecipeLikes(User user) { - List recipeListReponseDtos = new ArrayList<>(); + public RecipeListDto showAllRecipeLikes(User user, int page, int size) { + List recipeLists = new ArrayList<>(); - List recipeLikes = this.recipeLikeRepository.findAllByUser(user); + Sort sort = Sort.by(Sort.Order.desc("createdAt")); - for(RecipeLike recipeLike : recipeLikes){ - RecipeResponseDto recipeResponseDto = RecipeResponseDto.builder() - .recipeId(recipeLike.getRecipe().getId()) - .name(recipeLike.getRecipe().getName()) - .build(); - recipeListReponseDtos.add(recipeResponseDto); - } - return new RecipeListReponseDto(recipeListReponseDtos); + Pageable pageable = PageRequest.of(page, size); + + Page recipeLikes = this.recipeLikeRepository.findAllByUser(user, pageable); + List recipes = recipeLikes.stream().map(like -> like.getRecipe()).collect(Collectors.toList()); + Page recipePage = new PageImpl<>(recipes); + RecipeListDto recipeListDto = RecipeListDto.mapping(recipePage); + + return recipeListDto; } } From d73ff47df01388a177c8b1cffbc1c21304be4640 Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 18:44:12 +0900 Subject: [PATCH 188/212] =?UTF-8?q?refactor:=20=EB=94=94=ED=85=8C=EC=9D=BC?= =?UTF-8?q?=20dto=EC=97=90=EC=84=9C=EB=8F=84=20=EC=9D=B4=EB=AF=B8=EC=A7=80?= =?UTF-8?q?=20=EC=82=AC=EC=9A=A9=ED=95=A0=20=EC=88=98=20=EC=9E=88=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=B6=94=EA=B0=80=20-=20#76?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/recipe/DetailRecipeDto.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/DetailRecipeDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/DetailRecipeDto.java index f4e4025..677904f 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/DetailRecipeDto.java +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/DetailRecipeDto.java @@ -1,24 +1,31 @@ package com.hackathonteam1.refreshrator.dto.response.recipe; +import com.hackathonteam1.refreshrator.dto.response.file.ImageDto; +import com.hackathonteam1.refreshrator.entity.Image; import com.hackathonteam1.refreshrator.entity.IngredientRecipe; +import com.hackathonteam1.refreshrator.entity.Recipe; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; import java.util.List; +import java.util.UUID; import java.util.stream.Collectors; @Getter @Builder @AllArgsConstructor public class DetailRecipeDto { + private UUID id; private String name; private List ingredientRecipes; private String cookingStep; + private ImageDto image; - public static DetailRecipeDto detailRecipeDto(String name, List ingredientRecipes, String cookingStep){ + public static DetailRecipeDto mapping(Recipe recipe, List ingredientRecipes){ List ingredientDtos = ingredientRecipes.stream().map( i->IngredientRecipeResponseDto.changeToDto(i)).collect(Collectors.toList()); - return new DetailRecipeDto(name, ingredientDtos, cookingStep); + return new DetailRecipeDto(recipe.getId(), recipe.getName(), ingredientDtos, + recipe.getCookingStep(),ImageDto.mapping(recipe.getImage())); } } From cf382b7a0efb24d7717f468d29865b1f8e8bc185 Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 18:44:48 +0900 Subject: [PATCH 189/212] =?UTF-8?q?refactor:=20=EB=A0=88=EC=8B=9C=ED=94=BC?= =?UTF-8?q?=20=EB=93=B1=EB=A1=9D,=20=EC=88=98=EC=A0=95=20=EC=8B=9C=20?= =?UTF-8?q?=EC=9D=B4=EB=AF=B8=EC=A7=80=EB=A5=BC=20=ED=8F=AC=ED=95=A8?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=A6=AC=ED=8C=A9=ED=86=A0?= =?UTF-8?q?=EB=A7=81=20-=20#76?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/service/RecipeServiceImpl.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java index 677c7fe..92add89 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java @@ -15,7 +15,6 @@ import com.hackathonteam1.refreshrator.entity.Recipe; import com.hackathonteam1.refreshrator.entity.User; import com.hackathonteam1.refreshrator.entity.Fridge; -import com.hackathonteam1.refreshrator.entity.FrdigeItem; import com.hackathonteam1.refreshrator.entity.Image; import com.hackathonteam1.refreshrator.exception.*; @@ -86,14 +85,21 @@ public RecipeListDto getList(String keyword, String type, int page, int size) { @Override @Transactional public void register(RegisterRecipeDto registerRecipeDto, User user) { + Image image = null; + + if(registerRecipeDto.getImageId()!=null){ + image = findImageByImageId(registerRecipeDto.getImageId()); + } Recipe recipe = Recipe.builder() .name(registerRecipeDto.getName()) .cookingStep(registerRecipeDto.getCookingStep()) .user(user) + .image(image) .build(); recipeRepository.save(recipe); + registerRecipeDto.getIngredientIds().stream().forEach(i -> registerRecipeIngredient(findIngredientByIngredientId(i),recipe)); } @@ -103,7 +109,7 @@ public DetailRecipeDto getDetail(UUID recipeId) { Recipe recipe = findRecipeByRecipeId(recipeId); List ingredientRecipes = findAllIngredientRecipeByRecipe(recipe); - DetailRecipeDto detailRecipeDto = DetailRecipeDto.detailRecipeDto(recipe.getName(),ingredientRecipes, recipe.getCookingStep()); + DetailRecipeDto detailRecipeDto = DetailRecipeDto.mapping(recipe, ingredientRecipes); return detailRecipeDto; } @@ -113,6 +119,11 @@ public void modifyContent(ModifyRecipeDto modifyRecipeDto, User user, UUID recip Recipe recipe = findRecipeByRecipeId(recipeId); checkAuth(recipe.getUser(), user); + Image image = null; + + if(modifyRecipeDto.getImageId()!=null){ + recipe.updateImage(findImageByImageId(modifyRecipeDto.getImageId())); + } if(modifyRecipeDto.getName()!=null){ recipe.updateName(modifyRecipeDto.getName()); } From 8a2ea5858dbf607aa74cf5f286e7f0037c93bc4f Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 19:41:00 +0900 Subject: [PATCH 190/212] =?UTF-8?q?feat:=20cors=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20-=20#80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AuthenticationInterceptor.java | 3 ++ .../refreshrator/config/CorsConfig.java | 29 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/config/CorsConfig.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticationInterceptor.java b/src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticationInterceptor.java index 8b2bc83..7bba7ae 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticationInterceptor.java +++ b/src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticationInterceptor.java @@ -27,6 +27,9 @@ public class AuthenticationInterceptor implements HandlerInterceptor { public boolean preHandle(final HttpServletRequest request, final HttpServletResponse response, final Object handler) { + if(request.getMethod().equals("OPTIONS")){ + return true; + } String accessToken = AuthenticationExtractor.extract(request); UUID userId = UUID.fromString(jwtTokenProvider.getPayload(accessToken)); User user = findExistingUser(userId); diff --git a/src/main/java/com/hackathonteam1/refreshrator/config/CorsConfig.java b/src/main/java/com/hackathonteam1/refreshrator/config/CorsConfig.java new file mode 100644 index 0000000..493e03a --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/config/CorsConfig.java @@ -0,0 +1,29 @@ +package com.hackathonteam1.refreshrator.config; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.HttpMethod; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +import java.util.List; + +@Configuration +public class CorsConfig implements WebMvcConfigurer { + private final long MAX_AGE_SECS = 3600; + @Value("${client.host}") + private List clientHosts; + + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**") + .allowedOrigins(clientHosts.toArray(new String[0])) + .allowedMethods(HttpMethod.GET.name(), HttpMethod.POST.name(), HttpMethod.PUT.name(), + HttpMethod.PATCH.name(), HttpMethod.DELETE.name(), + HttpMethod.OPTIONS.name()) + .allowedHeaders("*") + .allowCredentials(true) + .maxAge(MAX_AGE_SECS); + } +} + From 4c4be790f1cac078b1cfa952031f224a8cd35375 Mon Sep 17 00:00:00 2001 From: jher235 Date: Wed, 24 Jul 2024 23:59:13 +0900 Subject: [PATCH 191/212] =?UTF-8?q?feat:=20HealthController=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20-=20#82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/controller/HealthController.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/controller/HealthController.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/HealthController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/HealthController.java new file mode 100644 index 0000000..1336686 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/HealthController.java @@ -0,0 +1,12 @@ +package com.hackathonteam1.refreshrator.controller; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HealthController { + @GetMapping("/health") + public String checkHealth(){ + return "ok"; + } +} \ No newline at end of file From 73ce1ec08114c658c5289da938a65f51f168845d Mon Sep 17 00:00:00 2001 From: jher235 Date: Thu, 25 Jul 2024 00:12:41 +0900 Subject: [PATCH 192/212] =?UTF-8?q?refactor:=20=ED=8E=98=EC=9D=B4=EC=A7=80?= =?UTF-8?q?=EB=84=A4=EC=9D=B4=EC=85=98=20=EC=82=AC=EC=9A=A9=20=EC=8B=9C=20?= =?UTF-8?q?=EB=88=84=EB=9D=BD=EB=90=9C=20=EC=98=88=EC=99=B8=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=20=EC=9E=91=EC=84=B1=20-=20#84=20=EA=B8=B0=EC=A1=B4?= =?UTF-8?q?=EC=97=90=20=EC=A1=B4=EC=9E=AC=ED=95=98=EB=8D=98=20checkValidPa?= =?UTF-8?q?ge=20=EB=A9=94=EC=84=9C=EB=93=9C=EB=A5=BC=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EC=97=AC=20=EC=B2=98=EB=A6=AC=ED=95=A8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/service/AuthService.java | 10 +++++++++- .../refreshrator/service/RecipeServiceImpl.java | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java b/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java index 0d4a15f..602123b 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java @@ -102,8 +102,16 @@ public RecipeListDto showAllRecipeLikes(User user, int page, int size) { Page recipeLikes = this.recipeLikeRepository.findAllByUser(user, pageable); List recipes = recipeLikes.stream().map(like -> like.getRecipe()).collect(Collectors.toList()); Page recipePage = new PageImpl<>(recipes); - RecipeListDto recipeListDto = RecipeListDto.mapping(recipePage); + checkValidPage(recipePage, page); + + RecipeListDto recipeListDto = RecipeListDto.mapping(recipePage); return recipeListDto; } + + private void checkValidPage(Page pages, int page){ + if(pages.getTotalPages() <= page && page != 0){ + throw new NotFoundException(ErrorCode.PAGE_NOT_FOUND); + } + } } diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java index fec2aeb..37fcdd3 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java @@ -204,6 +204,7 @@ public RecipeListDto getRecommendation(int page, int size, int match, String typ Pageable pageable = PageRequest.of(page,size,sort); Page resultPages = recipeRepository.findAllByIngredientRecipesContain(usersIngredients, match, pageable); + checkValidPage(resultPages, page); RecipeListDto recipeListDto = RecipeListDto.mapping(resultPages); return recipeListDto; } From 177344b497798e618e7016eab35a7d3b180416e6 Mon Sep 17 00:00:00 2001 From: jher235 Date: Fri, 26 Jul 2024 16:28:18 +0900 Subject: [PATCH 193/212] =?UTF-8?q?feat:=20CI/CD=20=EC=A0=81=EC=9A=A9?= =?UTF-8?q?=EC=9D=84=20=EC=9C=84=ED=95=9C=20gradle.yml=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20-=20#86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/gradle.yml | 67 ++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .github/workflows/gradle.yml diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml new file mode 100644 index 0000000..f62ccbd --- /dev/null +++ b/.github/workflows/gradle.yml @@ -0,0 +1,67 @@ +name: Java CI/CD with Gradle # 워크플로우 이름 + +on: # 언제 실행할 것인지에 대한 설정 + push: # 푸시 이벤트가 발생할 때 + branches: [ "main" ] # main 브랜치에 푸시 이벤트가 발생할 때 + +permissions: # 권한 설정 + contents: read # 해당 레포지토리의 모든 파일을 읽기 권한을 부여한다. + +jobs: # 실행할 작업들에 대한 설정 + # Spring Boot 애플리케이션을 빌드하여 도커허브에 푸시하는 과정 + build-docker-image: # 작업 이름 - 애플리케이션을 빌드하여 도커허브에 푸시하는 작업 + runs-on: ubuntu-latest # 실행 환경 설정 + steps: # 작업 내용 + - uses: actions/checkout@v3 + + - name: Grant execute permission for gradlew # gradlew 파일에 실행 권한 부여 + run: chmod +x gradlew # gradlew 파일에 실행 권한을 부여한다. + + - name: Set up JDK 17 # 1. Java 17 세팅 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + - name: make application.properties # 2. application.properties 파일 생성 + run: | + mkdir -p ./src/main/resources + cd ./src/main/resources + touch ./application.properties + echo "${{ secrets.PROPERTIES }}" > ./application.properties + shell: bash + + - name: Build with Gradle # 3. Spring Boot 애플리케이션 빌드, jar 파일 생성 + uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0 + with: + arguments: clean bootJar + + - name: docker image build # 4. Docker 이미지 빌드 + run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE }} . + + - name: docker login # 5. DockerHub 로그인 + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: docker Hub push # 6. Docker Hub 이미지 푸시 + run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE }} + + deploy: # 작업 이름 - 도커허브에 푸시한 이미지를 서버에 배포하는 작업 + needs: build-docker-image # build-docker-image 작업이 성공적으로 완료되어야 함 + runs-on: ubuntu-latest # 실행 환경 설정 + steps: # 작업 내용 + - name: ssh connect & production # EC2에 접속하여 도커 이미지 실행 + uses: appleboy/ssh-action@master + with: + host: ${{secrets.HOST}} # EC2 인스턴스의 IP 주소 + username: ${{secrets.USERNAME}} # EC2 인스턴스의 사용자 이름 (ubuntu) + key: ${{secrets.PASSWORD}} # EC2 인스턴스의 비밀번호 (SSH 키) + script: | # 실행할 스크립트 + sudo docker login --username ${{secrets.DOCKERHUB_USERNAME}} --password ${{secrets.DOCKERHUB_PASSWORD}} + sudo docker pull ${{secrets.DOCKERHUB_USERNAME}}/${{secrets.DOCKERHUB_IMAGE}} + sudo docker ps -q | xargs -r sudo docker stop + sudo docker ps -aq | xargs -r sudo docker rm + sudo docker run --name ${{secrets.DOCKERHUB_IMAGE}} --rm -d -p 8080:8080 ${{secrets.DOCKERHUB_USERNAME}}/${{secrets.DOCKERHUB_IMAGE}} + sudo docker system prune -f \ No newline at end of file From 46774b3fb1412391c7ee0e3db91379a17990a6b3 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sat, 27 Jul 2024 10:48:13 +0900 Subject: [PATCH 194/212] =?UTF-8?q?feat:=20user=20=EC=BB=A8=ED=8A=B8?= =?UTF-8?q?=EB=A1=A4=EB=9F=AC=20=EC=9E=91=EC=84=B1=20-=20#88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/UserController.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/controller/UserController.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/UserController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/UserController.java new file mode 100644 index 0000000..03d3fb2 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/UserController.java @@ -0,0 +1,33 @@ +package com.hackathonteam1.refreshrator.controller; + +import com.hackathonteam1.refreshrator.annotation.AuthenticatedUser; +import com.hackathonteam1.refreshrator.dto.ResponseDto; +import com.hackathonteam1.refreshrator.dto.response.recipe.RecipeListDto; +import com.hackathonteam1.refreshrator.entity.User; +import com.hackathonteam1.refreshrator.service.RecipeService; +import lombok.AllArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@AllArgsConstructor +@RequestMapping("/users") +public class UserController { + + private final RecipeService recipeService; + + @GetMapping("/me/recipes") + public ResponseEntity> getMyRecipe(@AuthenticatedUser User user, + @RequestParam(name = "type", defaultValue = "newest") String type, + @RequestParam(name = "page", defaultValue = "0") int page, + @RequestParam(name = "size", defaultValue = "10") int size){ + RecipeListDto recipeListDto = recipeService.findMyRecipes(user, type, page, size); + return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "자신이 작성한 레시피 목록 조회 성공", recipeListDto),HttpStatus.OK); + } + + +} From 5593b36cabaaedc07fe6eefc4221ca1476d4b160 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sat, 27 Jul 2024 10:48:49 +0900 Subject: [PATCH 195/212] =?UTF-8?q?feat:=20=EC=9C=A0=EC=A0=80=EB=A5=BC=20?= =?UTF-8?q?=ED=86=B5=ED=95=B4=20=EB=A0=88=EC=8B=9C=ED=94=BC=EB=A5=BC=20?= =?UTF-8?q?=EC=B0=BE=EA=B8=B0=20=EC=9C=84=ED=95=9C=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EC=9E=91=EC=84=B1=20-=20#88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/repository/RecipeRepository.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/repository/RecipeRepository.java b/src/main/java/com/hackathonteam1/refreshrator/repository/RecipeRepository.java index e2d3313..5076b83 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/repository/RecipeRepository.java +++ b/src/main/java/com/hackathonteam1/refreshrator/repository/RecipeRepository.java @@ -2,13 +2,13 @@ import com.hackathonteam1.refreshrator.entity.Ingredient; import com.hackathonteam1.refreshrator.entity.Recipe; +import com.hackathonteam1.refreshrator.entity.User; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import java.util.List; import java.util.Set; import java.util.UUID; @@ -18,4 +18,5 @@ public interface RecipeRepository extends JpaRepository { @Query("SELECT r FROM recipe r JOIN r.ingredientRecipes ir JOIN ir.ingredient i WHERE i IN :ingredients GROUP BY r.id HAVING COUNT(i) >= :match OR COUNT(i) = SIZE(r.ingredientRecipes)") Page findAllByIngredientRecipesContain(@Param("ingredients") Set ingredients, @Param("match") int match, Pageable pageable); Page findAll(Pageable pageable); + Page findAllByUser(User user, Pageable pageable); } From 9d23eecaff476419df4811d5af37ae6e942effee Mon Sep 17 00:00:00 2001 From: jher235 Date: Sat, 27 Jul 2024 10:49:25 +0900 Subject: [PATCH 196/212] =?UTF-8?q?feat:=20=EC=9E=90=EC=8B=A0=EC=9D=B4=20?= =?UTF-8?q?=EB=A7=8C=EB=93=A0=20=EB=A0=88=EC=8B=9C=ED=94=BC=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=EB=A5=BC=20=EC=9C=84=ED=95=9C=20=EB=B9=84=EC=A6=88?= =?UTF-8?q?=EB=8B=88=EC=8A=A4=20=EB=A1=9C=EC=A7=81=20=EC=9E=91=EC=84=B1=20?= =?UTF-8?q?-=20#88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/service/RecipeService.java | 2 ++ .../service/RecipeServiceImpl.java | 21 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java index dc5c9b9..2be73b3 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeService.java @@ -53,5 +53,7 @@ public interface RecipeService { //파일(이미지) 삭제 public void deleteImage(UUID imageId, User user); +// 자신이 작성한 레시피 조회 + public RecipeListDto findMyRecipes(User user, String type, int page, int size); } diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java index 37fcdd3..9299a9d 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/RecipeServiceImpl.java @@ -248,7 +248,26 @@ public void deleteImage(UUID imageId, User user) { s3Uploader.removeS3File(image.getUrl().split("/")[3]); imageRepository.delete(image); } - + + @Override + public RecipeListDto findMyRecipes(User user, String type, int page, int size) { + + Sort sort; + if (type.equals("popularity")){ + sort = Sort.by(Sort.Order.desc("likeCount")); + }else{ + sort = Sort.by(Sort.Order.desc("createdAt")); + } + + Pageable pageable = PageRequest.of(page,size, sort); + Page recipePage = recipeRepository.findAllByUser(user, pageable); + checkValidPage(recipePage, page); + + RecipeListDto recipeListDto = RecipeListDto.mapping(recipePage); + + return recipeListDto; + } + private Fridge findFridgeByUser(User user){ return fridgeRepository.findByUser(user).orElseThrow(()-> new NotFoundException(ErrorCode.FRIDGE_NOT_FOUND)); } From c5f779aefd15ed9a062f9eaeaf32023c49d33b82 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sat, 27 Jul 2024 10:50:13 +0900 Subject: [PATCH 197/212] =?UTF-8?q?feat:=20=EC=9D=B8=ED=84=B0=EC=85=89?= =?UTF-8?q?=ED=84=B0=20=EA=B2=BD=EB=A1=9C=20=EC=B6=94=EA=B0=80=20-=20#88?= =?UTF-8?q?=20/users/me/**=EC=9D=98=20=EA=B2=BD=EB=A1=9C=EB=A5=BC=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20-?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/config/AuthenticationConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/config/AuthenticationConfig.java b/src/main/java/com/hackathonteam1/refreshrator/config/AuthenticationConfig.java index 275d652..224f50e 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/config/AuthenticationConfig.java +++ b/src/main/java/com/hackathonteam1/refreshrator/config/AuthenticationConfig.java @@ -21,7 +21,7 @@ public class AuthenticationConfig implements WebMvcConfigurer { @Override public void addInterceptors(final InterceptorRegistry registry) { registry.addInterceptor(authenticationInterceptor) - .addPathPatterns("/fridge/**","/recipes/**","/auth/leave","/auth/logout", "/auth/likes") + .addPathPatterns("/fridge/**","/recipes/**","/auth/leave","/auth/logout", "/auth/likes", "/users/me/**") .excludePathPatterns("/auth/signin", "/auth/login"); } From 1543aa3676e5f1ec4841046dd44b165c10668fb4 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sat, 27 Jul 2024 12:25:29 +0900 Subject: [PATCH 198/212] =?UTF-8?q?feat:=20=EC=83=81=EC=88=98=EA=B0=92?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20URI=20=EB=B3=B4=EA=B8=B0=20=ED=8E=B8?= =?UTF-8?q?=ED=95=98=EA=B2=8C=20=EB=B3=80=EA=B2=BD=20-=20#90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/config/AuthenticationConfig.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/config/AuthenticationConfig.java b/src/main/java/com/hackathonteam1/refreshrator/config/AuthenticationConfig.java index 224f50e..8698da6 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/config/AuthenticationConfig.java +++ b/src/main/java/com/hackathonteam1/refreshrator/config/AuthenticationConfig.java @@ -17,12 +17,16 @@ public class AuthenticationConfig implements WebMvcConfigurer { private final AuthenticationInterceptor authenticationInterceptor; private final AuthenticatedUserArgumentResolver authenticatedUserArgumentResolver; + private static final String[] ADD_PATH_PATTERNS = {"/fridge/**","/recipes/**","/auth/leave","/auth/logout", "/auth/likes", "/users/me/**"}; + private static final String[] EXCLUDE_PATH_PATTERNS = {"/auth/signin", "/auth/login"}; + //인터셉터 등록 + 경로 설정 @Override public void addInterceptors(final InterceptorRegistry registry) { registry.addInterceptor(authenticationInterceptor) - .addPathPatterns("/fridge/**","/recipes/**","/auth/leave","/auth/logout", "/auth/likes", "/users/me/**") - .excludePathPatterns("/auth/signin", "/auth/login"); + .addPathPatterns(ADD_PATH_PATTERNS) + .excludePathPatterns(EXCLUDE_PATH_PATTERNS); + } //컨트롤러 메서드 파라미터에 인증된 유저가 들어가도록 함 From 10975a8a36e3ddcf6e5cedb2d754d9b9ff438bc0 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sat, 27 Jul 2024 12:26:19 +0900 Subject: [PATCH 199/212] =?UTF-8?q?feat:=20=EB=A0=88=EC=8B=9C=ED=94=BC=20?= =?UTF-8?q?=EB=AA=A9=EB=A1=9D=EC=A1=B0=ED=9A=8C,=20=EC=83=81=EC=84=B8?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=EB=A5=BC=20=EC=9C=A0=EC=A0=80=20=EC=9D=B8?= =?UTF-8?q?=EA=B0=80=EC=97=90=EC=84=9C=20=EC=A0=9C=EC=99=B8=20-=20#90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/authentication/AuthenticationInterceptor.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticationInterceptor.java b/src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticationInterceptor.java index 7bba7ae..b98d908 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticationInterceptor.java +++ b/src/main/java/com/hackathonteam1/refreshrator/authentication/AuthenticationInterceptor.java @@ -30,6 +30,9 @@ public boolean preHandle(final HttpServletRequest request, if(request.getMethod().equals("OPTIONS")){ return true; } + if(request.getMethod().equals("GET") && (request.getRequestURI().equals("/recipes") || request.getRequestURI().matches("^/recipes/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"))){ + return true; + } String accessToken = AuthenticationExtractor.extract(request); UUID userId = UUID.fromString(jwtTokenProvider.getPayload(accessToken)); User user = findExistingUser(userId); From 9a6e0d8bd2f50c1898c11349c5cd79ae301fd1a9 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sat, 27 Jul 2024 12:27:21 +0900 Subject: [PATCH 200/212] =?UTF-8?q?feat:=20Dto=EC=97=90=20=ED=91=9C?= =?UTF-8?q?=ED=98=84=EB=90=98=EB=8A=94=20=EB=82=B4=EC=9A=A9=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20-=20#90=20=EC=83=9D=EC=84=B1=20=EC=8B=9C=EA=B0=84,?= =?UTF-8?q?=20=EC=88=98=EC=A0=95=20=EC=8B=9C=EA=B0=84=EC=9D=84=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=ED=95=98=EA=B3=A0=20detail=EC=97=90=EB=8A=94=20?= =?UTF-8?q?=EB=88=84=EB=9D=BD=EB=90=98=EC=97=88=EB=8D=98=20=EC=A2=8B?= =?UTF-8?q?=EC=95=84=EC=9A=94=20=EC=88=98=EB=8F=84=20=EB=82=98=ED=83=80?= =?UTF-8?q?=EB=82=98=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/dto/response/recipe/DetailRecipeDto.java | 7 ++++++- .../refreshrator/dto/response/recipe/RecipeDto.java | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/DetailRecipeDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/DetailRecipeDto.java index 677904f..c9119c9 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/DetailRecipeDto.java +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/DetailRecipeDto.java @@ -8,6 +8,7 @@ import lombok.Builder; import lombok.Getter; +import java.time.LocalDateTime; import java.util.List; import java.util.UUID; import java.util.stream.Collectors; @@ -20,12 +21,16 @@ public class DetailRecipeDto { private String name; private List ingredientRecipes; private String cookingStep; + private int likeCount; private ImageDto image; + private LocalDateTime createdAt; + private LocalDateTime updatedAt; public static DetailRecipeDto mapping(Recipe recipe, List ingredientRecipes){ List ingredientDtos = ingredientRecipes.stream().map( i->IngredientRecipeResponseDto.changeToDto(i)).collect(Collectors.toList()); return new DetailRecipeDto(recipe.getId(), recipe.getName(), ingredientDtos, - recipe.getCookingStep(),ImageDto.mapping(recipe.getImage())); + recipe.getCookingStep(), recipe.getLikeCount(), ImageDto.mapping(recipe.getImage()), + recipe.getCreatedAt(), recipe.getUpdatedAt()); } } diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/RecipeDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/RecipeDto.java index 5fabf14..754f39e 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/RecipeDto.java +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/response/recipe/RecipeDto.java @@ -5,6 +5,7 @@ import lombok.AllArgsConstructor; import lombok.Getter; +import java.time.LocalDateTime; import java.util.UUID; @Getter @@ -15,7 +16,10 @@ public class RecipeDto { private String name; private int likeCount; private ImageDto image; + private LocalDateTime createdAt; + private LocalDateTime updatedAt; public static RecipeDto mapping(Recipe recipe){ - return new RecipeDto(recipe.getId(), recipe.getName(), recipe.getLikeCount(),ImageDto.mapping(recipe.getImage())); + return new RecipeDto(recipe.getId(), recipe.getName(), recipe.getLikeCount(), + ImageDto.mapping(recipe.getImage()), recipe.getCreatedAt(), recipe.getUpdatedAt()); } } From 5607d7bd43980322d4ebd3a18150b7dcaf070bee Mon Sep 17 00:00:00 2001 From: jihyeonEom Date: Sat, 27 Jul 2024 19:44:08 +0900 Subject: [PATCH 201/212] =?UTF-8?q?refactor:=20fridgeTimeDto=EC=97=90=20?= =?UTF-8?q?=EC=9C=A0=ED=86=B5=EA=B8=B0=ED=95=9C=20=EC=B6=94=EA=B0=80=20-?= =?UTF-8?q?=20#93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/dto/response/fridge/FridgeItemDto.java | 2 ++ .../com/hackathonteam1/refreshrator/service/FridgeService.java | 1 + 2 files changed, 3 insertions(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/response/fridge/FridgeItemDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/response/fridge/FridgeItemDto.java index 43bf3b4..1311655 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/dto/response/fridge/FridgeItemDto.java +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/response/fridge/FridgeItemDto.java @@ -3,6 +3,7 @@ import lombok.Builder; import lombok.Getter; +import java.time.LocalDate; import java.util.UUID; @Builder @@ -11,4 +12,5 @@ public class FridgeItemDto { private UUID id; private String ingredientName; private UUID ingredientId; + private LocalDate expirationDate; } diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java b/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java index 9161797..4492264 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/FridgeService.java @@ -101,6 +101,7 @@ public FridgeItemListDto getIngredientsInFridge(User user) { .id(fridgeItem.getId()) .ingredientId(fridgeItem.getIngredient().getId()) .ingredientName(fridgeItem.getIngredient().getName()) + .expirationDate(fridgeItem.getExpiredDate()) .build(); if(LocalDate.now().isAfter(fridgeItem.getExpiredDate())){ From 0b09c71eba4478c542206a627682f67a5d3e16df Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 28 Jul 2024 03:21:15 +0900 Subject: [PATCH 202/212] =?UTF-8?q?feat:=20redis=EB=A5=BC=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=ED=95=98=EA=B8=B0=20=EC=9C=84=ED=95=9C=20=EC=9D=98?= =?UTF-8?q?=EC=A1=B4=EC=84=B1=20=EC=B6=94=EA=B0=80=20-=20#92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.gradle b/build.gradle index 95fa937..cbbca56 100644 --- a/build.gradle +++ b/build.gradle @@ -40,6 +40,8 @@ dependencies { implementation 'javax.xml.bind:jaxb-api:2.3.1'//JAXB implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'//AWS + + implementation 'org.springframework.boot:spring-boot-starter-data-redis'//Redis } tasks.named('test') { From 42e15a8d30df0ded934177ef93c02b44be8bceaf Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 28 Jul 2024 03:21:38 +0900 Subject: [PATCH 203/212] =?UTF-8?q?feat:=20redis=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=EC=8B=9C=20=EC=98=A4=EB=A5=98=EC=B6=94=EA=B0=80,=20=EC=98=88?= =?UTF-8?q?=EC=99=B8=EC=B2=98=EB=A6=AC=20-=20#92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/exception/RedisException.java | 9 +++++++++ .../refreshrator/exception/errorcode/ErrorCode.java | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/exception/RedisException.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/exception/RedisException.java b/src/main/java/com/hackathonteam1/refreshrator/exception/RedisException.java new file mode 100644 index 0000000..a162510 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/exception/RedisException.java @@ -0,0 +1,9 @@ +package com.hackathonteam1.refreshrator.exception; + +import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; + +public class RedisException extends CustomException{ + public RedisException(ErrorCode errorCode, String detail) { + super(errorCode, detail); + } +} \ No newline at end of file diff --git a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java index 33d0883..f70300d 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java +++ b/src/main/java/com/hackathonteam1/refreshrator/exception/errorcode/ErrorCode.java @@ -47,7 +47,8 @@ public enum ErrorCode { RECIPE_IMAGE_CONFLICT("4093", "레시피에 이미지가 이미 존재합니다."), //InternetException - FILE_STORAGE_ERROR("5000", "파일을 업로드할 수 없습니다."); + FILE_STORAGE_ERROR("5000", "파일을 업로드할 수 없습니다."), + REDIS_ERROR("5001", "Redis에서 오류가 발생했습니다."); private final String code; private final String message; From 8c72af00140a8216bc067be9447ddbc664296eb9 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 28 Jul 2024 03:22:34 +0900 Subject: [PATCH 204/212] =?UTF-8?q?feat:=20redis=20config=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20-=20#92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/config/RedisConfig.java | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/config/RedisConfig.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/config/RedisConfig.java b/src/main/java/com/hackathonteam1/refreshrator/config/RedisConfig.java new file mode 100644 index 0000000..4aced21 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/config/RedisConfig.java @@ -0,0 +1,42 @@ +package com.hackathonteam1.refreshrator.config; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.connection.RedisConnection; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; +import org.springframework.data.redis.core.RedisKeyValueAdapter; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.repository.configuration.EnableRedisRepositories; +import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; +import org.springframework.data.redis.serializer.StringRedisSerializer; + +@Configuration +public class RedisConfig { + + private final String redisHost; + private final int redisPort; + + public RedisConfig(@Value("${spring.data.redis.host}") String redisHost, + @Value("${spring.data.redis.port}")int redisPort){ + this.redisHost = redisHost; + this.redisPort = redisPort; + } + + @Bean + public RedisConnectionFactory redisConnectionFactory(){ + return new LettuceConnectionFactory(redisHost, redisPort); + } + + @Bean + public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory){ + RedisTemplate redisTemplate = new RedisTemplate<>(); + redisTemplate.setConnectionFactory(redisConnectionFactory); + redisTemplate.setKeySerializer(new StringRedisSerializer()); //key를 string으로 시리얼라이즈 + redisTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer()); //value를 json으로 시리얼라이즈 + redisTemplate.setHashKeySerializer(new StringRedisSerializer()); //Hash의 key를 String으로 시리얼라이즈 + redisTemplate.setHashValueSerializer(new GenericJackson2JsonRedisSerializer()); //Hash의 value를 json으로 시리얼라이즈 + return redisTemplate; + } +} From 99ea8302091aff8b743c8e25be66407c499f2292 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 28 Jul 2024 03:22:50 +0900 Subject: [PATCH 205/212] =?UTF-8?q?feat:=20redis=20util=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20-=20#92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/util/RedisUtil.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/util/RedisUtil.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/util/RedisUtil.java b/src/main/java/com/hackathonteam1/refreshrator/util/RedisUtil.java new file mode 100644 index 0000000..8ca3e23 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/util/RedisUtil.java @@ -0,0 +1,40 @@ +package com.hackathonteam1.refreshrator.util; + + +import com.hackathonteam1.refreshrator.exception.RedisException; +import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; + +import java.util.Optional; +import java.util.concurrent.TimeUnit; + +@Service +@AllArgsConstructor +@Slf4j +public class RedisUtil { + private final RedisTemplate redisTemplate; + + public void save(K key, V value, long timeout, TimeUnit timeUnit) { + try { + redisTemplate.opsForValue().set(key, value, timeout, timeUnit); + } catch (Exception e) { + throw new RedisException( ErrorCode.REDIS_ERROR, e.getMessage()); + } + } + + public void delete(K key) { + try { + redisTemplate.delete(key); + }catch (Exception e){ + throw new RedisException( ErrorCode.REDIS_ERROR, e.getMessage()); + } + } + + public Optional findById(K key){ + V result = redisTemplate.opsForValue().get(key); + return Optional.ofNullable(result); + } +} From 4edb4fb23833c2891ea19da28866206f623a229f Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 28 Jul 2024 03:23:22 +0900 Subject: [PATCH 206/212] =?UTF-8?q?feat:=20refreshToken=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20-=20#92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/entity/RefreshToken.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/main/java/com/hackathonteam1/refreshrator/entity/RefreshToken.java diff --git a/src/main/java/com/hackathonteam1/refreshrator/entity/RefreshToken.java b/src/main/java/com/hackathonteam1/refreshrator/entity/RefreshToken.java new file mode 100644 index 0000000..6976a40 --- /dev/null +++ b/src/main/java/com/hackathonteam1/refreshrator/entity/RefreshToken.java @@ -0,0 +1,22 @@ +package com.hackathonteam1.refreshrator.entity; + + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.springframework.data.annotation.Id; +import org.springframework.data.redis.core.index.Indexed; + +import java.util.UUID; + +@Getter +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class RefreshToken { + @Id + private UUID tokenId; + @Indexed + private UUID userId; +} \ No newline at end of file From ac1d9e96e5a13d9b6b066abe0391b67721338fb9 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 28 Jul 2024 03:23:47 +0900 Subject: [PATCH 207/212] =?UTF-8?q?feat:=20refreshToken=EC=9D=84=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=ED=95=98=EA=B8=B0=20=EC=9C=84=ED=95=9C=20Con?= =?UTF-8?q?troller=20=EC=9E=91=EC=84=B1=20-=20#92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/AuthController.java | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java b/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java index bf17b48..17733a5 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java +++ b/src/main/java/com/hackathonteam1/refreshrator/controller/AuthController.java @@ -10,6 +10,7 @@ import com.hackathonteam1.refreshrator.dto.response.recipe.RecipeListDto; import com.hackathonteam1.refreshrator.entity.User; import com.hackathonteam1.refreshrator.service.AuthService; +import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.Valid; import lombok.AllArgsConstructor; @@ -49,6 +50,15 @@ public ResponseEntity> leave(@AuthenticatedUser User user,Http .build(); response.addHeader("set-cookie", cookie.toString()); + ResponseCookie cookie_refresh = ResponseCookie.from("RefreshToken",null) + .maxAge(0) + .path("/auth/refresh") + .httpOnly(true) + .sameSite("None") + .secure(true) + .build(); + response.addHeader("set-cookie", cookie_refresh.toString()); + return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "회원 탈퇴 완료"), HttpStatus.OK); } @@ -67,6 +77,16 @@ public ResponseEntity> login(@RequestBody @Valid LoginDto logi .build(); response.addHeader("set-cookie", cookie.toString()); + ResponseCookie cookie_refresh = ResponseCookie.from("RefreshToken",tokenResponseDto.getRefreshToken().getTokenId().toString()) + .maxAge(Duration.ofDays(14)) + .path("/auth/refresh") + .httpOnly(true) + .sameSite("None") + .secure(true) + .build(); + + response.addHeader("set-cookie", cookie_refresh.toString()); + return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "로그인 완료"), HttpStatus.OK); } @@ -81,6 +101,15 @@ public ResponseEntity> logout(@AuthenticatedUser User user, fi .build(); response.addHeader("set-cookie", cookie.toString()); + ResponseCookie cookie_refresh = ResponseCookie.from("RefreshToken",null) + .maxAge(0) + .path("/auth/refresh") + .httpOnly(true) + .sameSite("None") + .secure(true) + .build(); + response.addHeader("set-cookie", cookie_refresh.toString()); + return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "로그아웃 완료"), HttpStatus.OK); } @@ -92,4 +121,29 @@ public ResponseEntity> showAllRecipeLikes(@Authentica RecipeListDto recipeListDto = authService.showAllRecipeLikes(user, page, size); return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "좋아요 누른 레시피 목록 조회 성공", recipeListDto), HttpStatus.OK); } + + @GetMapping("/refresh") + public ResponseEntity> refresh(HttpServletRequest request, HttpServletResponse response){ + TokenResponseDto tokenResponseDto = authService.refresh(request); + String bearerToken = JwtEncoder.encodeJwtToken(tokenResponseDto.getAccessToken()); + + ResponseCookie cookie_access = ResponseCookie.from(AuthenticationExtractor.TOKEN_COOKIE_NAME, bearerToken) + .maxAge(Duration.ofMillis(1800000)) + .path("/") + .httpOnly(true) + .sameSite("None").secure(true) + .build(); + + ResponseCookie cookie_refresh = ResponseCookie.from("RefreshToken", tokenResponseDto.getRefreshToken().getTokenId().toString()) + .maxAge(Duration.ofDays(14)) + .path("/auth/refresh") + .httpOnly(true) + .sameSite("None") + .secure(true) + .build(); + + response.addHeader("set-cookie", cookie_access.toString()); + response.addHeader("set-cookie", cookie_refresh.toString()); + return new ResponseEntity<>(ResponseDto.res(HttpStatus.OK, "토큰 재발급 성공"), HttpStatus.OK); + } } From 20c8120b757f75deff0c6fd58bf39fba00a0738a Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 28 Jul 2024 03:24:21 +0900 Subject: [PATCH 208/212] =?UTF-8?q?feat:=20=EC=9D=B8=EC=A6=9D=EC=9D=B4=20?= =?UTF-8?q?=ED=95=84=EC=9A=94=ED=95=98=EC=A7=80=20=EC=95=8A=EC=9D=80=20pat?= =?UTF-8?q?h=20=EC=B6=94=EA=B0=80.=20-=20#92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/config/AuthenticationConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/config/AuthenticationConfig.java b/src/main/java/com/hackathonteam1/refreshrator/config/AuthenticationConfig.java index 8698da6..4e988c5 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/config/AuthenticationConfig.java +++ b/src/main/java/com/hackathonteam1/refreshrator/config/AuthenticationConfig.java @@ -18,7 +18,7 @@ public class AuthenticationConfig implements WebMvcConfigurer { private final AuthenticatedUserArgumentResolver authenticatedUserArgumentResolver; private static final String[] ADD_PATH_PATTERNS = {"/fridge/**","/recipes/**","/auth/leave","/auth/logout", "/auth/likes", "/users/me/**"}; - private static final String[] EXCLUDE_PATH_PATTERNS = {"/auth/signin", "/auth/login"}; + private static final String[] EXCLUDE_PATH_PATTERNS = {"/auth/signin", "/auth/login", "/auth/refresh"}; //인터셉터 등록 + 경로 설정 @Override From ed18ad611aeaebdd6eaf21dfafd9e5c14763c6fb Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 28 Jul 2024 03:24:40 +0900 Subject: [PATCH 209/212] =?UTF-8?q?feat:=20refreshToken=EC=9D=84=20?= =?UTF-8?q?=EC=9C=84=ED=95=9C=20=EB=B9=84=EC=A6=88=EB=8B=88=EC=8A=A4=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=9E=91=EC=84=B1=20-=20#92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/service/AuthService.java | 80 +++++++++++++++++-- 1 file changed, 73 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java b/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java index 602123b..567ec3b 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java @@ -1,5 +1,6 @@ package com.hackathonteam1.refreshrator.service; +import com.hackathonteam1.refreshrator.authentication.JwtEncoder; import com.hackathonteam1.refreshrator.authentication.JwtTokenProvider; import com.hackathonteam1.refreshrator.authentication.PasswordHashEncryption; import com.hackathonteam1.refreshrator.dto.request.auth.LoginDto; @@ -7,27 +8,31 @@ import com.hackathonteam1.refreshrator.dto.response.auth.TokenResponseDto; import com.hackathonteam1.refreshrator.dto.response.recipe.RecipeDto; import com.hackathonteam1.refreshrator.dto.response.recipe.RecipeListDto; -import com.hackathonteam1.refreshrator.entity.Fridge; -import com.hackathonteam1.refreshrator.entity.Recipe; -import com.hackathonteam1.refreshrator.entity.RecipeLike; -import com.hackathonteam1.refreshrator.entity.User; +import com.hackathonteam1.refreshrator.entity.*; import com.hackathonteam1.refreshrator.exception.ConflictException; import com.hackathonteam1.refreshrator.exception.ForbiddenException; import com.hackathonteam1.refreshrator.exception.NotFoundException; +import com.hackathonteam1.refreshrator.exception.UnauthorizedException; import com.hackathonteam1.refreshrator.exception.errorcode.ErrorCode; import com.hackathonteam1.refreshrator.repository.FridgeRepository; import com.hackathonteam1.refreshrator.repository.RecipeLikeRepository; import com.hackathonteam1.refreshrator.repository.UserRepository; +import com.hackathonteam1.refreshrator.util.RedisUtil; +import jakarta.servlet.http.Cookie; +import jakarta.servlet.http.HttpServletRequest; import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.data.domain.*; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; -import java.util.ArrayList; -import java.util.List; +import java.util.*; +import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @Service @AllArgsConstructor +@Slf4j public class AuthService { private final UserRepository userRepository; private final FridgeRepository fridgeRepository; @@ -35,6 +40,13 @@ public class AuthService { private final JwtTokenProvider jwtTokenProvider; private final RecipeLikeRepository recipeLikeRepository; + private final RedisUtil redisUtilForRefreshToken; + private final RedisUtil redisUtilForUserId; + + private final static int TIMEOUT = 14; + private final static TimeUnit TIME_UNIT = TimeUnit.DAYS; + + //회원가입 public void signin(SigninDto signinDto){ @@ -88,7 +100,23 @@ public TokenResponseDto login(LoginDto loginDto){ String payload = String.valueOf(user.getId()); String accessToken = jwtTokenProvider.createToken(payload); - return new TokenResponseDto(accessToken); + //기존에 refreshToken이 있었는지 확인 후 삭제 + Optional refreshTokenId = redisUtilForUserId.findById(user.getId().toString()); + if(refreshTokenId.isPresent()){ + redisUtilForRefreshToken.delete(refreshTokenId.get()); + redisUtilForUserId.delete(user.getId().toString()); + } + + UUID newRefreshTokenId = UUID.randomUUID(); + RefreshToken refreshToken = RefreshToken.builder() + .tokenId(newRefreshTokenId) + .userId(user.getId()) + .build(); + + redisUtilForRefreshToken.save(newRefreshTokenId.toString(), refreshToken, TIMEOUT, TIME_UNIT); + redisUtilForUserId.save(user.getId().toString(), newRefreshTokenId.toString(),TIMEOUT,TIME_UNIT); + + return new TokenResponseDto(accessToken, refreshToken); } // 좋아요 누른 레시피 목록 조회 @@ -109,6 +137,44 @@ public RecipeListDto showAllRecipeLikes(User user, int page, int size) { return recipeListDto; } + @Transactional + public TokenResponseDto refresh(HttpServletRequest request){ + + Cookie[] cookies = request.getCookies(); + + if (cookies != null) { + for (Cookie cookie : cookies) { + if (cookie.getName().equals("RefreshToken")) { + RefreshToken refreshToken = findRefreshTokenByRefreshTokenId(UUID.fromString(cookie.getValue())); + UUID userId = refreshToken.getUserId(); + String accessToken = jwtTokenProvider.createToken(userId.toString()); + + //refreshToken Rotation을 위해 매번 재발급. + redisUtilForRefreshToken.delete(refreshToken.getTokenId().toString()); + redisUtilForUserId.delete(userId.toString()); + + UUID newRefreshTokenId = UUID.randomUUID(); + + RefreshToken newRefreshToken = RefreshToken.builder() + .tokenId(newRefreshTokenId) + .userId(userId) + .build(); + + redisUtilForRefreshToken.save(newRefreshTokenId.toString(), newRefreshToken, TIMEOUT, TIME_UNIT); + redisUtilForUserId.save(userId.toString(), newRefreshTokenId.toString(),TIMEOUT,TIME_UNIT); + + return new TokenResponseDto(accessToken, newRefreshToken); + } + } + } + throw new UnauthorizedException(ErrorCode.COOKIE_NOT_FOUND, "RefreshToken이 존재하지 않습니다."); + } + + private RefreshToken findRefreshTokenByRefreshTokenId(UUID tokenId){ + return redisUtilForRefreshToken.findById(tokenId.toString()).orElseThrow( () -> + new UnauthorizedException(ErrorCode.INVALID_TOKEN)); + } + private void checkValidPage(Page pages, int page){ if(pages.getTotalPages() <= page && page != 0){ throw new NotFoundException(ErrorCode.PAGE_NOT_FOUND); From 51c1ce40130708f63b15894213b71527d57076d7 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 28 Jul 2024 03:25:07 +0900 Subject: [PATCH 210/212] =?UTF-8?q?feat:=20TokenResponseDto=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20-=20#92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../refreshrator/dto/response/auth/TokenResponseDto.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/hackathonteam1/refreshrator/dto/response/auth/TokenResponseDto.java b/src/main/java/com/hackathonteam1/refreshrator/dto/response/auth/TokenResponseDto.java index e7a38c6..172dd2e 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/dto/response/auth/TokenResponseDto.java +++ b/src/main/java/com/hackathonteam1/refreshrator/dto/response/auth/TokenResponseDto.java @@ -1,10 +1,14 @@ package com.hackathonteam1.refreshrator.dto.response.auth; +import com.hackathonteam1.refreshrator.entity.RefreshToken; import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.NoArgsConstructor; @Getter @AllArgsConstructor +@NoArgsConstructor public class TokenResponseDto { private String AccessToken; + private RefreshToken refreshToken; } From 25b878694da0cbc03b8c9c897935e2fcafb30ed5 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 28 Jul 2024 03:27:21 +0900 Subject: [PATCH 211/212] =?UTF-8?q?feat:=20ci/cd=EC=97=90=EC=84=9C=20EC2?= =?UTF-8?q?=EC=97=90=EC=84=9C=20docker=EB=A1=9C=20redis=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/gradle.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index f62ccbd..d5a2c42 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -63,5 +63,6 @@ jobs: # 실행할 작업들에 대한 설정 sudo docker pull ${{secrets.DOCKERHUB_USERNAME}}/${{secrets.DOCKERHUB_IMAGE}} sudo docker ps -q | xargs -r sudo docker stop sudo docker ps -aq | xargs -r sudo docker rm + sudo docker run --name redis --rm -d -p 6379:6379 redis sudo docker run --name ${{secrets.DOCKERHUB_IMAGE}} --rm -d -p 8080:8080 ${{secrets.DOCKERHUB_USERNAME}}/${{secrets.DOCKERHUB_IMAGE}} sudo docker system prune -f \ No newline at end of file From 52d1097409c5c620f69a88842b002abc001763c1 Mon Sep 17 00:00:00 2001 From: jher235 Date: Sun, 28 Jul 2024 12:23:07 +0900 Subject: [PATCH 212/212] =?UTF-8?q?feat:=20=EC=98=88=EC=99=B8=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=20=EC=8B=9C=20detail=20=EC=B6=94=EA=B0=80=20-=20#92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hackathonteam1/refreshrator/service/AuthService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java b/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java index 567ec3b..de2e9a3 100644 --- a/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java +++ b/src/main/java/com/hackathonteam1/refreshrator/service/AuthService.java @@ -172,7 +172,7 @@ public TokenResponseDto refresh(HttpServletRequest request){ private RefreshToken findRefreshTokenByRefreshTokenId(UUID tokenId){ return redisUtilForRefreshToken.findById(tokenId.toString()).orElseThrow( () -> - new UnauthorizedException(ErrorCode.INVALID_TOKEN)); + new UnauthorizedException(ErrorCode.INVALID_TOKEN, "유효하지 않은 RefreshToken입니다.")); } private void checkValidPage(Page pages, int page){