diff --git a/.github/ISSUE_TEMPLATE/mission-issue.md b/.github/ISSUE_TEMPLATE/mission-issue.md deleted file mode 100644 index 6808a15..0000000 --- a/.github/ISSUE_TEMPLATE/mission-issue.md +++ /dev/null @@ -1,40 +0,0 @@ ---- -name: "미션 이슈" -about: "주차별 작업 계획과 범위를 기록합니다." -title: "[n주차] 이름/[type] 작업 내용" -labels: "" -assignees: "" ---- - -## 1. 무엇을? - - - - -## 2. 상세 설명 - - - - -## 3. 제출 전 체크 계획 - -- [ ] 프로젝트가 정상 실행되는지 확인 -- [ ] `GET /health` 요청 정상 응답 확인 -- [ ] `POST /string/repeat` JSON 응답 요구사항 확인 -- [ ] Controller와 Service 분리 구조 확인 - -## 4. 추가 사항 - - - -## 5. 권장 추가 구현(선택) - -- [ ] 요청/응답 DTO 분리 -- [ ] 잘못된 요청에 대한 예외 처리 -- [ ] 응답 메시지 커스터마이징 -- [ ] 이해하기 쉬운 API 경로 설계 diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 746e0ce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,60 +0,0 @@ - - -## 1. 과제 요구사항 중 구현한 내용 - - - -- [ ] 프로젝트 구조 구성 (Controller/Service 레이어 분리) -- [ ] 헬스체크 API 구현 (`GET /health`) -- [ ] 문자열 2개 반환 API 구현 (`POST /string/repeat`) -- [ ] 권장 추가 구현 반영 (선택) - - -## 2. 핵심 변경 사항 - - - - -## 3. 실행 및 검증 결과 - - - -- 실행 결과: -- `GET /health` 응답: -- `POST /string/repeat` 요청/응답: - - -## 4. 완료 사항 - - - -1. -2. -3. - - -## 5. 추가 사항 - -- 관련 이슈: `closed #이슈번호` - - - -## 제출 체크리스트 - -- [ ] PR 제목이 규칙에 맞다 -- [ ] base가 `{이름}/main` 브랜치다 -- [ ] compare가 `{이름}/{숫자}주차` 브랜치다 -- [ ] 프로젝트가 정상 실행된다 -- [ ] 본인을 Assignee로 지정했다 -- [ ] 파트 담당 Reviewer를 지정했다 -- [ ] 리뷰 피드백을 반영한 뒤 머지/PR close를 진행한다 - -### Reviewer 참고 - - diff --git a/.gitignore b/.gitignore deleted file mode 100644 index b593b3e..0000000 --- a/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -.DS_Store - -# IDE -.idea/ -.vscode/ -*.iml - -# Java/Gradle build outputs -.gradle/ -build/ -out/ - -# Maven build outputs -target/ - -# Logs -*.log - -# Environment files -.env -.env.* - -# OS generated files -Thumbs.db diff --git a/.gradle/9.0.0/checksums/checksums.lock b/.gradle/9.0.0/checksums/checksums.lock new file mode 100644 index 0000000..bd793df Binary files /dev/null and b/.gradle/9.0.0/checksums/checksums.lock differ diff --git a/.gradle/9.0.0/executionHistory/executionHistory.bin b/.gradle/9.0.0/executionHistory/executionHistory.bin new file mode 100644 index 0000000..87202e4 Binary files /dev/null and b/.gradle/9.0.0/executionHistory/executionHistory.bin differ diff --git a/.gradle/9.0.0/executionHistory/executionHistory.lock b/.gradle/9.0.0/executionHistory/executionHistory.lock new file mode 100644 index 0000000..31047e7 Binary files /dev/null and b/.gradle/9.0.0/executionHistory/executionHistory.lock differ diff --git a/.gradle/9.0.0/fileChanges/last-build.bin b/.gradle/9.0.0/fileChanges/last-build.bin new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/.gradle/9.0.0/fileChanges/last-build.bin differ diff --git a/.gradle/9.0.0/fileHashes/fileHashes.bin b/.gradle/9.0.0/fileHashes/fileHashes.bin new file mode 100644 index 0000000..fbfd354 Binary files /dev/null and b/.gradle/9.0.0/fileHashes/fileHashes.bin differ diff --git a/.gradle/9.0.0/fileHashes/fileHashes.lock b/.gradle/9.0.0/fileHashes/fileHashes.lock new file mode 100644 index 0000000..3ee4c34 Binary files /dev/null and b/.gradle/9.0.0/fileHashes/fileHashes.lock differ diff --git a/.gradle/9.0.0/fileHashes/resourceHashesCache.bin b/.gradle/9.0.0/fileHashes/resourceHashesCache.bin new file mode 100644 index 0000000..ed7f722 Binary files /dev/null and b/.gradle/9.0.0/fileHashes/resourceHashesCache.bin differ diff --git a/.gradle/9.0.0/gc.properties b/.gradle/9.0.0/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock new file mode 100644 index 0000000..afbbba2 Binary files /dev/null and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/.gradle/buildOutputCleanup/cache.properties b/.gradle/buildOutputCleanup/cache.properties new file mode 100644 index 0000000..2999dcf --- /dev/null +++ b/.gradle/buildOutputCleanup/cache.properties @@ -0,0 +1,2 @@ +#Tue Mar 24 18:04:07 KST 2026 +gradle.version=9.0.0 diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin new file mode 100644 index 0000000..8889a2a Binary files /dev/null and b/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/.gradle/file-system.probe b/.gradle/file-system.probe new file mode 100644 index 0000000..ffeb2d0 Binary files /dev/null and b/.gradle/file-system.probe differ diff --git a/.gradle/vcs-1/gc.properties b/.gradle/vcs-1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..9879198 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,10 @@ +# 디폴트 무시된 파일 +/shelf/ +/workspace.xml +# 쿼리 파일을 포함한 무시된 디폴트 폴더 +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# 에디터 기반 HTTP 클라이언트 요청 +/httpRequests/ diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..f984869 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +demo1 \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..4f993f3 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..05eca02 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,17 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..03872dd --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + \ 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/README.md b/README.md deleted file mode 100644 index f6c3742..0000000 --- a/README.md +++ /dev/null @@ -1,58 +0,0 @@ -# 7th-BE-Blog - -7기 BE 블로그 프로젝트 레포지토리입니다. - -## ⚠️ 미션 요구사항 - -미션 진행 방법을 꼭 읽고 진행해주세요!! - - 과거 자료라서 레포지토리 이름이 다릅니다! 7th-BE-Blog로 이해하시면 됩니다 - - [미션 진행 방법](https://leets-7th-workspace.notion.site/327ca3362bee80acbd1be10724249c37) - - [참고 레포지토리](https://github.com/Leets-Official/6th-BE-Blog) -> 전 기수 repo입니다. 브랜치, pr 작성법, 리뷰 방법 참고하세요! - -## 📌 1주차 목표 -- Spring Boot 프로젝트를 직접 생성하고 실행해본다. -- Controller와 Service를 분리하여 서버 구조를 이해한다. -- GET / POST 방식의 차이를 간단한 API를 통해 경험한다. -- JSON 형태의 응답을 직접 만들어본다. - -### 과제 요구사항 -1. 프로젝트 구조 구성 - 아래 조건을 만족하도록 프로젝트를 구성합니다. - - Controller 레이어와 Service 레이어를 분리합니다. - - 각 레이어는 역할에 맞게 작성합니다. - - 패키지 구조는 자유롭게 구성하되, 역할 구분이 드러나야 합니다. - -2. 헬스체크 API 구현 - 서버가 정상적으로 동작하는지 확인할 수 있는 헬스체크 API를 구현합니다. - - `GET` Method를 사용합니다. - - 서버가 정상 동작 중임을 확인할 수 있는 문자열을 반환합니다. - -3. 문자열 2개 반환 API 구현 - 문자열을 입력받으면, 같은 문자열을 2개 반환하는 API를 구현합니다. - - `POST` Method를 사용합니다. - - 요청으로 문자열을 전달받습니다. - - 응답은 반드시 JSON 형식이어야 합니다. - - 응답 JSON은 아래 구조를 따라야 합니다. - -### 제출 시 확인할 것 -- 프로젝트가 정상 실행되는가 -- `GET /health` 요청 시 정상 응답이 오는가 -- `POST /string/repeat` 요청 시 JSON 응답이 요구사항과 동일한가 -- Controller와 Service가 분리되어 있는가 - -### 권장 추가 구현 -필수는 아니지만 아래 항목도 함께 해보면 좋습니다. - -- 요청/응답 DTO 분리하기 -- 잘못된 요청에 대한 예외 처리 고민해보기 -- 응답 메시지를 직접 변경해보기 -- API 경로를 본인이 이해하기 쉬운 구조로 설계해보기 - -## 👥 팀 구성 - -| 1조 | 2조 | 3조 | 4조 | 5조 | -|-------|-------|-------|-------|-------| -| 강예손 | 김지훈 | 이교형 | 김다인 | 송유경 | -| 나명준 | 한하람 | 조연준 | 김동빈 | 임성현 | -| 이건희 | 남유정 | 시재욱 | 임현성 | 정대교 | -| 이은표 | 변승현 | 최유찬 | 이예서 | 강지훈 | diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..9adf091 --- /dev/null +++ b/build.gradle @@ -0,0 +1,43 @@ +plugins { + id 'java' + id 'org.springframework.boot' version '3.5.12' + id 'io.spring.dependency-management' version '1.1.7' +} + +group = 'com.example' +version = '0.0.1-SNAPSHOT' + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(21) + } +} + +configurations { + compileOnly { + extendsFrom annotationProcessor + } +} + +repositories { + mavenCentral() +} + +dependencies { + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' + implementation 'org.springframework.boot:spring-boot-starter-web' + compileOnly 'org.projectlombok:lombok' + runtimeOnly 'com.mysql:mysql-connector-j' + annotationProcessor 'org.projectlombok:lombok' + testImplementation 'org.springframework.boot:spring-boot-starter-test' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' + runtimeOnly 'com.h2database:h2' +} + +tasks.named('test') { + useJUnitPlatform() +} + +springBoot { + mainClass = 'com.example.demo.DemoApplication' +} diff --git a/build/classes/java/main/com/example/demo1/Demo1Application.class b/build/classes/java/main/com/example/demo1/Demo1Application.class new file mode 100644 index 0000000..70facd3 Binary files /dev/null and b/build/classes/java/main/com/example/demo1/Demo1Application.class differ diff --git a/build/classes/java/main/com/example/demo1/controller/ApiController.class b/build/classes/java/main/com/example/demo1/controller/ApiController.class new file mode 100644 index 0000000..522f3f2 Binary files /dev/null and b/build/classes/java/main/com/example/demo1/controller/ApiController.class differ diff --git a/build/classes/java/main/com/example/demo1/dto/StringRequestDto.class b/build/classes/java/main/com/example/demo1/dto/StringRequestDto.class new file mode 100644 index 0000000..471c833 Binary files /dev/null and b/build/classes/java/main/com/example/demo1/dto/StringRequestDto.class differ diff --git a/build/classes/java/main/com/example/demo1/dto/StringResponseDto$StringResponseDtoBuilder.class b/build/classes/java/main/com/example/demo1/dto/StringResponseDto$StringResponseDtoBuilder.class new file mode 100644 index 0000000..5a227b0 Binary files /dev/null and b/build/classes/java/main/com/example/demo1/dto/StringResponseDto$StringResponseDtoBuilder.class differ diff --git a/build/classes/java/main/com/example/demo1/dto/StringResponseDto.class b/build/classes/java/main/com/example/demo1/dto/StringResponseDto.class new file mode 100644 index 0000000..dd67c79 Binary files /dev/null and b/build/classes/java/main/com/example/demo1/dto/StringResponseDto.class differ diff --git a/build/classes/java/main/com/example/demo1/service/ApiService.class b/build/classes/java/main/com/example/demo1/service/ApiService.class new file mode 100644 index 0000000..8c3d5fe Binary files /dev/null and b/build/classes/java/main/com/example/demo1/service/ApiService.class differ diff --git a/build/tmp/compileJava/previous-compilation-data.bin b/build/tmp/compileJava/previous-compilation-data.bin new file mode 100644 index 0000000..fb180e1 Binary files /dev/null and b/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..8bdaf60 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..2a84e18 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..ef07e01 --- /dev/null +++ b/gradlew @@ -0,0 +1,251 @@ +#!/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/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\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 + +CLASSPATH="\\\"\\\"" + + +# 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, 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" \ + -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/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..db3a6ac --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,94 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH= + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -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/settings.gradle b/settings.gradle new file mode 100644 index 0000000..45d9527 --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'demo1' diff --git a/src/main/java/com/example/demo/DemoApplication.java b/src/main/java/com/example/demo/DemoApplication.java new file mode 100644 index 0000000..e910566 --- /dev/null +++ b/src/main/java/com/example/demo/DemoApplication.java @@ -0,0 +1,12 @@ +package com.example.demo; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; + +@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) // 이 부분 추가 +public class DemoApplication { + public static void main(String[] args) { + SpringApplication.run(DemoApplication.class, args); + } +} diff --git a/src/main/java/com/example/demo/controller/ApiController.java b/src/main/java/com/example/demo/controller/ApiController.java new file mode 100644 index 0000000..5c8be93 --- /dev/null +++ b/src/main/java/com/example/demo/controller/ApiController.java @@ -0,0 +1,25 @@ +package com.example.demo.controller; + +import com.example.demo.dto.RepeatResponse; +import com.example.demo.service.ApiService; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; +import java.util.Map; + +@RestController +@RequiredArgsConstructor +public class ApiController { + private final ApiService apiService; + + @GetMapping("/health") + public String healthCheck() { + return "OK"; + } + + @PostMapping("/string/repeat") + public RepeatResponse repeatString(@RequestBody Map request) { + String input = request.get("value"); + String processed = apiService.processString(input); + return new RepeatResponse(input, processed); + } +} \ No newline at end of file diff --git a/src/main/java/com/example/demo/dto/RepeatResponse.java b/src/main/java/com/example/demo/dto/RepeatResponse.java new file mode 100644 index 0000000..fa3fd35 --- /dev/null +++ b/src/main/java/com/example/demo/dto/RepeatResponse.java @@ -0,0 +1,11 @@ +package com.example.demo.dto; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class RepeatResponse { + private String original; + private String repeated; +} \ No newline at end of file diff --git a/src/main/java/com/example/demo/service/ApiService.java b/src/main/java/com/example/demo/service/ApiService.java new file mode 100644 index 0000000..da63dba --- /dev/null +++ b/src/main/java/com/example/demo/service/ApiService.java @@ -0,0 +1,10 @@ +package com.example.demo.service; + +import org.springframework.stereotype.Service; + +@Service +public class ApiService { + public String processString(String input) { + return input + " " + input; // 문자열을 반복해주는 로직 + } +} \ No newline at end of file diff --git a/src/main/java/com/example/demo1/Demo1Application.java b/src/main/java/com/example/demo1/Demo1Application.java new file mode 100644 index 0000000..5ec0fc5 --- /dev/null +++ b/src/main/java/com/example/demo1/Demo1Application.java @@ -0,0 +1,12 @@ +package com.example.demo1; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; + +@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) +public class Demo1Application { + public static void main(String[] args) { + SpringApplication.run(Demo1Application.class, args); + } +} \ No newline at end of file diff --git a/src/main/java/com/example/demo1/controller/ApiController.java b/src/main/java/com/example/demo1/controller/ApiController.java new file mode 100644 index 0000000..0d7b5ea --- /dev/null +++ b/src/main/java/com/example/demo1/controller/ApiController.java @@ -0,0 +1,31 @@ +package com.example.demo1.controller; + +import com.example.demo1.dto.StringRequestDto; +import com.example.demo1.dto.StringResponseDto; +import com.example.demo1.service.ApiService; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +@RestController +//@RequestMapping("/api/v1") +@RequiredArgsConstructor +public class ApiController { + + private final ApiService apiService; + + @GetMapping("/health") + public ResponseEntity healthCheck() { + return ResponseEntity.ok(apiService.getHealthStatus()); + } + + @PostMapping("/string/repeat") + public ResponseEntity repeatString(@RequestBody StringRequestDto requestDto) { + return ResponseEntity.ok(apiService.repeatString(requestDto)); + } + + @ExceptionHandler(IllegalArgumentException.class) + public ResponseEntity handleRuntimeException(IllegalArgumentException e) { + return ResponseEntity.badRequest().body(e.getMessage()); + } +} \ No newline at end of file diff --git a/src/main/java/com/example/demo1/dto/StringRequestDto.java b/src/main/java/com/example/demo1/dto/StringRequestDto.java new file mode 100644 index 0000000..ceff83c --- /dev/null +++ b/src/main/java/com/example/demo1/dto/StringRequestDto.java @@ -0,0 +1,10 @@ +package com.example.demo1.dto; + +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +public class StringRequestDto { + private String value; +} \ No newline at end of file diff --git a/src/main/java/com/example/demo1/dto/StringResponseDto.java b/src/main/java/com/example/demo1/dto/StringResponseDto.java new file mode 100644 index 0000000..525625d --- /dev/null +++ b/src/main/java/com/example/demo1/dto/StringResponseDto.java @@ -0,0 +1,11 @@ +package com.example.demo1.dto; + +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder +public class StringResponseDto { + private String string_one; + private String string_two; +} \ No newline at end of file diff --git a/src/main/java/com/example/demo1/service/ApiService.java b/src/main/java/com/example/demo1/service/ApiService.java new file mode 100644 index 0000000..8eaac06 --- /dev/null +++ b/src/main/java/com/example/demo1/service/ApiService.java @@ -0,0 +1,26 @@ +package com.example.demo1.service; + +import com.example.demo1.dto.StringRequestDto; +import com.example.demo1.dto.StringResponseDto; +import org.springframework.stereotype.Service; + +@Service +public class ApiService { + + public String getHealthStatus() { + return "ok"; + } + + public StringResponseDto repeatString(StringRequestDto requestDto) { + String original = requestDto.getValue(); + + if (original == null || original.isBlank()) { + throw new IllegalArgumentException("입력 값이 비어있습니다."); + } + + return StringResponseDto.builder() + .string_one(original) + .string_two(original) + .build(); + } +} \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..2109a44 --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1 @@ +spring.application.name=demo diff --git a/src/test/java/com/example/demo/DemoApplicationTests.java b/src/test/java/com/example/demo/DemoApplicationTests.java new file mode 100644 index 0000000..2778a6a --- /dev/null +++ b/src/test/java/com/example/demo/DemoApplicationTests.java @@ -0,0 +1,13 @@ +package com.example.demo; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class DemoApplicationTests { + + @Test + void contextLoads() { + } + +}