diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..7006bd91 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ + +goodnight/src/main/.DS_Store + +goodnight/src/main/java/.DS_Store + +goodnight/src/main/java/com/.DS_Store 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..1d79d3dc --- /dev/null +++ b/goodnight/build.gradle @@ -0,0 +1,32 @@ +plugins { + id 'java' + id 'org.springframework.boot' version '2.7.9' + id 'io.spring.dependency-management' version '1.0.15.RELEASE' +} + +group = 'com.example' +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-web' + compileOnly 'org.projectlombok:lombok' + runtimeOnly 'com.h2database:h2' + annotationProcessor 'org.projectlombok:lombok' + testImplementation 'org.springframework.boot:spring-boot-starter-test' +} + +tasks.named('test') { + useJUnitPlatform() +} 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/goodnighthackathonspringboot/GoodNightHackathonSpringBootApplication.java b/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/GoodNightHackathonSpringBootApplication.java new file mode 100644 index 00000000..1ce71def --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/GoodNightHackathonSpringBootApplication.java @@ -0,0 +1,13 @@ +package com.techeer.goodnighthackathonspringboot; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class GoodNightHackathonSpringBootApplication { + + public static void main(String[] args) { + SpringApplication.run(GoodNightHackathonSpringBootApplication.class, args); + } + +} diff --git a/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/hello/controller/HelloController.java b/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/hello/controller/HelloController.java new file mode 100644 index 00000000..1215b484 --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/hello/controller/HelloController.java @@ -0,0 +1,27 @@ +package com.techeer.goodnighthackathonspringboot.domain.hello.controller; + +import com.techeer.goodnighthackathonspringboot.domain.hello.dto.HelloDto; +import com.techeer.goodnighthackathonspringboot.domain.hello.service.HelloService; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping("/api/v1/hello") +@RequiredArgsConstructor +public class HelloController { + private final HelloService helloService; + + @PostMapping // @RequestMapping("/api/v1/hello") 를 post 로 보내면 실행 + public HelloDto create(@RequestBody HelloDto dto){ + return helloService.create(dto); + } + @DeleteMapping + public void delete(@RequestBody HelloDto dto){ + helloService.delete(dto); //url로 deletemethod 면 실행 + } + @GetMapping + public String test(){ + return "TEST"; //url로 getmethod 면 실행 + } + +} diff --git a/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/hello/domain/entity/Hello.java b/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/hello/domain/entity/Hello.java new file mode 100644 index 00000000..0ac6ffce --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/hello/domain/entity/Hello.java @@ -0,0 +1,21 @@ +package com.techeer.goodnighthackathonspringboot.domain.hello.domain.entity; + +import lombok.*; + +import javax.persistence.*; + +@Entity +@Getter +@Builder +@AllArgsConstructor +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Table(name = "hello") +public class Hello { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + private Long id; + + @Column(name = "contents") + private String contents; +} diff --git a/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/hello/domain/repository/HelloRepository.java b/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/hello/domain/repository/HelloRepository.java new file mode 100644 index 00000000..ac1b049b --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/hello/domain/repository/HelloRepository.java @@ -0,0 +1,12 @@ +package com.techeer.goodnighthackathonspringboot.domain.hello.domain.repository; + +import com.techeer.goodnighthackathonspringboot.domain.hello.domain.entity.Hello; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.Optional; + +public interface HelloRepository extends JpaRepository { + Optional findById(Long id); //sql문 만들어짐 + void deleteById(Long id); + +} diff --git a/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/hello/dto/HelloDto.java b/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/hello/dto/HelloDto.java new file mode 100644 index 00000000..8a29e973 --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/hello/dto/HelloDto.java @@ -0,0 +1,13 @@ +package com.techeer.goodnighthackathonspringboot.domain.hello.dto; + +import lombok.Builder; +import lombok.Getter; + +@Builder +@Getter +public class HelloDto { + private Long id; + private String contents; + + // setter = public void update(){} +} diff --git a/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/hello/service/HelloService.java b/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/hello/service/HelloService.java new file mode 100644 index 00000000..ff3a7b3f --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/hello/service/HelloService.java @@ -0,0 +1,24 @@ +package com.techeer.goodnighthackathonspringboot.domain.hello.service; + +import com.techeer.goodnighthackathonspringboot.domain.hello.domain.entity.Hello; +import com.techeer.goodnighthackathonspringboot.domain.hello.domain.repository.HelloRepository; +import com.techeer.goodnighthackathonspringboot.domain.hello.dto.HelloDto; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class HelloService { + private final HelloRepository helloRepository; + public HelloDto create(HelloDto dto){ + String contents = dto.getContents(); + Hello entity = Hello.builder() + .contents(contents) + .build(); + helloRepository.save(entity); + return HelloDto.builder().build().id(savedEntity.getId()).contents(); + } + public HelloDto delete(HelloDto dto){ + helloRepository.deleteById(dto.getId()); + } +} diff --git a/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/restaurant/controller/RestaurantController.java b/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/restaurant/controller/RestaurantController.java new file mode 100644 index 00000000..c61a2b30 --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/restaurant/controller/RestaurantController.java @@ -0,0 +1,28 @@ +package com.techeer.goodnighthackathonspringboot.domain.restaurant.controller; + + +import com.techeer.goodnighthackathonspringboot.domain.restaurant.service.RestaurantService; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RequestMapping("/api/v1/restaurant") +@RestController +@RequiredArgsConstructor +public class RestaurantController { + private final RestaurantService restaurantService; + + @DeleteMapping("/{id}") + public ResponseEntity delete(@PathVariable Long id) { + restaurantService.delete(id); + return ResponseEntity + .noContent() + .build(); + } + + + +} diff --git a/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/restaurant/dto/RestaurantCreateRequest.java b/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/restaurant/dto/RestaurantCreateRequest.java new file mode 100644 index 00000000..01228172 --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/restaurant/dto/RestaurantCreateRequest.java @@ -0,0 +1,21 @@ +package com.techeer.goodnighthackathonspringboot.domain.restaurant.dto; + +import jdk.jfr.Category; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +import javax.validation.constraints.NotNull; + +@Builder +@AllArgsConstructor +@Getter +@RequiredArgsConstructor +public class RestaurantCreateRequest { + @NotNull(message = "레스토랑 이름은 필수입니다.") + private String name; + @NotNull(message = "레스토랑 카테고리는 필수입니다.") + private Category category; + +} diff --git a/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/restaurant/dto/RestaurantDto.java b/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/restaurant/dto/RestaurantDto.java new file mode 100644 index 00000000..8af70ade --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/restaurant/dto/RestaurantDto.java @@ -0,0 +1,14 @@ +package com.techeer.goodnighthackathonspringboot.domain.restaurant.dto; + +import jdk.jfr.Category; +import lombok.Builder; +import lombok.Getter; + +import java.util.Date; + +@Builder +@Getter +public class RestaurantDto { + private String storename; + private String category; +} diff --git a/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/restaurant/dto/RestaurantInfo.java b/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/restaurant/dto/RestaurantInfo.java new file mode 100644 index 00000000..8dd89586 --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/restaurant/dto/RestaurantInfo.java @@ -0,0 +1,14 @@ +package com.techeer.goodnighthackathonspringboot.domain.restaurant.dto; + + +import com.techeer.goodnighthackathonspringboot.domain.restaurant.entity.RestaurantCategory; +import lombok.*; + +@Getter +@Builder +@AllArgsConstructor +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public class RestaurantInfo { + private String name; + private RestaurantCategory category; +} diff --git a/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/restaurant/entity/Restaurant.java b/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/restaurant/entity/Restaurant.java new file mode 100644 index 00000000..4cabc5d1 --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/restaurant/entity/Restaurant.java @@ -0,0 +1,37 @@ +package com.techeer.goodnighthackathonspringboot.domain.restaurant.entity; + +import com.techeer.goodnighthackathonspringboot.global.domain.BaseEntity; +import jdk.jfr.Category; +import lombok.*; + +import javax.persistence.*; + +@Entity +@Getter +@AllArgsConstructor +@NoArgsConstructor(access= AccessLevel.PROTECTED) +@Table(name = "restaurant") +public class Restaurant extends BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "name") + private String name; + + @Column(name = "category") + @Enumerated(EnumType.STRING) + private Category category; + + @Builder + public Restaurant(String name, Category category){ + this.name = name; + this.category = category; + } + + public void delete(){ + this.activeOff(); + } + +} diff --git a/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/restaurant/entity/RestaurantCategory.java b/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/restaurant/entity/RestaurantCategory.java new file mode 100644 index 00000000..453fa1cc --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/restaurant/entity/RestaurantCategory.java @@ -0,0 +1,7 @@ +package com.techeer.goodnighthackathonspringboot.domain.restaurant.entity; + +public enum RestaurantCategory { + 한식, + 중식, + 일식, +} diff --git a/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/restaurant/repository/RestaurantRepository.java b/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/restaurant/repository/RestaurantRepository.java new file mode 100644 index 00000000..3904b09c --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/restaurant/repository/RestaurantRepository.java @@ -0,0 +1,8 @@ +package com.techeer.goodnighthackathonspringboot.domain.restaurant.repository; + + +import com.techeer.goodnighthackathonspringboot.domain.restaurant.entity.Restaurant; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface RestaurantRepository extends JpaRepository { +} diff --git a/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/restaurant/service/RestaurantService.java b/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/restaurant/service/RestaurantService.java new file mode 100644 index 00000000..8be2d406 --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/restaurant/service/RestaurantService.java @@ -0,0 +1,33 @@ +package com.techeer.goodnighthackathonspringboot.domain.restaurant.service; + +import com.techeer.goodnighthackathonspringboot.domain.restaurant.dto.RestaurantCreateRequest; +import com.techeer.goodnighthackathonspringboot.domain.restaurant.entity.Restaurant; +import com.techeer.goodnighthackathonspringboot.domain.restaurant.repository.RestaurantRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import javax.transaction.Transactional; + +@Service +@RequiredArgsConstructor +@Transactional +public class RestaurantService { + private final RestaurantRepository restaurantRepository; + //등록 - 삭제 + + public void create(RestaurantCreateRequest restaurantCreateRequest) { + Restaurant restaurant = mapRestaurantEntityToRestaurantInfo(restaurantCreateRequest); + restaurantRepository.save(restaurant); + } + public Restaurant mapRestaurantEntityToRestaurantInfo(RestaurantCreateRequest restaurantCreateRequest) { + return Restaurant.builder() + .name(restaurantCreateRequest.getName()) + .category(restaurantCreateRequest.getCategory()) + .build(); + } + + public void delete(Long id){ + restaurantRepository.deleteById(id); + } + +} diff --git a/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/review/dto/ReviewDto.java b/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/review/dto/ReviewDto.java new file mode 100644 index 00000000..39da0157 --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/domain/review/dto/ReviewDto.java @@ -0,0 +1,13 @@ +package com.techeer.goodnighthackathonspringboot.domain.review.dto; + +import lombok.Builder; +import lombok.Getter; + +@Builder +@Getter +public class ReviewDto { + private String storeName; + private String reviewName; + private String reviewContent; + +} diff --git a/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/global/config/JpaAuditingConfig.java b/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/global/config/JpaAuditingConfig.java new file mode 100644 index 00000000..a2aa8c6b --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/global/config/JpaAuditingConfig.java @@ -0,0 +1,9 @@ +package com.techeer.goodnighthackathonspringboot.global.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.data.jpa.repository.config.EnableJpaAuditing; + +@EnableJpaAuditing +@Configuration +public class JpaAuditingConfig { +} diff --git a/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/global/domain/BaseEntity.java b/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/global/domain/BaseEntity.java new file mode 100644 index 00000000..34af7946 --- /dev/null +++ b/goodnight/src/main/java/com/techeer/goodnighthackathonspringboot/global/domain/BaseEntity.java @@ -0,0 +1,29 @@ +package com.techeer.goodnighthackathonspringboot.global.domain; + +import lombok.Getter; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +import javax.persistence.Column; +import javax.persistence.EntityListeners; +import javax.persistence.MappedSuperclass; +import java.time.LocalDateTime; + +@Getter +@MappedSuperclass +@EntityListeners(AuditingEntityListener.class) +public abstract class BaseEntity { + @CreatedDate + private LocalDateTime createOn; + + @LastModifiedDate + private LocalDateTime updateOn; + + @Column(name = "is_activated", nullable = false) + protected boolean isActivated; + + public void activeOff(){ + this.isActivated = false; + } +} diff --git a/goodnight/src/main/resources/application.properties b/goodnight/src/main/resources/application.properties new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/goodnight/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/goodnight/src/test/java/com/example/goodnight/GoodnightApplicationTests.java b/goodnight/src/test/java/com/example/goodnight/GoodnightApplicationTests.java new file mode 100644 index 00000000..636d278e --- /dev/null +++ b/goodnight/src/test/java/com/example/goodnight/GoodnightApplicationTests.java @@ -0,0 +1,13 @@ +package com.example.goodnight; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class GoodnightApplicationTests { + + @Test + void contextLoads() { + } + +}