diff --git a/goodnight/.gitignore b/goodnight/.gitignore new file mode 100644 index 00000000..c2065bc2 --- /dev/null +++ b/goodnight/.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/goodnight/build.gradle b/goodnight/build.gradle new file mode 100644 index 00000000..6a1c673c --- /dev/null +++ b/goodnight/build.gradle @@ -0,0 +1,35 @@ +plugins { + id 'java' + id 'org.springframework.boot' version '2.7.9' + id 'io.spring.dependency-management' version '1.0.15.RELEASE' +} + +group = 'com.techeer' +version = '0.0.1-SNAPSHOT' +sourceCompatibility = '11' + +configurations { + compileOnly { + extendsFrom annotationProcessor + } +} + +repositories { + mavenCentral() +} + +dependencies { + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' + implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' + implementation 'org.springframework.boot:spring-boot-starter-web' + compileOnly 'org.projectlombok:lombok' + developmentOnly 'org.springframework.boot:spring-boot-devtools' + runtimeOnly 'com.mysql:mysql-connector-j' + annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' + annotationProcessor 'org.projectlombok:lombok' + testImplementation 'org.springframework.boot:spring-boot-starter-test' +} + +tasks.named('test') { + useJUnitPlatform() +} diff --git a/goodnight/docker-compose.yml b/goodnight/docker-compose.yml new file mode 100644 index 00000000..59490153 --- /dev/null +++ b/goodnight/docker-compose.yml @@ -0,0 +1,25 @@ +version: '3' + +volumes: + good-night-dev_db_vol: + driver: local + +services: + db: + image: mysql/mysql-server:8.0 + container_name: good-night-dev-db + restart: always + command: + - --default-authentication-plugin=mysql_native_password + - --character-set-server=utf8mb4 + - --collation-server=utf8mb4_unicode_520_ci + environment: + MYSQL_DATABASE: userdb + MYSQL_ROOT_HOST: "%" + MYSQL_ROOT_PASSWORD: password + MYSQL_USER: user + MYSQL_PASSWORD: password + ports: + - '33080:3306' + volumes: + - good-night-dev_db_vol:/var/lib/mysql \ No newline at end of file diff --git a/goodnight/gradle/wrapper/gradle-wrapper.jar b/goodnight/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..249e5832 Binary files /dev/null and b/goodnight/gradle/wrapper/gradle-wrapper.jar differ diff --git a/goodnight/gradle/wrapper/gradle-wrapper.properties b/goodnight/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..070cb702 --- /dev/null +++ b/goodnight/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/goodnight/gradlew b/goodnight/gradlew new file mode 100755 index 00000000..a69d9cb6 --- /dev/null +++ b/goodnight/gradlew @@ -0,0 +1,240 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# 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/master/subprojects/plugins/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 + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# 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"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || 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 + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + 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 + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/goodnight/gradlew.bat b/goodnight/gradlew.bat new file mode 100644 index 00000000..53a6b238 --- /dev/null +++ b/goodnight/gradlew.bat @@ -0,0 +1,91 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +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. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/goodnight/settings.gradle b/goodnight/settings.gradle new file mode 100644 index 00000000..182a5b2f --- /dev/null +++ b/goodnight/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'goodnight' diff --git a/goodnight/src/main/java/com/techeer/goodnight/GoodnightApplication.java b/goodnight/src/main/java/com/techeer/goodnight/GoodnightApplication.java new file mode 100644 index 00000000..490e1f3e --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnight/GoodnightApplication.java @@ -0,0 +1,13 @@ +package com.techeer.goodnight; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class GoodnightApplication { + + public static void main(String[] args) { + SpringApplication.run(GoodnightApplication.class, args); + } + +} diff --git a/goodnight/src/main/java/com/techeer/goodnight/domain/restaurant/controller/RestaurantController.java b/goodnight/src/main/java/com/techeer/goodnight/domain/restaurant/controller/RestaurantController.java new file mode 100644 index 00000000..b1324a64 --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnight/domain/restaurant/controller/RestaurantController.java @@ -0,0 +1,64 @@ +package com.techeer.goodnight.domain.restaurant.controller; + +import com.techeer.goodnight.domain.restaurant.service.RestaurantService; +import com.techeer.goodnight.domain.restaurant.dto.request.RestaruantCreateRequestDto; +import com.techeer.goodnight.domain.restaurant.dto.request.RestaruantUpdateRequestDto; +import com.techeer.goodnight.domain.restaurant.dto.response.RestaruantResponseDto; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.data.web.PageableDefault; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.Optional; + +@Slf4j +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/restaurants") +public class RestaurantController { + + @Resource(name = "restaurantService") + private final RestaurantService restaurantService; + + @GetMapping() + public ResponseEntity> get( + @PageableDefault(sort ="id", direction = Sort.Direction.DESC) + Pageable pageable, + @RequestParam(value = "categoryName", required = false) Optional categoryName + ) { + return new ResponseEntity<>(restaurantService.getRestaurants(pageable, categoryName), HttpStatus.OK); + } + + + @PostMapping() + public ResponseEntity create( + @RequestBody final RestaruantCreateRequestDto createRestaurantReq + ) { + return new ResponseEntity<>(restaurantService.create(createRestaurantReq), HttpStatus.CREATED); + } + + @GetMapping("/{id}") + public ResponseEntity getRestaurantById(@PathVariable final long id) { + return new ResponseEntity<>(restaurantService.findById(id), HttpStatus.OK); + } + + + @PatchMapping("/{id}") + public ResponseEntity patchRestaurantById( + @PathVariable final long id, + @RequestBody final RestaruantUpdateRequestDto patchRestaurantReq) { + return new ResponseEntity<>(restaurantService.patchById(id, patchRestaurantReq), HttpStatus.OK); + } + + + @DeleteMapping("/{id}") + public void deleteRestaurantById(@PathVariable final long id) { + restaurantService.deleteById(id); + } +} \ No newline at end of file diff --git a/goodnight/src/main/java/com/techeer/goodnight/domain/restaurant/dto/request/RestaruantCreateRequestDto.java b/goodnight/src/main/java/com/techeer/goodnight/domain/restaurant/dto/request/RestaruantCreateRequestDto.java new file mode 100644 index 00000000..3ffc0f2f --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnight/domain/restaurant/dto/request/RestaruantCreateRequestDto.java @@ -0,0 +1,22 @@ +package com.techeer.goodnight.domain.restaurant.dto.request; +import com.techeer.goodnight.domain.restaurant.entity.Restaurant; + +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class RestaruantCreateRequestDto { + + private String name; + + private String categoryName; + + public Restaurant toEntity() { + return Restaurant.builder() + .name(name) + .categoryName(categoryName) + .build(); + } +} \ No newline at end of file diff --git a/goodnight/src/main/java/com/techeer/goodnight/domain/restaurant/dto/request/RestaruantUpdateRequestDto.java b/goodnight/src/main/java/com/techeer/goodnight/domain/restaurant/dto/request/RestaruantUpdateRequestDto.java new file mode 100644 index 00000000..71b2e5da --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnight/domain/restaurant/dto/request/RestaruantUpdateRequestDto.java @@ -0,0 +1,12 @@ +package com.techeer.goodnight.domain.restaurant.dto.request; + +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class RestaruantUpdateRequestDto { + private String categoryName; + +} \ No newline at end of file diff --git a/goodnight/src/main/java/com/techeer/goodnight/domain/restaurant/dto/response/RestaruantResponseDto.java b/goodnight/src/main/java/com/techeer/goodnight/domain/restaurant/dto/response/RestaruantResponseDto.java new file mode 100644 index 00000000..e75c95a6 --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnight/domain/restaurant/dto/response/RestaruantResponseDto.java @@ -0,0 +1,33 @@ +package com.techeer.goodnight.domain.restaurant.dto.response; + +import com.techeer.goodnight.domain.restaurant.entity.Restaurant; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class RestaruantResponseDto { + + private long id; + + private LocalDateTime createdAt; + + private LocalDateTime updatedAt; + + private String name; + + private String categoryName; + + @Builder + public RestaruantResponseDto(Restaurant restaurant) { + this.id = restaurant.getId(); + this.createdAt = restaurant.getCreatedAt(); + this.updatedAt = restaurant.getUpdatedAt(); + this.name = restaurant.getName(); + this.categoryName = restaurant.getCategoryName(); + } +} \ No newline at end of file diff --git a/goodnight/src/main/java/com/techeer/goodnight/domain/restaurant/entity/Restaurant.java b/goodnight/src/main/java/com/techeer/goodnight/domain/restaurant/entity/Restaurant.java new file mode 100644 index 00000000..a960495a --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnight/domain/restaurant/entity/Restaurant.java @@ -0,0 +1,52 @@ +package com.techeer.goodnight.domain.restaurant.entity; +import com.techeer.goodnight.domain.review.entity.Review; +import lombok.*; +import com.techeer.goodnight.global.domain.BaseEntity; + +import javax.persistence.*; +import java.time.LocalDateTime; + +import java.util.ArrayList; +import java.util.List; + + +@Getter +@Entity +@Table(name = "restaurant") +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class Restaurant extends BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column + private String name; + + @Column + private String categoryName; + + @OneToMany(mappedBy = "restaurant", fetch = FetchType.LAZY) + @NonNull + private List reviewList = new ArrayList<>(); + + + @Builder + public Restaurant(String name, String categoryName) { + this.name = name; + this.categoryName = categoryName; + } + + public void setCategoryName(String categoryName) { + this.categoryName = categoryName; + } + + public void setIsDeleted(boolean isDeleted) { + this.isDeleted = isDeleted; + } + + public void setDeletedAt(LocalDateTime deletedAt) { + this.deletedAt = deletedAt; + } + +} \ No newline at end of file diff --git a/goodnight/src/main/java/com/techeer/goodnight/domain/restaurant/exception/RestaurantExceptionHandler.java b/goodnight/src/main/java/com/techeer/goodnight/domain/restaurant/exception/RestaurantExceptionHandler.java new file mode 100644 index 00000000..9641ee42 --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnight/domain/restaurant/exception/RestaurantExceptionHandler.java @@ -0,0 +1,20 @@ +package com.techeer.goodnight.domain.restaurant.exception; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; +import com.techeer.goodnight.global.response.ErrorResponse; + + +@Slf4j +@RestControllerAdvice +public class RestaurantExceptionHandler { + + @ResponseStatus(value = HttpStatus.NOT_FOUND) + @ExceptionHandler(RestaurantIdNotFoundException.class) + public ErrorResponse handleRestaurantIdNotFoundException(RestaurantIdNotFoundException ex) { + log.info("restaurant id not found exception", ex); + return new ErrorResponse(ex.getErrorCode()); + } +} \ No newline at end of file diff --git a/goodnight/src/main/java/com/techeer/goodnight/domain/restaurant/exception/RestaurantIdNotFoundException.java b/goodnight/src/main/java/com/techeer/goodnight/domain/restaurant/exception/RestaurantIdNotFoundException.java new file mode 100644 index 00000000..569a176f --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnight/domain/restaurant/exception/RestaurantIdNotFoundException.java @@ -0,0 +1,15 @@ +package com.techeer.goodnight.domain.restaurant.exception; + +import com.techeer.goodnight.global.exception.ErrorCode; +import lombok.Getter; + +@Getter +public class RestaurantIdNotFoundException extends RuntimeException{ + + private final ErrorCode errorCode; + + public RestaurantIdNotFoundException() { + this.errorCode = ErrorCode.RESTAURANT_ID_NOT_FOUND; + } + +} diff --git a/goodnight/src/main/java/com/techeer/goodnight/domain/restaurant/repository/RestaurantRepository.java b/goodnight/src/main/java/com/techeer/goodnight/domain/restaurant/repository/RestaurantRepository.java new file mode 100644 index 00000000..189b6fb3 --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnight/domain/restaurant/repository/RestaurantRepository.java @@ -0,0 +1,21 @@ +package com.techeer.goodnight.domain.restaurant.repository; +import com.techeer.goodnight.domain.restaurant.entity.Restaurant; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.stereotype.Repository; +import java.util.Optional; + +@Repository +public interface RestaurantRepository extends PagingAndSortingRepository, + JpaRepository { + + @Query("select r from Restaurant r where r.isDeleted = false") + @Override + Page findAll(Pageable pageable); + + @Query("select r from Restaurant r where r.categoryName = :categoryName and r.isDeleted = false") + Page findAllWithCategoryName(Pageable pageable, Optional categoryName); +} \ No newline at end of file diff --git a/goodnight/src/main/java/com/techeer/goodnight/domain/restaurant/service/RestaurantService.java b/goodnight/src/main/java/com/techeer/goodnight/domain/restaurant/service/RestaurantService.java new file mode 100644 index 00000000..f17f6539 --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnight/domain/restaurant/service/RestaurantService.java @@ -0,0 +1,70 @@ +package com.techeer.goodnight.domain.restaurant.service; + +import com.techeer.goodnight.domain.restaurant.repository.RestaurantRepository; +import com.techeer.goodnight.domain.restaurant.dto.request.RestaruantCreateRequestDto; +import com.techeer.goodnight.domain.restaurant.dto.request.RestaruantUpdateRequestDto; +import com.techeer.goodnight.domain.restaurant.dto.response.RestaruantResponseDto; +import com.techeer.goodnight.domain.restaurant.entity.Restaurant; +import com.techeer.goodnight.domain.restaurant.exception.RestaurantIdNotFoundException; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; + +import java.time.LocalDateTime; +import java.util.Date; +import java.util.Optional; + +@Service +@RequiredArgsConstructor +public class RestaurantService { + private final RestaurantRepository restaurantRepository; + + public Page getRestaurants(Pageable pageable, Optional categoryName) { + if(categoryName.isEmpty()) { // Optional은 지양해야 된다. 용량을 많이 차지한다. + Page restaurants = restaurantRepository.findAll(pageable); + + return restaurants.map(RestaruantResponseDto::new); + } + + Page restaurants = restaurantRepository.findAllWithCategoryName(pageable, categoryName); + + return restaurants.map(RestaruantResponseDto::new); + } + + public RestaruantResponseDto create(RestaruantCreateRequestDto createRestaurantReq) { + Restaurant restaurant = createRestaurantReq.toEntity(); + restaurantRepository.save(restaurant); + + return new RestaruantResponseDto(restaurant); + } + + public RestaruantResponseDto findById(long id) { + Restaurant restaurant = restaurantRepository.findById(id).orElseThrow(RestaurantIdNotFoundException::new); + + return new RestaruantResponseDto(restaurant); + } + + public Restaurant findByIdInner(long id) { + return restaurantRepository.findById(id).orElseThrow(RestaurantIdNotFoundException::new); + } + + public RestaruantResponseDto patchById(long id, RestaruantUpdateRequestDto patchRestaurantReq) { + Restaurant restaurant = restaurantRepository.findById(id).orElseThrow(RestaurantIdNotFoundException::new); + + restaurant.setCategoryName(patchRestaurantReq.getCategoryName()); + restaurantRepository.save(restaurant); + + return new RestaruantResponseDto(restaurant); + } + + + public void deleteById(long id) { + Restaurant restaurant = this.findByIdInner(id); + + restaurant.setIsDeleted(true); + restaurant.setDeletedAt(LocalDateTime.now()); + + restaurantRepository.save(restaurant); + } +} \ No newline at end of file diff --git a/goodnight/src/main/java/com/techeer/goodnight/domain/review/controller/ReviewController.java b/goodnight/src/main/java/com/techeer/goodnight/domain/review/controller/ReviewController.java new file mode 100644 index 00000000..c382b701 --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnight/domain/review/controller/ReviewController.java @@ -0,0 +1,59 @@ +package com.techeer.goodnight.domain.review.controller; + +import com.techeer.goodnight.domain.review.service.ReviewService; +import com.techeer.goodnight.domain.review.dto.request.ViewCreateRequestDto; +import com.techeer.goodnight.domain.review.dto.request.ViewUpdateRequestDto; +import com.techeer.goodnight.domain.review.dto.response.ReviewResponseDto; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.data.web.PageableDefault; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.Optional; + +@Slf4j +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/reviews") +public class ReviewController { + + @Resource(name = "reviewService") + private final ReviewService reviewService; + + @GetMapping() + public ResponseEntity> getReviews( + @PageableDefault(sort = "id", direction = Sort.Direction.DESC)Pageable pageable, + @RequestParam(value = "keyword", required = false) Optional keyword + ) { + return new ResponseEntity<>(reviewService.findAll(pageable, keyword), HttpStatus.OK); + } + + + @PostMapping() + public ResponseEntity create(@RequestBody final ViewCreateRequestDto reviewReq) { + return new ResponseEntity<>(reviewService.create(reviewReq), HttpStatus.CREATED); + } + + @GetMapping("/{id}") + public ResponseEntity getReview(@PathVariable long id) { + return new ResponseEntity<>(reviewService.findById(id), HttpStatus.OK); + } + + @PatchMapping("/{id}") + public ResponseEntity patchReview( + @PathVariable long id, + @RequestBody ViewUpdateRequestDto patchReviewReq) { + return new ResponseEntity<>(reviewService.patchById(id, patchReviewReq), HttpStatus.OK); + } + + @DeleteMapping("/{id}") + public void deleteReview(@PathVariable long id) { + reviewService.deleteById(id); + } +} \ No newline at end of file diff --git a/goodnight/src/main/java/com/techeer/goodnight/domain/review/dto/request/ViewCreateRequestDto.java b/goodnight/src/main/java/com/techeer/goodnight/domain/review/dto/request/ViewCreateRequestDto.java new file mode 100644 index 00000000..c532ba33 --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnight/domain/review/dto/request/ViewCreateRequestDto.java @@ -0,0 +1,27 @@ +package com.techeer.goodnight.domain.review.dto.request; + +import com.techeer.goodnight.domain.restaurant.entity.Restaurant; +import com.techeer.goodnight.domain.review.entity.Review; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class ViewCreateRequestDto { + + private long restaurantId; + + private String title; + + private String description; + + public Review toEntity(Restaurant restaurant) { + return Review.builder() + .title(title) + .description(description) + .restaurant(restaurant) + .build(); + } + +} \ No newline at end of file diff --git a/goodnight/src/main/java/com/techeer/goodnight/domain/review/dto/request/ViewUpdateRequestDto.java b/goodnight/src/main/java/com/techeer/goodnight/domain/review/dto/request/ViewUpdateRequestDto.java new file mode 100644 index 00000000..d5e60bb5 --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnight/domain/review/dto/request/ViewUpdateRequestDto.java @@ -0,0 +1,17 @@ +package com.techeer.goodnight.domain.review.dto.request; + +import com.techeer.goodnight.domain.restaurant.entity.Restaurant; +import com.techeer.goodnight.domain.review.entity.Review; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class ViewUpdateRequestDto { + + private String title; + + private String description; + +} \ No newline at end of file diff --git a/goodnight/src/main/java/com/techeer/goodnight/domain/review/dto/response/ReviewResponseDto.java b/goodnight/src/main/java/com/techeer/goodnight/domain/review/dto/response/ReviewResponseDto.java new file mode 100644 index 00000000..e9ee11eb --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnight/domain/review/dto/response/ReviewResponseDto.java @@ -0,0 +1,36 @@ +package com.techeer.goodnight.domain.review.dto.response; + +import com.techeer.goodnight.domain.restaurant.entity.Restaurant; +import com.techeer.goodnight.domain.review.entity.Review; + +import java.time.LocalDateTime; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class ReviewResponseDto { + + private long id; + + private LocalDateTime createdAt; + + private LocalDateTime updatedAt; + + private String restaurantName; + + private String title; + private String description; + + @Builder + public ReviewResponseDto(Review review, Restaurant restaurant) { + this.id = review.getId(); + this.createdAt = review.getCreatedAt(); + this.updatedAt = review.getUpdatedAt(); + this.restaurantName = restaurant.getName(); + this.title = review.getTitle(); + this.description = review.getDescription(); + } +} \ No newline at end of file diff --git a/goodnight/src/main/java/com/techeer/goodnight/domain/review/entity/Review.java b/goodnight/src/main/java/com/techeer/goodnight/domain/review/entity/Review.java new file mode 100644 index 00000000..89b61306 --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnight/domain/review/entity/Review.java @@ -0,0 +1,53 @@ +package com.techeer.goodnight.domain.review.entity; + +import com.techeer.goodnight.global.domain.BaseEntity; +import com.techeer.goodnight.domain.restaurant.entity.Restaurant; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@Entity +@Table(name = "review") +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class Review extends BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column + private String title; + + @Column + private String description; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "restaurant_id") + private Restaurant restaurant; + + @Builder + public Review(Restaurant restaurant, String title, String description) { + this.restaurant = restaurant; + this.title = title; + this.description = description; + } + + public void setTitle(String title) { + this.title = title; + } + + public void setDescription(String description) { + this.description = description; + } +} \ No newline at end of file diff --git a/goodnight/src/main/java/com/techeer/goodnight/domain/review/repository/ReviewRepository.java b/goodnight/src/main/java/com/techeer/goodnight/domain/review/repository/ReviewRepository.java new file mode 100644 index 00000000..ace871fe --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnight/domain/review/repository/ReviewRepository.java @@ -0,0 +1,16 @@ +package com.techeer.goodnight.domain.review.repository; +import com.techeer.goodnight.domain.review.entity.Review; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.PagingAndSortingRepository; + +import java.util.Optional; + +public interface ReviewRepository extends PagingAndSortingRepository, JpaRepository { + + @Query("select r from Review r where r.title LIKE %:keyword or r.description LIKE %:keyword and r.isDeleted is false") + Page findAllWithKeyword(Pageable pageable, Optional keyword); +} \ No newline at end of file diff --git a/goodnight/src/main/java/com/techeer/goodnight/domain/review/service/ReviewService.java b/goodnight/src/main/java/com/techeer/goodnight/domain/review/service/ReviewService.java new file mode 100644 index 00000000..089c7eb0 --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnight/domain/review/service/ReviewService.java @@ -0,0 +1,72 @@ +package com.techeer.goodnight.domain.review.service; + +import com.techeer.goodnight.domain.restaurant.service.RestaurantService; +import com.techeer.goodnight.domain.restaurant.entity.Restaurant; +import com.techeer.goodnight.domain.review.repository.ReviewRepository; + +import com.techeer.goodnight.domain.review.dto.request.ViewCreateRequestDto; +import com.techeer.goodnight.domain.review.dto.request.ViewUpdateRequestDto; +import com.techeer.goodnight.domain.review.dto.response.ReviewResponseDto; +import com.techeer.goodnight.domain.review.entity.Review; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Optional; + + +@Service +@RequiredArgsConstructor +public class ReviewService { + + private final ReviewRepository reviewRepository; + private final RestaurantService restaurantService; + + + public ReviewResponseDto create(ViewCreateRequestDto reviewReq) { + Restaurant restaurant = restaurantService.findByIdInner(reviewReq.getRestaurantId()); + + Review review = reviewReq.toEntity(restaurant); + + reviewRepository.save(review); + + return new ReviewResponseDto(review, restaurant); + } + + @Transactional(readOnly = true) + public Page findAll(Pageable pageable, Optional keyword) { + if(keyword.isEmpty()) { + Page reviews = reviewRepository.findAll(pageable); + + return reviews.map(review -> new ReviewResponseDto(review, review.getRestaurant())); + } + + Page reviews = reviewRepository.findAllWithKeyword(pageable, keyword); + + return reviews.map(review -> new ReviewResponseDto(review, review.getRestaurant())); + } + + public ReviewResponseDto findById(long id) { + Review review = reviewRepository.findById(id).orElseThrow(); + + return new ReviewResponseDto(review, review.getRestaurant()); + } + + + public ReviewResponseDto patchById(long id, ViewUpdateRequestDto patchReviewReq) { + Review review = reviewRepository.findById(id).orElseThrow(); + + review.setTitle(patchReviewReq.getTitle()); + review.setDescription(patchReviewReq.getDescription()); + + reviewRepository.save(review); + + return new ReviewResponseDto(review, review.getRestaurant()); + } + + public void deleteById(long id) { + reviewRepository.deleteById(id); + } +} \ No newline at end of file diff --git a/goodnight/src/main/java/com/techeer/goodnight/global/config/JpaAuditingConfig.java b/goodnight/src/main/java/com/techeer/goodnight/global/config/JpaAuditingConfig.java new file mode 100644 index 00000000..9ac3300b --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnight/global/config/JpaAuditingConfig.java @@ -0,0 +1,9 @@ +package com.techeer.goodnight.global.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.data.jpa.repository.config.EnableJpaAuditing; + +@EnableJpaAuditing +@Configuration +public class JpaAuditingConfig { +} \ No newline at end of file diff --git a/goodnight/src/main/java/com/techeer/goodnight/global/domain/BaseEntity.java b/goodnight/src/main/java/com/techeer/goodnight/global/domain/BaseEntity.java new file mode 100644 index 00000000..993448d9 --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnight/global/domain/BaseEntity.java @@ -0,0 +1,29 @@ +package com.techeer.goodnight.global.domain; + +import java.time.LocalDateTime; +import javax.persistence.Column; +import javax.persistence.EntityListeners; +import javax.persistence.MappedSuperclass; +import lombok.Getter; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +@Getter +@MappedSuperclass +@EntityListeners(AuditingEntityListener.class) +public class BaseEntity { + + @CreatedDate + @Column(updatable = false) + private LocalDateTime createdAt; + + @LastModifiedDate + private LocalDateTime updatedAt; + + protected LocalDateTime deletedAt; + + @Column() + protected boolean isDeleted; + +} \ No newline at end of file diff --git a/goodnight/src/main/java/com/techeer/goodnight/global/exception/ErrorCode.java b/goodnight/src/main/java/com/techeer/goodnight/global/exception/ErrorCode.java new file mode 100644 index 00000000..f3febecc --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnight/global/exception/ErrorCode.java @@ -0,0 +1,28 @@ +package com.techeer.goodnight.global.exception; + +import lombok.Getter; + +@Getter +public enum ErrorCode { + + /* 예시 */ + NO_DATA_IN_DB(-1, "데이터베이스에 값이 존재하지 않습니다."), + OMISSION_REQUIRE_PARAM(-2, "request 파라미터가 누락되었습니다."), + + /* 레스토랑 */ + RESTAURANT_ID_NOT_FOUND(-200, "존재하지 않는 restaurant 입니다."), + + /* 리뷰 */ + ORDER_REVIEW_ALREADY_EXISTS(-600, "요청 주문에 대한 리뷰가 이미 존재합니다."), + USER_REVIEW_NOT_FOUND(-601, "요청 유저가 작성한 리뷰가 존재하지 않습니다."),; + + + private final int code; + private final String message; + + ErrorCode(int code, String message) { + this.code = code; + this.message = message; + } + +} \ No newline at end of file diff --git a/goodnight/src/main/java/com/techeer/goodnight/global/exception/GlobalExceptionHandler.java b/goodnight/src/main/java/com/techeer/goodnight/global/exception/GlobalExceptionHandler.java new file mode 100644 index 00000000..b9162540 --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnight/global/exception/GlobalExceptionHandler.java @@ -0,0 +1,33 @@ +package com.techeer.goodnight.global.exception; + +import com.techeer.goodnight.global.exception.global.BadRequestException; +import com.techeer.goodnight.global.exception.global.NoDataException; +import com.techeer.goodnight.global.response.ErrorResponse; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +@Slf4j +@RestControllerAdvice +public class GlobalExceptionHandler { + + // ExceptionHandler 어노테이션을 사용, 전역에서 Exception을 핸들링할 수 있게 처리합니다. + @ResponseStatus(value = HttpStatus.BAD_REQUEST) + @ExceptionHandler(BadRequestException.class) + public ErrorResponse handleBadRequestException(BadRequestException ex) { + // exception throw가 발생할 경우 log를 납깁니다. + log.info("request param omission exception", ex); + return new ErrorResponse(ex.getErrorCode()); + } + + @ResponseStatus(value = HttpStatus.NOT_FOUND) + @ExceptionHandler(NoDataException.class) + public ErrorResponse handleNotFoundException(NoDataException ex) { + // exception throw가 발생할 경우 log를 납깁니다. + log.info("not found data exception", ex); + return new ErrorResponse(ex.getErrorCode()); + } + +} \ No newline at end of file diff --git a/goodnight/src/main/java/com/techeer/goodnight/global/exception/global/BadRequestException.java b/goodnight/src/main/java/com/techeer/goodnight/global/exception/global/BadRequestException.java new file mode 100644 index 00000000..48b73aac --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnight/global/exception/global/BadRequestException.java @@ -0,0 +1,12 @@ +package com.techeer.goodnight.global.exception.global; + +import com.techeer.goodnight.global.exception.ErrorCode; +import lombok.Getter; + +@Getter +public class BadRequestException extends RuntimeException { + + private final ErrorCode errorCode; + + public BadRequestException() { this.errorCode = ErrorCode.OMISSION_REQUIRE_PARAM; } +} \ No newline at end of file diff --git a/goodnight/src/main/java/com/techeer/goodnight/global/exception/global/NoDataException.java b/goodnight/src/main/java/com/techeer/goodnight/global/exception/global/NoDataException.java new file mode 100644 index 00000000..a9afdce2 --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnight/global/exception/global/NoDataException.java @@ -0,0 +1,12 @@ +package com.techeer.goodnight.global.exception.global; +import com.techeer.goodnight.global.exception.ErrorCode; +import lombok.Getter; + +@Getter +public class NoDataException extends RuntimeException { + + private final ErrorCode errorCode; + + public NoDataException() { this.errorCode = ErrorCode.NO_DATA_IN_DB; } + +} \ No newline at end of file diff --git a/goodnight/src/main/java/com/techeer/goodnight/global/response/ErrorResponse.java b/goodnight/src/main/java/com/techeer/goodnight/global/response/ErrorResponse.java new file mode 100644 index 00000000..182546a5 --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnight/global/response/ErrorResponse.java @@ -0,0 +1,17 @@ +package com.techeer.goodnight.global.response; +import com.techeer.goodnight.global.exception.ErrorCode; +import lombok.Builder; +import lombok.Getter; + +@Getter +public class ErrorResponse { + + private int code; + private String message; + + @Builder + public ErrorResponse(ErrorCode errorStatus) { + this.code = errorStatus.getCode(); + this.message = errorStatus.getMessage(); + } +} \ No newline at end of file diff --git a/goodnight/src/main/resources/application.yml b/goodnight/src/main/resources/application.yml new file mode 100644 index 00000000..01ced844 --- /dev/null +++ b/goodnight/src/main/resources/application.yml @@ -0,0 +1,21 @@ +spring.datasource: + username: user + password: password + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:${db.type}://${db.host}:${db.port}/${db.database}?serverTimezone=${db.timezone}&characterEncoding=UTF-8 + +db.type: mysql +db.host: localhost +db.port: 33080 +db.database: good-night-dev-db +db.timezone: Asia/Seoul + +spring.jpa: + database: mysql + show-sql: false + hibernate: + dialect: org.hibernate.dialect.MySQL57InnoDBDialect + ddl-auto: create # must change to update, create make table all clear + +server: + port: 8000 \ No newline at end of file diff --git a/goodnight/src/test/java/com/techeer/goodnight/GoodnightApplicationTests.java b/goodnight/src/test/java/com/techeer/goodnight/GoodnightApplicationTests.java new file mode 100644 index 00000000..2d3b7b91 --- /dev/null +++ b/goodnight/src/test/java/com/techeer/goodnight/GoodnightApplicationTests.java @@ -0,0 +1,13 @@ +package com.techeer.goodnight; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class GoodnightApplicationTests { + + @Test + void contextLoads() { + } + +}