diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..c79ce29 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,10 @@ +# 디폴트 무시된 파일 +/shelf/ +/workspace.xml +# 에디터 기반 HTTP 클라이언트 요청 +/httpRequests/ +# 환경에 따라 달라지는 Maven 홈 디렉터리 +/mavenHomeManager.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/10th_SpringBoot_B.iml b/.idea/10th_SpringBoot_B.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/10th_SpringBoot_B.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..3fe0d38 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..4635b22 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,16 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..c40b155 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..0bdfc3c --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/umc10th_wony.main.iml b/.idea/modules/umc10th_wony.main.iml new file mode 100644 index 0000000..8ecf595 --- /dev/null +++ b/.idea/modules/umc10th_wony.main.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/umc10th_wony/.gitattributes b/umc10th_wony/.gitattributes new file mode 100644 index 0000000..8af972c --- /dev/null +++ b/umc10th_wony/.gitattributes @@ -0,0 +1,3 @@ +/gradlew text eol=lf +*.bat text eol=crlf +*.jar binary diff --git a/umc10th_wony/.gitignore b/umc10th_wony/.gitignore new file mode 100644 index 0000000..c2065bc --- /dev/null +++ b/umc10th_wony/.gitignore @@ -0,0 +1,37 @@ +HELP.md +.gradle +build/ +!gradle/wrapper/gradle-wrapper.jar +!**/src/main/**/build/ +!**/src/test/**/build/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ diff --git a/umc10th_wony/build.gradle b/umc10th_wony/build.gradle new file mode 100644 index 0000000..20b3a39 --- /dev/null +++ b/umc10th_wony/build.gradle @@ -0,0 +1,41 @@ +plugins { + id 'java' + id 'org.springframework.boot' version '4.0.5' + id 'io.spring.dependency-management' version '1.1.7' +} + +group = 'com.example' +version = '0.0.1-SNAPSHOT' +description = 'umc10th_wony' + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(21) + } +} + +repositories { + mavenCentral() +} + +dependencies { + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' + implementation 'org.springframework.boot:spring-boot-starter-webmvc' + implementation 'org.springframework.boot:spring-boot-starter-security' + compileOnly 'org.projectlombok:lombok' + runtimeOnly 'com.mysql:mysql-connector-j' + annotationProcessor 'org.projectlombok:lombok' + testImplementation 'org.springframework.boot:spring-boot-starter-data-jpa-test' + testImplementation 'org.springframework.boot:spring-boot-starter-webmvc-test' + testCompileOnly 'org.projectlombok:lombok' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' + testAnnotationProcessor 'org.projectlombok:lombok' + + // Swagger + implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:3.0.1' + implementation 'org.springdoc:springdoc-openapi-starter-webmvc-api:3.0.1' +} + +tasks.named('test') { + useJUnitPlatform() +} diff --git a/umc10th_wony/gradle/wrapper/gradle-wrapper.jar b/umc10th_wony/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..d997cfc Binary files /dev/null and b/umc10th_wony/gradle/wrapper/gradle-wrapper.jar differ diff --git a/umc10th_wony/gradle/wrapper/gradle-wrapper.properties b/umc10th_wony/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..c61a118 --- /dev/null +++ b/umc10th_wony/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/umc10th_wony/gradlew b/umc10th_wony/gradlew new file mode 100644 index 0000000..739907d --- /dev/null +++ b/umc10th_wony/gradlew @@ -0,0 +1,248 @@ +#!/bin/sh + +# +# Copyright © 2015 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/2d6327017519d23b96af35865dc997fcb544fb40/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + + + +# 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" ) + + 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, 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" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# 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/umc10th_wony/gradlew.bat b/umc10th_wony/gradlew.bat new file mode 100644 index 0000000..c4bdd3a --- /dev/null +++ b/umc10th_wony/gradlew.bat @@ -0,0 +1,93 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* + +: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/umc10th_wony/settings.gradle b/umc10th_wony/settings.gradle new file mode 100644 index 0000000..e926390 --- /dev/null +++ b/umc10th_wony/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'umc10th_wony' diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/Umc10thWonyApplication.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/Umc10thWonyApplication.java new file mode 100644 index 0000000..38bd4e9 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/Umc10thWonyApplication.java @@ -0,0 +1,13 @@ +package com.example.umc10th_wony; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Umc10thWonyApplication { + + public static void main(String[] args) { + SpringApplication.run(Umc10thWonyApplication.class, args); + } + +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/controller/MemberController.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/controller/MemberController.java new file mode 100644 index 0000000..8439cda --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/controller/MemberController.java @@ -0,0 +1,56 @@ +package com.example.umc10th_wony.domain.member.controller; + +import com.example.umc10th_wony.domain.member.dto.MemberSignupRequest; +import com.example.umc10th_wony.domain.member.dto.MemberInfoResponse; +import com.example.umc10th_wony.domain.member.dto.MemberSignupResponse; + +import com.example.umc10th_wony.global.apiPayload.ApiResponse; +import com.example.umc10th_wony.domain.member.exception.code.MemberSuccessCode; +import com.example.umc10th_wony.global.security.LoginMember; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +@Tag(name = "Member API", description = "회원 관련 API") +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/members") +public class MemberController { + // 1. 회원가입 + @Operation(summary = "회원가입", description = "이메일 + 비밀번호로 회원을 등록합니다.") + @PostMapping("/signup") + public ResponseEntity> signup( + @Valid @RequestBody MemberSignupRequest request + ) { + // TODO: memberService.signup(request) + MemberSignupResponse result = MemberSignupResponse.builder() + .memberId(1L) + .email(request.getEmail()) + .nickname(request.getNickname()) + .build(); + return ResponseEntity.status(201) + .body(ApiResponse.onSuccess(MemberSuccessCode.SIGNUP_SUCCESS, result)); + } + + // 2. 내 정보 조회 + @Operation(summary = "내 정보 조회", description = "JWT 토큰으로 인증된 현재 회원의 정보를 반환합니다.") + @GetMapping("/me") + public ResponseEntity> getMyInfo( + @Parameter(hidden = true) @LoginMember Long memberId + ) { + // TODO: memberService.getMyInfo(memberId) + MemberInfoResponse result = MemberInfoResponse.builder() + .memberId(memberId) + .email("example@email.com") + .nickname("닉네임") + .completedMissionCount(5) + .writtenReviewCount(3) + .build(); + return ResponseEntity.ok(ApiResponse.onSuccess(MemberSuccessCode.MEMBER_FOUND, result)); + } +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/controller/MissionController.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/controller/MissionController.java new file mode 100644 index 0000000..92db218 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/controller/MissionController.java @@ -0,0 +1,83 @@ +package com.example.umc10th_wony.domain.member.controller; + +import com.example.umc10th_wony.domain.mission.dto.MissionCompleteRequest; +import com.example.umc10th_wony.domain.mission.dto.ReviewCreateRequest; +import com.example.umc10th_wony.domain.mission.dto.MissionResponse; +import com.example.umc10th_wony.domain.mission.dto.MissionCompleteResponse; +import com.example.umc10th_wony.domain.mission.dto.ReviewResponse; + +import com.example.umc10th_wony.global.apiPayload.ApiResponse; +import com.example.umc10th_wony.domain.mission.exception.code.MissionSuccessCode; +import com.example.umc10th_wony.global.security.LoginMember; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@Tag(name = "Mission API", description = "미션 관련 API") +@RestController +@RequiredArgsConstructor +@RequestMapping("/api") +public class MissionController { + + // 1. 지역별 미션 목록 조회 + @Operation(summary = "지역별 미션 목록 조회", description = "특정 지역의 미션 목록을 조회합니다.") + @GetMapping("/missions") + public ResponseEntity>> getMissionsByRegion( + @Parameter(description = "지역명 (예: 공릉동)", required = true) @RequestParam String region + ) { + // TODO: missionService.getMissionsByRegion(region) + List result = List.of(MissionResponse.builder() + .missionId(1L).title("공릉동 미션 예시").description("미션 설명") + .region(region).reward(1000).status("OPEN").build()); + return ResponseEntity.ok(ApiResponse.onSuccess(MissionSuccessCode.MISSION_LIST_FOUND, result)); + } + + // 2. 내 미션 목록 조회 + @Operation(summary = "내 미션 목록 조회", description = "현재 로그인한 회원이 참여 중인 미션 목록을 반환합니다.") + @GetMapping("/missions/me") + public ResponseEntity>> getMyMissions( + @Parameter(hidden = true) @LoginMember Long memberId + ) { + // TODO: missionService.getMyMissions(memberId) + List result = List.of(MissionResponse.builder() + .missionId(2L).title("내 미션 예시").description("미션 설명") + .region("서울").reward(500).status("IN_PROGRESS").build()); + return ResponseEntity.ok(ApiResponse.onSuccess(MissionSuccessCode.MISSION_LIST_FOUND, result)); + } + + // 3. 미션 완료 처리 + @Operation(summary = "미션 완료 처리", description = "특정 미션을 완료 처리합니다. JWT에서 회원 ID를 추출합니다.") + @PatchMapping("/missions/{missionId}/complete") + public ResponseEntity> completeMission( + @Parameter(description = "완료할 미션 ID") @PathVariable Long missionId, + @Valid @RequestBody MissionCompleteRequest request, + @Parameter(hidden = true) @LoginMember Long memberId + ) { + // TODO: missionService.completeMission(missionId, memberId, request) + MissionCompleteResponse result = MissionCompleteResponse.builder() + .missionId(missionId).memberId(memberId).status("COMPLETED").rewardPoint(1000).build(); + return ResponseEntity.ok(ApiResponse.onSuccess(MissionSuccessCode.MISSION_COMPLETED, result)); + } + + // 4. 리뷰 작성 + @Operation(summary = "리뷰 작성", description = "완료된 미션에 대해 별점과 텍스트로 리뷰를 작성합니다.") + @PostMapping("/reviews") + public ResponseEntity> createReview( + @Valid @RequestBody ReviewCreateRequest request, + @Parameter(hidden = true) @LoginMember Long memberId + ) { + // TODO: reviewService.createReview(request, memberId) + ReviewResponse result = ReviewResponse.builder() + .reviewId(1L).missionId(request.getMissionId()).memberId(memberId) + .rating(request.getRating()).content(request.getContent()).build(); + return ResponseEntity.status(201) + .body(ApiResponse.onSuccess(MissionSuccessCode.REVIEW_CREATED, result)); + } +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/converter/MemberConverter.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/converter/MemberConverter.java new file mode 100644 index 0000000..113c250 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/converter/MemberConverter.java @@ -0,0 +1,4 @@ +package com.example.umc10th_wony.domain.member.converter; + +public class MemberConverter { +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/dto/MemberInfoResponse.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/dto/MemberInfoResponse.java new file mode 100644 index 0000000..2b21a63 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/dto/MemberInfoResponse.java @@ -0,0 +1,22 @@ +package com.example.umc10th_wony.domain.member.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +@Getter +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class MemberInfoResponse { + + private Long memberId; + private String email; + private String nickname; + private int completedMissionCount; // 완료한 미션 수 + private int writtenReviewCount; // 작성한 리뷰 수 + private LocalDateTime createdAt; +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/dto/MemberReqDTO.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/dto/MemberReqDTO.java new file mode 100644 index 0000000..d6b6dcb --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/dto/MemberReqDTO.java @@ -0,0 +1,5 @@ +package com.example.umc10th_wony.domain.member.dto; + +public class MemberReqDTO { + +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/dto/MemberResDTO.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/dto/MemberResDTO.java new file mode 100644 index 0000000..18b5a59 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/dto/MemberResDTO.java @@ -0,0 +1,4 @@ +package com.example.umc10th_wony.domain.member.dto; + +public class MemberResDTO { +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/dto/MemberSignupRequest.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/dto/MemberSignupRequest.java new file mode 100644 index 0000000..692ec8c --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/dto/MemberSignupRequest.java @@ -0,0 +1,29 @@ +package com.example.umc10th_wony.domain.member.dto; + +import jakarta.validation.constraints.Email; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.Pattern; +import jakarta.validation.constraints.Size; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +public class MemberSignupRequest { + + @NotBlank(message = "이메일은 필수입니다.") + @Email(message = "올바른 이메일 형식이 아닙니다.") + private String email; + + @NotBlank(message = "비밀번호는 필수입니다.") + @Size(min = 8, max = 20, message = "비밀번호는 8자 이상 20자 이하여야 합니다.") + @Pattern( + regexp = "^(?=.*[A-Za-z])(?=.*\\d)(?=.*[@$!%*#?&])[A-Za-z\\d@$!%*#?&]{8,}$", + message = "비밀번호는 영문, 숫자, 특수문자를 각각 1개 이상 포함해야 합니다." + ) + private String password; + + @NotBlank(message = "닉네임은 필수입니다.") + @Size(min = 2, max = 10, message = "닉네임은 2자 이상 10자 이하여야 합니다.") + private String nickname; +} \ No newline at end of file diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/dto/MemberSignupResponse.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/dto/MemberSignupResponse.java new file mode 100644 index 0000000..237e5a3 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/dto/MemberSignupResponse.java @@ -0,0 +1,17 @@ +package com.example.umc10th_wony.domain.member.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class MemberSignupResponse { + + private Long memberId; + private String email; + private String nickname; +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/entity/Food.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/entity/Food.java new file mode 100644 index 0000000..cd9d34f --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/entity/Food.java @@ -0,0 +1,4 @@ +package com.example.umc10th_wony.domain.member.entity; + +public class Food { +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/entity/Member.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/entity/Member.java new file mode 100644 index 0000000..fb23d44 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/entity/Member.java @@ -0,0 +1,4 @@ +package com.example.umc10th_wony.domain.member.entity; + +public class Member { +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/entity/Term.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/entity/Term.java new file mode 100644 index 0000000..dd022de --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/entity/Term.java @@ -0,0 +1,4 @@ +package com.example.umc10th_wony.domain.member.entity; + +public class Term { +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/entity/mapping/MemberFood.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/entity/mapping/MemberFood.java new file mode 100644 index 0000000..7c88a47 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/entity/mapping/MemberFood.java @@ -0,0 +1,4 @@ +package com.example.umc10th_wony.domain.member.entity.mapping; + +public class MemberFood { +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/entity/mapping/MemberTrem.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/entity/mapping/MemberTrem.java new file mode 100644 index 0000000..2b5221b --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/entity/mapping/MemberTrem.java @@ -0,0 +1,4 @@ +package com.example.umc10th_wony.domain.member.entity.mapping; + +public class MemberTrem { +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/enums/Gender.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/enums/Gender.java new file mode 100644 index 0000000..420d741 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/enums/Gender.java @@ -0,0 +1,4 @@ +package com.example.umc10th_wony.domain.member.enums; + +public enum Gender { +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/enums/SocialType.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/enums/SocialType.java new file mode 100644 index 0000000..9375157 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/enums/SocialType.java @@ -0,0 +1,4 @@ +package com.example.umc10th_wony.domain.member.enums; + +public enum SocialType { +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/enums/Term.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/enums/Term.java new file mode 100644 index 0000000..a26d950 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/enums/Term.java @@ -0,0 +1,4 @@ +package com.example.umc10th_wony.domain.member.enums; + +public enum Term { +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/exception/MemberException.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/exception/MemberException.java new file mode 100644 index 0000000..893b28d --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/exception/MemberException.java @@ -0,0 +1,11 @@ +package com.example.umc10th_wony.domain.member.exception; + +import com.example.umc10th_wony.global.apiPayload.exception.ProjectException; +import com.example.umc10th_wony.domain.member.exception.code.MemberErrorCode; + +public class MemberException extends ProjectException { + + public MemberException(MemberErrorCode errorCode) { + super(errorCode); + } +} \ No newline at end of file diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/exception/code/MemberErrorCode.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/exception/code/MemberErrorCode.java new file mode 100644 index 0000000..6d71c78 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/exception/code/MemberErrorCode.java @@ -0,0 +1,19 @@ +package com.example.umc10th_wony.domain.member.exception.code; + +import com.example.umc10th_wony.global.apiPayload.code.BaseErrorCode; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.springframework.http.HttpStatus; + +@Getter +@AllArgsConstructor +public enum MemberErrorCode implements BaseErrorCode { + + MEMBER_NOT_FOUND(HttpStatus.NOT_FOUND, "MEMBER404_1", "해당 회원을 찾을 수 없습니다."), + EMAIL_ALREADY_EXISTS(HttpStatus.CONFLICT, "MEMBER409_1", "이미 사용 중인 이메일입니다."), + INVALID_PASSWORD(HttpStatus.UNAUTHORIZED, "MEMBER401_1", "비밀번호가 올바르지 않습니다."); + + private final HttpStatus status; + private final String code; + private final String message; +} \ No newline at end of file diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/exception/code/MemberSuccessCode.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/exception/code/MemberSuccessCode.java new file mode 100644 index 0000000..d28ec63 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/exception/code/MemberSuccessCode.java @@ -0,0 +1,18 @@ +package com.example.umc10th_wony.domain.member.exception.code; + +import com.example.umc10th_wony.global.apiPayload.code.BaseSuccessCode; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.springframework.http.HttpStatus; + +@Getter +@AllArgsConstructor +public enum MemberSuccessCode implements BaseSuccessCode { + + SIGNUP_SUCCESS(HttpStatus.CREATED, "MEMBER201_1", "회원가입에 성공했습니다."), + MEMBER_FOUND(HttpStatus.OK, "MEMBER200_1", "성공적으로 유저를 조회했습니다."); + + private final HttpStatus status; + private final String code; + private final String message; +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/repository/MemberRepository.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/repository/MemberRepository.java new file mode 100644 index 0000000..0121d26 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/repository/MemberRepository.java @@ -0,0 +1,4 @@ +package com.example.umc10th_wony.domain.member.repository; + +public interface MemberRepository { +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/service/MemberService.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/service/MemberService.java new file mode 100644 index 0000000..5e827b2 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/member/service/MemberService.java @@ -0,0 +1,4 @@ +package com.example.umc10th_wony.domain.member.service; + +public class MemberService { +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/controller/MissionController.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/controller/MissionController.java new file mode 100644 index 0000000..c12d3a0 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/controller/MissionController.java @@ -0,0 +1,83 @@ +package com.example.umc10th_wony.domain.mission.controller; + +import com.example.umc10th_wony.domain.mission.dto.MissionCompleteRequest; +import com.example.umc10th_wony.domain.mission.dto.ReviewCreateRequest; +import com.example.umc10th_wony.domain.mission.dto.MissionResponse; +import com.example.umc10th_wony.domain.mission.dto.MissionCompleteResponse; +import com.example.umc10th_wony.domain.mission.dto.ReviewResponse; + +import com.example.umc10th_wony.global.apiPayload.ApiResponse; +import com.example.umc10th_wony.domain.mission.exception.code.MissionSuccessCode; +import com.example.umc10th_wony.global.security.LoginMember; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@Tag(name = "Mission API", description = "미션 관련 API") +@RestController +@RequiredArgsConstructor +@RequestMapping("/api") +public class MissionController { + + // 1. 지역별 미션 목록 조회 + @Operation(summary = "지역별 미션 목록 조회", description = "특정 지역의 미션 목록을 조회합니다.") + @GetMapping("/missions") + public ResponseEntity>> getMissionsByRegion( + @Parameter(description = "지역명 (예: 서울, 부산)", required = true) @RequestParam String region + ) { + // TODO: missionService.getMissionsByRegion(region) + List result = List.of(MissionResponse.builder() + .missionId(1L).title("서울 미션 예시").description("미션 설명") + .region(region).reward(1000).status("OPEN").build()); + return ResponseEntity.ok(ApiResponse.onSuccess(MissionSuccessCode.MISSION_LIST_FOUND, result)); + } + + // 2. 내 미션 목록 조회 + @Operation(summary = "내 미션 목록 조회", description = "현재 로그인한 회원이 참여 중인 미션 목록을 반환합니다.") + @GetMapping("/missions/me") + public ResponseEntity>> getMyMissions( + @Parameter(hidden = true) @LoginMember Long memberId + ) { + // TODO: missionService.getMyMissions(memberId) + List result = List.of(MissionResponse.builder() + .missionId(2L).title("내 미션 예시").description("미션 설명") + .region("서울").reward(500).status("IN_PROGRESS").build()); + return ResponseEntity.ok(ApiResponse.onSuccess(MissionSuccessCode.MISSION_LIST_FOUND, result)); + } + + // 3. 미션 완료 처리 + @Operation(summary = "미션 완료 처리", description = "특정 미션을 완료 처리합니다. JWT에서 회원 ID를 추출합니다.") + @PatchMapping("/missions/{missionId}/complete") + public ResponseEntity> completeMission( + @Parameter(description = "완료할 미션 ID") @PathVariable Long missionId, + @Valid @RequestBody MissionCompleteRequest request, + @Parameter(hidden = true) @LoginMember Long memberId + ) { + // TODO: missionService.completeMission(missionId, memberId, request) + MissionCompleteResponse result = MissionCompleteResponse.builder() + .missionId(missionId).memberId(memberId).status("COMPLETED").rewardPoint(1000).build(); + return ResponseEntity.ok(ApiResponse.onSuccess(MissionSuccessCode.MISSION_COMPLETED, result)); + } + + // 4. 리뷰 작성 + @Operation(summary = "리뷰 작성", description = "완료된 미션에 대해 별점과 텍스트로 리뷰를 작성합니다.") + @PostMapping("/reviews") + public ResponseEntity> createReview( + @Valid @RequestBody ReviewCreateRequest request, + @Parameter(hidden = true) @LoginMember Long memberId + ) { + // TODO: reviewService.createReview(request, memberId) + ReviewResponse result = ReviewResponse.builder() + .reviewId(1L).missionId(request.getMissionId()).memberId(memberId) + .rating(request.getRating()).content(request.getContent()).build(); + return ResponseEntity.status(201) + .body(ApiResponse.onSuccess(MissionSuccessCode.REVIEW_CREATED, result)); + } +} \ No newline at end of file diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/converter/MissionConverter.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/converter/MissionConverter.java new file mode 100644 index 0000000..758d355 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/converter/MissionConverter.java @@ -0,0 +1,4 @@ +package com.example.umc10th_wony.domain.mission.converter; + +public class MissionConverter { +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/dto/MissionCompleteRequest.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/dto/MissionCompleteRequest.java new file mode 100644 index 0000000..233228f --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/dto/MissionCompleteRequest.java @@ -0,0 +1,13 @@ +package com.example.umc10th_wony.domain.mission.dto; + +import jakarta.validation.constraints.NotBlank; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +public class MissionCompleteRequest { + + @NotBlank(message = "미션 완료 인증 내용은 필수입니다.") + private String proof; // 인증 내용 (텍스트 or 이미지 URL 등) +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/dto/MissionCompleteResponse.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/dto/MissionCompleteResponse.java new file mode 100644 index 0000000..93f24dc --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/dto/MissionCompleteResponse.java @@ -0,0 +1,21 @@ +package com.example.umc10th_wony.domain.mission.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +@Getter +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class MissionCompleteResponse { + + private Long missionId; + private Long memberId; + private String status; // COMPLETED + private int rewardPoint; // 지급된 보상 포인트 + private LocalDateTime completedAt; +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/dto/MissionReqDTO.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/dto/MissionReqDTO.java new file mode 100644 index 0000000..23f17a0 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/dto/MissionReqDTO.java @@ -0,0 +1,4 @@ +package com.example.umc10th_wony.domain.mission.dto; + +public class MissionReqDTO { +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/dto/MissionResDTO.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/dto/MissionResDTO.java new file mode 100644 index 0000000..97fe964 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/dto/MissionResDTO.java @@ -0,0 +1,4 @@ +package com.example.umc10th_wony.domain.mission.dto; + +public class MissionResDTO { +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/dto/MissionResponse.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/dto/MissionResponse.java new file mode 100644 index 0000000..b1ae914 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/dto/MissionResponse.java @@ -0,0 +1,24 @@ +package com.example.umc10th_wony.domain.mission.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +@Getter +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class MissionResponse { + + private Long missionId; + private String title; + private String description; + private String region; // 지역명 + private int reward; // 보상 포인트 + private String status; // OPEN / IN_PROGRESS / COMPLETED + private LocalDateTime deadline; + private LocalDateTime createdAt; +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/dto/ReviewCreateRequest.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/dto/ReviewCreateRequest.java new file mode 100644 index 0000000..69ea8a0 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/dto/ReviewCreateRequest.java @@ -0,0 +1,22 @@ +package com.example.umc10th_wony.domain.mission.dto; + +import jakarta.validation.constraints.*; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +public class ReviewCreateRequest { + + @NotNull(message = "미션 ID는 필수입니다.") + private Long missionId; + + @NotNull(message = "별점은 필수입니다.") + @Min(value = 1, message = "별점은 1점 이상이어야 합니다.") + @Max(value = 5, message = "별점은 5점 이하여야 합니다.") + private Integer rating; + + @NotBlank(message = "리뷰 내용은 필수입니다.") + @Size(min = 5, max = 500, message = "리뷰 내용은 5자 이상 500자 이하여야 합니다.") + private String content; +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/dto/ReviewResponse.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/dto/ReviewResponse.java new file mode 100644 index 0000000..ae3269a --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/dto/ReviewResponse.java @@ -0,0 +1,24 @@ +package com.example.umc10th_wony.domain.mission.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +@Getter +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ReviewResponse { + + private Long reviewId; + private Long missionId; + private String missionTitle; + private Long memberId; + private String memberNickname; + private int rating; + private String content; + private LocalDateTime createdAt; +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/entity/Location.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/entity/Location.java new file mode 100644 index 0000000..b7dae42 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/entity/Location.java @@ -0,0 +1,4 @@ +package com.example.umc10th_wony.domain.mission.entity; + +public class Location { +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/entity/Mission.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/entity/Mission.java new file mode 100644 index 0000000..cb500d1 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/entity/Mission.java @@ -0,0 +1,4 @@ +package com.example.umc10th_wony.domain.mission.entity; + +public class Mission { +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/entity/Store.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/entity/Store.java new file mode 100644 index 0000000..4006a04 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/entity/Store.java @@ -0,0 +1,4 @@ +package com.example.umc10th_wony.domain.mission.entity; + +public class Store { +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/entity/mapping/MemberMission.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/entity/mapping/MemberMission.java new file mode 100644 index 0000000..ec26822 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/entity/mapping/MemberMission.java @@ -0,0 +1,4 @@ +package com.example.umc10th_wony.domain.mission.entity.mapping; + +public class MemberMission { +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/enums/Address.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/enums/Address.java new file mode 100644 index 0000000..91a8b74 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/enums/Address.java @@ -0,0 +1,4 @@ +package com.example.umc10th_wony.domain.mission.enums; + +public enum Address { +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/exception/MissionException.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/exception/MissionException.java new file mode 100644 index 0000000..83fa96c --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/exception/MissionException.java @@ -0,0 +1,11 @@ +package com.example.umc10th_wony.domain.mission.exception; + +import com.example.umc10th_wony.domain.mission.exception.code.MissionErrorCode; +import com.example.umc10th_wony.global.apiPayload.exception.ProjectException; + +public class MissionException extends ProjectException { + + public MissionException(MissionErrorCode errorCode) { + super(errorCode); + } +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/exception/code/MissionErrorCode.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/exception/code/MissionErrorCode.java new file mode 100644 index 0000000..5c43370 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/exception/code/MissionErrorCode.java @@ -0,0 +1,19 @@ +package com.example.umc10th_wony.domain.mission.exception.code; + +import com.example.umc10th_wony.global.apiPayload.code.BaseErrorCode; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.springframework.http.HttpStatus; + +@Getter +@AllArgsConstructor +public enum MissionErrorCode implements BaseErrorCode { + + MISSION_NOT_FOUND(HttpStatus.NOT_FOUND, "MISSION404_1", "해당 미션을 찾을 수 없습니다."), + ALREADY_COMPLETED(HttpStatus.CONFLICT, "MISSION409_1", "이미 완료된 미션입니다."), + NOT_PARTICIPATING(HttpStatus.FORBIDDEN, "MISSION403_1", "참여 중인 미션이 아닙니다."); + + private final HttpStatus status; + private final String code; + private final String message; +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/exception/code/MissionSuccessCode.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/exception/code/MissionSuccessCode.java new file mode 100644 index 0000000..ca9b6cb --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/exception/code/MissionSuccessCode.java @@ -0,0 +1,20 @@ +package com.example.umc10th_wony.domain.mission.exception.code; + +import com.example.umc10th_wony.global.apiPayload.code.BaseSuccessCode; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.springframework.http.HttpStatus; + +@Getter +@AllArgsConstructor +public enum MissionSuccessCode implements BaseSuccessCode { + + MISSION_LIST_FOUND(HttpStatus.OK, "MISSION200_1", "미션 목록 조회에 성공했습니다."), + MISSION_COMPLETED(HttpStatus.OK, "MISSION200_2", "미션이 완료 처리되었습니다."), + REVIEW_CREATED(HttpStatus.CREATED, "MISSION201_1", "리뷰가 성공적으로 작성되었습니다."); + + private final HttpStatus status; + private final String code; + private final String message; +} + diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/repository/MissionRepository.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/repository/MissionRepository.java new file mode 100644 index 0000000..6947e33 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/repository/MissionRepository.java @@ -0,0 +1,4 @@ +package com.example.umc10th_wony.domain.mission.repository; + +public interface MissionRepository { +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/service/MissionService.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/service/MissionService.java new file mode 100644 index 0000000..d1a3dd3 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/mission/service/MissionService.java @@ -0,0 +1,4 @@ +package com.example.umc10th_wony.domain.mission.service; + +public class MissionService { +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/controller/ReviewController.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/controller/ReviewController.java new file mode 100644 index 0000000..e093865 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/controller/ReviewController.java @@ -0,0 +1,4 @@ +package com.example.umc10th_wony.domain.review.controller; + +public class ReviewController { +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/converter/ReviewConverter.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/converter/ReviewConverter.java new file mode 100644 index 0000000..99ab5de --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/converter/ReviewConverter.java @@ -0,0 +1,4 @@ +package com.example.umc10th_wony.domain.review.converter; + +public class ReviewConverter { +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/dto/ReviewReqDTO.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/dto/ReviewReqDTO.java new file mode 100644 index 0000000..abd49aa --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/dto/ReviewReqDTO.java @@ -0,0 +1,4 @@ +package com.example.umc10th_wony.domain.review.dto; + +public class ReviewReqDTO { +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/dto/ReviewResDTO.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/dto/ReviewResDTO.java new file mode 100644 index 0000000..ecf7aeb --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/dto/ReviewResDTO.java @@ -0,0 +1,4 @@ +package com.example.umc10th_wony.domain.review.dto; + +public class ReviewResDTO { +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/entity/Reply.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/entity/Reply.java new file mode 100644 index 0000000..95a25b2 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/entity/Reply.java @@ -0,0 +1,4 @@ +package com.example.umc10th_wony.domain.review.entity; + +public class Reply { +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/entity/Review.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/entity/Review.java new file mode 100644 index 0000000..48920e0 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/entity/Review.java @@ -0,0 +1,4 @@ +package com.example.umc10th_wony.domain.review.entity; + +public class Review { +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/entity/ReviewPhoto.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/entity/ReviewPhoto.java new file mode 100644 index 0000000..470c619 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/entity/ReviewPhoto.java @@ -0,0 +1,4 @@ +package com.example.umc10th_wony.domain.review.entity; + +public class ReviewPhoto { +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/exception/ReviewException.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/exception/ReviewException.java new file mode 100644 index 0000000..922eb0a --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/exception/ReviewException.java @@ -0,0 +1,7 @@ +package com.example.umc10th_wony.domain.review.exception; + +public class ReviewException extends RuntimeException { + public ReviewException(String message) { + super(message); + } +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/exception/code/ReviewErrorCode.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/exception/code/ReviewErrorCode.java new file mode 100644 index 0000000..5e51244 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/exception/code/ReviewErrorCode.java @@ -0,0 +1,4 @@ +package com.example.umc10th_wony.domain.review.exception.code; + +public enum ReviewErrorCode { +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/exception/code/ReviewSuccessCode.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/exception/code/ReviewSuccessCode.java new file mode 100644 index 0000000..a0678f6 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/exception/code/ReviewSuccessCode.java @@ -0,0 +1,4 @@ +package com.example.umc10th_wony.domain.review.exception.code; + +public enum ReviewSuccessCode { +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/repository/ReviewRepository.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/repository/ReviewRepository.java new file mode 100644 index 0000000..598f0e9 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/repository/ReviewRepository.java @@ -0,0 +1,4 @@ +package com.example.umc10th_wony.domain.review.repository; + +public interface ReviewRepository { +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/service/ReviewService.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/service/ReviewService.java new file mode 100644 index 0000000..ffc43eb --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/domain/review/service/ReviewService.java @@ -0,0 +1,4 @@ +package com.example.umc10th_wony.domain.review.service; + +public class ReviewService { +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/global/apiPayload/ApiResponse.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/global/apiPayload/ApiResponse.java new file mode 100644 index 0000000..84804c6 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/global/apiPayload/ApiResponse.java @@ -0,0 +1,47 @@ +package com.example.umc10th_wony.global.apiPayload; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.example.umc10th_wony.global.apiPayload.code.BaseErrorCode; +import com.example.umc10th_wony.global.apiPayload.code.BaseSuccessCode; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@Builder +@NoArgsConstructor +@AllArgsConstructor +@JsonPropertyOrder({"isSuccess", "code", "message", "result"}) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ApiResponse { + + @JsonProperty("isSuccess") + private Boolean isSuccess; + + private String code; + private String message; + private T result; + + // 성공 + public static ApiResponse onSuccess(BaseSuccessCode successCode, T result) { + return ApiResponse.builder() + .isSuccess(true) + .code(successCode.getCode()) + .message(successCode.getMessage()) + .result(result) + .build(); + } + + // 실패 + public static ApiResponse onFailure(BaseErrorCode errorCode, T result) { + return ApiResponse.builder() + .isSuccess(false) + .code(errorCode.getCode()) + .message(errorCode.getMessage()) + .result(result) + .build(); + } +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/global/apiPayload/code/BaseErrorCode.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/global/apiPayload/code/BaseErrorCode.java new file mode 100644 index 0000000..c0f5674 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/global/apiPayload/code/BaseErrorCode.java @@ -0,0 +1,9 @@ +package com.example.umc10th_wony.global.apiPayload.code; + +import org.springframework.http.HttpStatus; + +public interface BaseErrorCode { + HttpStatus getStatus(); + String getCode(); + String getMessage(); +} \ No newline at end of file diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/global/apiPayload/code/BaseSuccessCode.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/global/apiPayload/code/BaseSuccessCode.java new file mode 100644 index 0000000..dfcee20 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/global/apiPayload/code/BaseSuccessCode.java @@ -0,0 +1,9 @@ +package com.example.umc10th_wony.global.apiPayload.code; + +import org.springframework.http.HttpStatus; + +public interface BaseSuccessCode { + HttpStatus getStatus(); + String getCode(); + String getMessage(); +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/global/apiPayload/code/GeneralErrorCode.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/global/apiPayload/code/GeneralErrorCode.java new file mode 100644 index 0000000..722ce35 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/global/apiPayload/code/GeneralErrorCode.java @@ -0,0 +1,22 @@ +package com.example.umc10th_wony.global.apiPayload.code; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.springframework.http.HttpStatus; + +@Getter +@AllArgsConstructor +public enum GeneralErrorCode implements BaseErrorCode { + + // 공통 에러 + BAD_REQUEST(HttpStatus.BAD_REQUEST, "COMMON400", "잘못된 요청입니다."), + UNAUTHORIZED(HttpStatus.UNAUTHORIZED, "COMMON401", "인증이 필요합니다."), + FORBIDDEN(HttpStatus.FORBIDDEN, "COMMON403", "접근 권한이 없습니다."), + NOT_FOUND(HttpStatus.NOT_FOUND, "COMMON404", "요청한 리소스를 찾을 수 없습니다."), + METHOD_NOT_ALLOWED(HttpStatus.METHOD_NOT_ALLOWED, "COMMON405", "지원하지 않는 HTTP 메서드입니다."), + INTERNAL_SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "COMMON500", "서버 내부 오류가 발생했습니다."); + + private final HttpStatus status; + private final String code; + private final String message; +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/global/apiPayload/code/GeneralSuccessCode.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/global/apiPayload/code/GeneralSuccessCode.java new file mode 100644 index 0000000..05923b3 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/global/apiPayload/code/GeneralSuccessCode.java @@ -0,0 +1,17 @@ +package com.example.umc10th_wony.global.apiPayload.code; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.springframework.http.HttpStatus; + +@Getter +@AllArgsConstructor +public enum GeneralSuccessCode implements BaseSuccessCode { + + OK(HttpStatus.OK, "COMMON200", "요청에 성공했습니다."), + CREATED(HttpStatus.CREATED, "COMMON201", "리소스가 성공적으로 생성되었습니다."); + + private final HttpStatus status; + private final String code; + private final String message; +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/global/apiPayload/exception/GeneralExceptionAdvice.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/global/apiPayload/exception/GeneralExceptionAdvice.java new file mode 100644 index 0000000..3f1a3e6 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/global/apiPayload/exception/GeneralExceptionAdvice.java @@ -0,0 +1,66 @@ +package com.example.umc10th_wony.global.apiPayload.exception; + +import com.example.umc10th_wony.global.apiPayload.ApiResponse; +import com.example.umc10th_wony.global.apiPayload.code.BaseErrorCode; +import com.example.umc10th_wony.global.apiPayload.code.GeneralErrorCode; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.HttpRequestMethodNotSupportedException; +import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.MissingServletRequestParameterException; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RestControllerAdvice; +import org.springframework.web.servlet.NoHandlerFoundException; + +@RestControllerAdvice +public class GeneralExceptionAdvice { + + // 프로젝트에서 직접 던진 예외 (도메인 Exception 포함) + @ExceptionHandler(ProjectException.class) + public ResponseEntity> handleProjectException(ProjectException e) { + BaseErrorCode errorCode = e.getErrorCode(); + return ResponseEntity.status(errorCode.getStatus()) + .body(ApiResponse.onFailure(errorCode, null)); + } + + // @Valid 검증 실패 + @ExceptionHandler(MethodArgumentNotValidException.class) + public ResponseEntity> handleValidException(MethodArgumentNotValidException e) { + String errorMessage = e.getBindingResult().getAllErrors().get(0).getDefaultMessage(); + BaseErrorCode code = GeneralErrorCode.BAD_REQUEST; + return ResponseEntity.status(code.getStatus()) + .body(ApiResponse.onFailure(code, errorMessage)); + } + + // 필수 Query Parameter 누락 + @ExceptionHandler(MissingServletRequestParameterException.class) + public ResponseEntity> handleMissingParam(MissingServletRequestParameterException e) { + BaseErrorCode code = GeneralErrorCode.BAD_REQUEST; + return ResponseEntity.status(code.getStatus()) + .body(ApiResponse.onFailure(code, e.getMessage())); + } + + // 존재하지 않는 URI + @ExceptionHandler(NoHandlerFoundException.class) + public ResponseEntity> handleNoHandler(NoHandlerFoundException e) { + BaseErrorCode code = GeneralErrorCode.NOT_FOUND; + return ResponseEntity.status(code.getStatus()) + .body(ApiResponse.onFailure(code, null)); + } + + // 지원하지 않는 HTTP 메서드 + @ExceptionHandler(HttpRequestMethodNotSupportedException.class) + public ResponseEntity> handleMethodNotSupported(HttpRequestMethodNotSupportedException e) { + BaseErrorCode code = GeneralErrorCode.METHOD_NOT_ALLOWED; + return ResponseEntity.status(code.getStatus()) + .body(ApiResponse.onFailure(code, null)); + } + + // 그 외 정의되지 않은 모든 예외 + @ExceptionHandler(Exception.class) + public ResponseEntity> handleException(Exception e) { + BaseErrorCode code = GeneralErrorCode.INTERNAL_SERVER_ERROR; + return ResponseEntity.status(code.getStatus()) + .body(ApiResponse.onFailure(code, e.getMessage())); + } +} diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/global/apiPayload/exception/ProjectException.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/global/apiPayload/exception/ProjectException.java new file mode 100644 index 0000000..8000744 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/global/apiPayload/exception/ProjectException.java @@ -0,0 +1,15 @@ +package com.example.umc10th_wony.global.apiPayload.exception; + +import com.example.umc10th_wony.global.apiPayload.code.BaseErrorCode; +import lombok.Getter; + +@Getter +public class ProjectException extends RuntimeException { + + private final BaseErrorCode errorCode; + + public ProjectException(BaseErrorCode errorCode) { + super(errorCode.getMessage()); + this.errorCode = errorCode; + } +} \ No newline at end of file diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/global/config/SwaggerConfig.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/global/config/SwaggerConfig.java new file mode 100644 index 0000000..4984c39 --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/global/config/SwaggerConfig.java @@ -0,0 +1,36 @@ +package com.example.umc10th_wony.global.config; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.security.SecurityRequirement; +import io.swagger.v3.oas.models.security.SecurityScheme; +import io.swagger.v3.oas.models.servers.Server; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class SwaggerConfig { + + @Bean + public OpenAPI swagger() { + Info info = new Info().title("UMC10th").description("10기 Swagger").version("0.0.1"); + + // JWT 토큰 헤더 방식 + String securityScheme = "JWT TOKEN"; + SecurityRequirement securityRequirement = new SecurityRequirement().addList(securityScheme); + + Components components = new Components() + .addSecuritySchemes(securityScheme, new SecurityScheme() + .name(securityScheme) + .type(SecurityScheme.Type.HTTP) + .scheme("Bearer") + .bearerFormat("JWT")); + + return new OpenAPI() + .info(info) + .addServersItem(new Server().url("/")) + .addSecurityItem(securityRequirement) + .components(components); + } +} \ No newline at end of file diff --git a/umc10th_wony/src/main/java/com/example/umc10th_wony/global/security/LoginMember.java b/umc10th_wony/src/main/java/com/example/umc10th_wony/global/security/LoginMember.java new file mode 100644 index 0000000..7b7a4ca --- /dev/null +++ b/umc10th_wony/src/main/java/com/example/umc10th_wony/global/security/LoginMember.java @@ -0,0 +1,16 @@ +package com.example.umc10th_wony.global.security; + +import org.springframework.security.core.annotation.AuthenticationPrincipal; + +import java.lang.annotation.*; + +/** + * 컨트롤러 파라미터에서 JWT로부터 추출한 현재 로그인 회원 ID를 주입받기 위한 커스텀 어노테이션 + * 사용 예시: public ResponseEntity myMethod(@LoginMember Long memberId) + */ +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : memberId") +public @interface LoginMember { +} diff --git a/umc10th_wony/src/main/resources/application.properties b/umc10th_wony/src/main/resources/application.properties new file mode 100644 index 0000000..45603bb --- /dev/null +++ b/umc10th_wony/src/main/resources/application.properties @@ -0,0 +1 @@ +spring.application.name=umc10th_wony diff --git a/umc10th_wony/src/main/resources/application.yml b/umc10th_wony/src/main/resources/application.yml new file mode 100644 index 0000000..c77f22c --- /dev/null +++ b/umc10th_wony/src/main/resources/application.yml @@ -0,0 +1,19 @@ +spring: + application: + name: "umc10th_wony" # "umc10th" + + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver # MySQL JDBC 드라이버 클래스 이름 + url: ${DB_URL} # jdbc:mysql://localhost:3306/{데이터베이스명} + username: ${DB_USER} # MySQL 유저 이름 + password: ${DB_PW} # MySQL 비밀번호 + + jpa: + database: mysql # 사용할 데이터베이스 유형 지정 (MySQL) + database-platform: org.hibernate.dialect.MySQLDialect # Hibernate에서 사용할 MySQL 방언(dialect) 설정 + show-sql: true # 실행된 SQL 쿼리를 콘솔에 출력할지 여부 설정 + hibernate: + ddl-auto: update # 애플리케이션 실행 시 데이터베이스 스키마의 상태를 설정 + properties: + hibernate: + format_sql: true # 출력되는 SQL 쿼리를 보기 좋게 포맷팅spring: \ No newline at end of file diff --git a/umc10th_wony/src/test/java/com/example/umc10th_wony/Umc10thWonyApplicationTests.java b/umc10th_wony/src/test/java/com/example/umc10th_wony/Umc10thWonyApplicationTests.java new file mode 100644 index 0000000..6e2d26d --- /dev/null +++ b/umc10th_wony/src/test/java/com/example/umc10th_wony/Umc10thWonyApplicationTests.java @@ -0,0 +1,13 @@ +package com.example.umc10th_wony; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class Umc10thWonyApplicationTests { + + @Test + void contextLoads() { + } + +}