-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BE][Team09][Bat & Pyro] API 를 JDBC 와 연동 #59
base: ghojeong
Are you sure you want to change the base?
Changes from all commits
f1ae674
cb11c76
f307e56
01cdef4
6650342
f8654db
5de75e1
42f75af
9061ab7
71719dd
f41a420
9d33a4e
59f8f50
2371a00
2d4c4c0
a544477
a779680
4172f10
f3d5fb3
de90a33
07e69c4
997048b
95c6ff6
8452983
96d1d2e
7719658
4db8370
c2f0380
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
#Tue Apr 20 01:45:16 KST 2021 | ||
gradle.version=6.8.3 | ||
#Thu Apr 29 14:48:25 KST 2021 | ||
gradle.version=7.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,89 @@ | ||
@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%" == "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%"=="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! | ||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 | ||
exit /b 1 | ||
|
||
:mainEnd | ||
if "%OS%"=="Windows_NT" endlocal | ||
|
||
:omega | ||
@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%" == "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%"=="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! | ||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 | ||
exit /b 1 | ||
:mainEnd | ||
if "%OS%"=="Windows_NT" endlocal | ||
:omega |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,10 +7,7 @@ | |
import io.swagger.annotations.ApiOperation; | ||
import io.swagger.annotations.ApiParam; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
|
@@ -53,24 +50,34 @@ public ResponseEntity<QuantityDto> getDetailQuantity(@ApiParam("요리의 식별 | |
return ResponseEntity.ok().body(quantityDto); | ||
} | ||
|
||
@PatchMapping("/detail/{detailHash}/{count}") | ||
@ApiOperation(value = "주문하기", notes = "주문하기") | ||
public ResponseEntity<String> orderDish(@ApiParam("요리의 식별자") @PathVariable("detailHash") String detailHash, @PathVariable("count") int count) { | ||
if (dishService.order(detailHash, count)) { | ||
return ResponseEntity.ok().body("주문완료"); | ||
} | ||
return ResponseEntity.ok().body("주문불가"); | ||
} | ||
|
||
@GetMapping("/main") | ||
@ApiOperation(value = "메인 요리", notes = "메인 요리의 목록을 반환합니다.") | ||
public ResponseEntity<List<DishDto>> getMainList() { | ||
List<DishDto> dishes = dishService.getList(1); | ||
List<DishDto> dishes = dishService.getList(1L); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이것도 enum 으로 main 과 1L 상수를 하나로 묶는게 좋겠군요. |
||
return ResponseEntity.ok().body(dishes); | ||
} | ||
|
||
@GetMapping("/soup") | ||
@ApiOperation(value = "국물 요리", notes = "국물 요리의 목록을 반환합니다.") | ||
public ResponseEntity<List<DishDto>> getSoupList() { | ||
List<DishDto> dishes = dishService.getList(2L); | ||
return ResponseEntity.ok().body(dishes); | ||
} | ||
|
||
@GetMapping("/side") | ||
@ApiOperation(value = "반찬 요리", notes = "반찬 요리의 목록을 반환합니다.") | ||
public ResponseEntity<List<DishDto>> getSideList() { | ||
List<DishDto> dishes = dishService.getList(3); | ||
List<DishDto> dishes = dishService.getList(3L); | ||
return ResponseEntity.ok().body(dishes); | ||
} | ||
|
||
@GetMapping("/soup") | ||
@ApiOperation(value = "국물 요리", notes = "국물 요리의 목록을 반환합니다.") | ||
public ResponseEntity<List<DishDto>> getSoupList() { | ||
List<DishDto> dishes = dishService.getList(2); | ||
return ResponseEntity.ok().body(dishes); | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
package com.codesquad.sidedish.SideDish.domain; | ||
|
||
import org.springframework.data.jdbc.repository.query.Query; | ||
import org.springframework.data.repository.CrudRepository; | ||
|
||
import java.util.List; | ||
|
||
public interface CategoryRepository { | ||
public interface CategoryRepository extends CrudRepository<Category, Long> { | ||
@Override | ||
@Query("SELECT * from sidedish.category") | ||
List<Category> findAll(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.codesquad.sidedish.SideDish.domain; | ||
|
||
import java.util.Objects; | ||
|
||
public class Delivery { | ||
private String deliveryType; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. type 이라면, enum 으로 만들어서 관리하는 편이 훨씬 좋겠군요. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'deliveryType',' imageType' 그리고 sale에서 'Badge' 모두 enum으로 관리하면 더 좋았을 것 같습니다. |
||
|
||
public Delivery(String deliveryType) { | ||
this.deliveryType = deliveryType; | ||
} | ||
|
||
public String getDeliveryType() { | ||
return deliveryType; | ||
} | ||
|
||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
Delivery delivery = (Delivery) o; | ||
return Objects.equals(deliveryType, delivery.deliveryType); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(deliveryType); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dishService.order()
의 리턴 타입이 스트링이었으면 코드가 조금 더 간결해졌겠네요.같은 메소드를 소비하는 다른 소비처가 있나요? 그리고 그곳이
boolean
타입 리턴을 필요로 하나요?그렇지 않다면, 서비스에서 바로 스트링을 내리는 구현도 좋을 것 같습니다.
다만 지금은 주문의 상태에 관한, 그러니까 경우의 수 를 다루는 메소드이므로
enum
을 사용하기에 아주 적절한 상황으로 보입니다.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enum 을 더 적극적으로 사용해보도록 하겠습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enum 생각을 하지 못하고 개발하였습니다....
image 구분할 때도 enum으로 했으면 더 좋았을 것 같습니다.
감사합니다.