diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..6722b1e7a --- /dev/null +++ b/.gitignore @@ -0,0 +1,295 @@ + +# Created by https://www.toptal.com/developers/gitignore/api/swift,xcode,java,intellij,gradle,vscode +# Edit at https://www.toptal.com/developers/gitignore?templates=swift,xcode,java,intellij,gradle,vscode + +### Intellij ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### Intellij Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +# https://plugins.jetbrains.com/plugin/7973-sonarlint +.idea/**/sonarlint/ + +# SonarQube Plugin +# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator-enh.xml +.idea/**/markdown-navigator/ + +# Cache file creation bug +# See https://youtrack.jetbrains.com/issue/JBR-2257 +.idea/$CACHE_FILE$ + +# CodeStream plugin +# https://plugins.jetbrains.com/plugin/12206-codestream +.idea/codestream.xml + +### Java ### +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +### Swift ### +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## User settings +xcuserdata/ + +## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) +*.xcscmblueprint +*.xccheckout + +## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) +build/ +DerivedData/ +*.moved-aside +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 + +## Obj-C/Swift specific +*.hmap + +## App packaging +*.ipa +*.dSYM.zip +*.dSYM + +## Playgrounds +timeline.xctimeline +playground.xcworkspace + +# Swift Package Manager +# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. +# Packages/ +# Package.pins +# Package.resolved +# *.xcodeproj +# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata +# hence it is not needed unless you have added a package configuration file to your project +# .swiftpm + +.build/ + +# CocoaPods +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# Pods/ +# Add this line if you want to avoid checking in source code from the Xcode workspace +# *.xcworkspace + +# Carthage +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build/ + +# Add this lines if you are using Accio dependency management (Deprecated since Xcode 12) +# Dependencies/ +# .accio/ + +# fastlane +# It is recommended to not store the screenshots in the git repo. +# Instead, use fastlane to re-generate the screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/#source-control + +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots/**/*.png +fastlane/test_output + +# Code Injection +# After new code Injection tools there's a generated folder /iOSInjectionProject +# https://github.com/johnno1962/injectionforxcode + +iOSInjectionProject/ + +### vscode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +### Xcode ### +# Xcode +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + + + + +## Gcc Patch +/*.gcno + +### Xcode Patch ### +*.xcodeproj/* +!*.xcodeproj/project.pbxproj +!*.xcodeproj/xcshareddata/ +!*.xcworkspace/contents.xcworkspacedata +**/xcshareddata/WorkspaceSettings.xcsettings + +### Gradle ### +.gradle + +# Ignore Gradle GUI config +gradle-app.setting + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar + +# Cache of project +.gradletasknamecache + +# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 +# gradle/wrapper/gradle-wrapper.properties + +### Gradle Patch ### +**/build/ + + +# Created by https://www.toptal.com/developers/gitignore/api/osx +# Edit at https://www.toptal.com/developers/gitignore?templates=osx + +### OSX ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# End of https://www.toptal.com/developers/gitignore/api/osx + +# End of https://www.toptal.com/developers/gitignore/api/swift,xcode,java,intellij,gradle,vscode diff --git a/BE_baseball/.gitignore b/BE_baseball/.gitignore new file mode 100644 index 000000000..a3386a750 --- /dev/null +++ b/BE_baseball/.gitignore @@ -0,0 +1,43 @@ +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/ + + +## logfiles +/logs/ +*.gz +*.log diff --git a/BE_baseball/BE_ReadME.md b/BE_baseball/BE_ReadME.md new file mode 100644 index 000000000..6962f34ef --- /dev/null +++ b/BE_baseball/BE_ReadME.md @@ -0,0 +1,70 @@ +# 테크니컬 첼린지 포인트 +## Oauth 구현하기 + - github 페이지와 ouath인증 진행하기 + - Spring security는 사용하지 않는다. + - 어려운 경우 >> Oauth를 별도 라이브러리로 구현하고 baseball 프로젝트에 통합 적용해 본다. + +## admin tool 제작 + - 게임 운영에 필요한 도구들을 모아놓은 admin tool을 별도 웹으로 구현한다. + - admin 도구는 프론트 및 백엔드 모두 백엔드에서 직접 구현한다. + - admin 사용자 인증은 hard coding으로 최대한 간단히 구현한다. admin email 주소를 설정에 포함할 것 + - 내생각 + - admin@dong.com / javaking >> 요런느낌으로 가자 + - 게임 운영에 필요한 도구들 + - 모든 데이터베이스 조회 + - 프론엔드 백엔드 다 구현해버리기 + +## VPC 학습 + - 웹서버와 데이터베이스는 다른컴퓨터로 쓰기!! + - EC2 두대로 각각 웹서버와, DB서버 두대 돌려 생성 + - 혹은 데이터베이스는 RDS로 쓰고, 웹서버 EC2 쓰는 구조 + - 22,80 포트 제외하고 다 닫기 + - 3306이나 8080은 포트 열려있는거 자체가 보안 취약점이니까 꼭 닫아놓기 + - 엔진엑스랑 연결되는거니까 다음항목을 봐라 + +## Nginx + - 프론트 배포는 NginX를 설정해서 사용한다. 프론트는 80포트에서 동작 + - NginX와 tomcat을 연동하고 80포트만 외부에 개방 + - 8080 포트는 외부에 개방하지마라 + - 그러니까 쉽게말해서 프론트사이드 + + +## 커밋 메시지 규칙 +> 원문 : http://karma-runner.github.io/5.0/dev/git-commit-msg.html + +- feat (new feature for the user, not a new feature for build script) +- fix (bug fix for the user, not a fix to a build script) +- docs (changes to the documentation) +- style (formatting, missing semi colons, etc; no production code change) +- refactor (refactoring production code, eg. renaming a variable) +- test (adding missing tests, refactoring tests; no production code change) +- chore (updating grunt tasks etc; no production code change) + + + +## 앞으로 더 구현할 기능 +### 데이터 입력받기 기능 + - ios / 데이터 입력받기 : 볼 , 스트라이크, 아웃, @@@@ +### api 문서화 어떻게 쓰는지에 대하여 + - 보기 편하시도록, 실서버에서 돌아가는거 +### 관리자 페이지 제공해서 시뮬레이션 해보실수 있도록??(옵션) + - 이거는 버리는옵션, 일단 백엔드 우선으로 돌리자 +### 팀 데이터(랭킹데이터) 제이슨으로 리턴되고, 승점순으로 정렬되 + - 승점순으로 정렬해서 제이슨으로 리턴해드리기 + - 지금은 축구룰 승점 적용(승리*3 + 비김*1)이지만, 나중에 야구룰 적용할지는 미지수 +### 상세보기 페이지 + - 뭐에대한 상세보기였지..? +### 오어쓰 기능구현 + - Oauth 2.0 생활코딩 강의 필기(낮은 우선순위) + - 하게된다면 이런 이슈는 있다 >> 옥토캣 라이브러리 사용한다(iOS분들) +### 1루 2루 3루 홈 누가있는지 리스트로 관리하기 + - 이부분 추가해야되요!! +


+# ios 사이드 요청사항 반영할꺼 +### 1 최신순으로 맨 위에 올라오게 >> 지금 경기상황 +- 경기상황 +### 2 스코어 화면 +- 편하게 띄워줄수 있도록 DTO 작성 +


+# 나의마인드셋 +- 언제든 불편한거 말씀하시면 99.8% 정도는 맞춰드리겠습니다!! diff --git a/BE_baseball/build.gradle b/BE_baseball/build.gradle new file mode 100644 index 000000000..e80dbff9f --- /dev/null +++ b/BE_baseball/build.gradle @@ -0,0 +1,25 @@ +plugins { + id 'org.springframework.boot' version '2.4.5' + id 'io.spring.dependency-management' version '1.0.11.RELEASE' + id 'java' +} + +group = 'com.dong' +version = '0.0.1-SNAPSHOT' +sourceCompatibility = '1.8' + +repositories { + mavenCentral() +} + +dependencies { + implementation 'org.springframework.boot:spring-boot-starter-data-jdbc' + implementation 'org.springframework.boot:spring-boot-starter-web' + developmentOnly 'org.springframework.boot:spring-boot-devtools' + runtimeOnly 'mysql:mysql-connector-java' + testImplementation('org.springframework.boot:spring-boot-starter-test') +} + +test { + useJUnitPlatform() +} diff --git a/BE_baseball/gradle/wrapper/gradle-wrapper.jar b/BE_baseball/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000..e708b1c02 Binary files /dev/null and b/BE_baseball/gradle/wrapper/gradle-wrapper.jar differ diff --git a/BE_baseball/gradle/wrapper/gradle-wrapper.properties b/BE_baseball/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..442d9132e --- /dev/null +++ b/BE_baseball/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/BE_baseball/gradlew b/BE_baseball/gradlew new file mode 100755 index 000000000..4f906e0c8 --- /dev/null +++ b/BE_baseball/gradlew @@ -0,0 +1,185 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or 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 UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$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 "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# 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 + ;; + 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" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/BE_baseball/gradlew.bat b/BE_baseball/gradlew.bat new file mode 100644 index 000000000..107acd32c --- /dev/null +++ b/BE_baseball/gradlew.bat @@ -0,0 +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 diff --git a/BE_baseball/settings.gradle b/BE_baseball/settings.gradle new file mode 100644 index 000000000..c1cccd8ee --- /dev/null +++ b/BE_baseball/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'baseball' diff --git a/BE_baseball/src/main/java/com/dong/baseball/BaseballApplication.java b/BE_baseball/src/main/java/com/dong/baseball/BaseballApplication.java new file mode 100644 index 000000000..d75d056d3 --- /dev/null +++ b/BE_baseball/src/main/java/com/dong/baseball/BaseballApplication.java @@ -0,0 +1,13 @@ +package com.dong.baseball; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class BaseballApplication { + + public static void main(String[] args) { + SpringApplication.run(BaseballApplication.class, args); + } + +} diff --git a/BE_baseball/src/main/java/com/dong/baseball/Controller/GameController.java b/BE_baseball/src/main/java/com/dong/baseball/Controller/GameController.java new file mode 100644 index 000000000..35fdaf4bf --- /dev/null +++ b/BE_baseball/src/main/java/com/dong/baseball/Controller/GameController.java @@ -0,0 +1,58 @@ +package com.dong.baseball.Controller; + +import com.dong.baseball.DTO.BaseballServerResponseDTO; +import com.dong.baseball.DTO.MatchAllProgressDataDTO; +import com.dong.baseball.DTO.MatchUpListsDTO; +import com.dong.baseball.DTO.ProgressDTO; +import com.dong.baseball.Service.GameService; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping("/games") +public class GameController { + + + private final GameService gameService; + + public GameController(GameService gameService) { + this.gameService = gameService; + } + + @GetMapping("") + public MatchUpListsDTO allMatches() { + return gameService.matchList(); + } + + @GetMapping("/{matchId}") + public MatchAllProgressDataDTO matchInfos(@PathVariable Long matchId) { + return new MatchAllProgressDataDTO(gameService.findMatch(matchId), gameService.matchInformations(matchId)); + } + + @GetMapping("/{matchId}/offense") + public ProgressDTO offeseInfo(@PathVariable Long matchId) { + gameService.matchInformations(matchId); + return new ProgressDTO(gameService.matchSingleInfo(matchId)); + } + + @GetMapping("/{matchId}/defense") + public ProgressDTO defenseInfo(@PathVariable Long matchId) { + + gameService.matchInformations(matchId); + return new ProgressDTO(gameService.matchSingleInfo(matchId)); + } + + @PostMapping("/{matchId}/start") + public BaseballServerResponseDTO gameStart(@PathVariable Long matchId) { + return gameService.gameStart(matchId); + } + + @PostMapping("/{matchId}/end") + public BaseballServerResponseDTO gameEnd(@PathVariable Long matchId) { + return gameService.gameEnd(matchId); + } + + @PostMapping("/{matchId}/throws") + public BaseballServerResponseDTO gameProgress(@PathVariable Long matchId) { + return gameService.gameProgress(matchId); + } +} diff --git a/BE_baseball/src/main/java/com/dong/baseball/Controller/TeamController.java b/BE_baseball/src/main/java/com/dong/baseball/Controller/TeamController.java new file mode 100644 index 000000000..2a9a40e66 --- /dev/null +++ b/BE_baseball/src/main/java/com/dong/baseball/Controller/TeamController.java @@ -0,0 +1,37 @@ +package com.dong.baseball.Controller; + +import com.dong.baseball.DTO.TeamRankDTO; +import com.dong.baseball.Domain.Team; +import com.dong.baseball.Service.TeamService; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@RestController +@RequestMapping("/teams") +public class TeamController { + + private final TeamService teamService; + + public TeamController(TeamService teamService) { + this.teamService = teamService; + } + + @GetMapping + public List teamRanking() { + return teamService.teamRanking(); + } + + @GetMapping("/num/{teamId}") + public Team teamInfoById(@PathVariable Long teamId) { + return teamService.teamInfoById(teamId); + } + + @GetMapping("/{teamName}") + public Team teamInfoByName(@PathVariable String teamName) { + return teamService.teamInfoByName(teamName); + } +} diff --git a/BE_baseball/src/main/java/com/dong/baseball/DTO/BaseballServerResponseDTO.java b/BE_baseball/src/main/java/com/dong/baseball/DTO/BaseballServerResponseDTO.java new file mode 100644 index 000000000..54a3de1da --- /dev/null +++ b/BE_baseball/src/main/java/com/dong/baseball/DTO/BaseballServerResponseDTO.java @@ -0,0 +1,46 @@ +package com.dong.baseball.DTO; + +public class BaseballServerResponseDTO { + private int code; + private String status; + private String explanation; + + public BaseballServerResponseDTO() { + this.code = 200; + this.status = "OK"; + this.explanation = ""; + } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getExplanation() { + return explanation; + } + + public void setExplanation(String explanation) { + this.explanation = explanation; + } + + @Override + public String toString() { + return "ResponseDTO{" + + "code=" + code + + ", status='" + status + '\'' + + ", explanation='" + explanation + '\'' + + '}'; + } +} diff --git a/BE_baseball/src/main/java/com/dong/baseball/DTO/MatchAllProgressDataDTO.java b/BE_baseball/src/main/java/com/dong/baseball/DTO/MatchAllProgressDataDTO.java new file mode 100644 index 000000000..d96838b9a --- /dev/null +++ b/BE_baseball/src/main/java/com/dong/baseball/DTO/MatchAllProgressDataDTO.java @@ -0,0 +1,31 @@ +package com.dong.baseball.DTO; + +import java.util.List; + +public class MatchAllProgressDataDTO { + private MatchDTO matchInfomation; + private List progressInfoList; + + public MatchAllProgressDataDTO(MatchDTO matchInfomation, List progressInfoList) { + this.matchInfomation = matchInfomation; + this.progressInfoList = progressInfoList; + } + + public MatchDTO getMatchInfomation() { + return matchInfomation; + } + + public void setMatchInfomation(MatchDTO matchInfomation) { + this.matchInfomation = matchInfomation; + } + + public List getProgressInfoList() { + return progressInfoList; + } + + public void setProgressInfoList(List progressInfoList) { + this.progressInfoList = progressInfoList; + } + + +} diff --git a/BE_baseball/src/main/java/com/dong/baseball/DTO/MatchDTO.java b/BE_baseball/src/main/java/com/dong/baseball/DTO/MatchDTO.java new file mode 100644 index 000000000..f41086834 --- /dev/null +++ b/BE_baseball/src/main/java/com/dong/baseball/DTO/MatchDTO.java @@ -0,0 +1,49 @@ +package com.dong.baseball.DTO; + +import com.dong.baseball.Domain.Match; + +public class MatchDTO { + private Long matchId; + private String home; + private String away; + + + public MatchDTO(Match match) { + this.matchId = match.getId(); + this.home = match.getHome(); + this.away = match.getAway(); + } + + public Long getMatchId() { + return matchId; + } + + public void setMatchId(Long matchId) { + this.matchId = matchId; + } + + public String getHome() { + return home; + } + + public void setHome(String home) { + this.home = home; + } + + public String getAway() { + return away; + } + + public void setAway(String away) { + this.away = away; + } + + @Override + public String toString() { + return "MatchUpListDTO{" + + "matchId=" + matchId + + ", home='" + home + '\'' + + ", away='" + away + '\'' + + '}'; + } +} diff --git a/BE_baseball/src/main/java/com/dong/baseball/DTO/MatchUpListsDTO.java b/BE_baseball/src/main/java/com/dong/baseball/DTO/MatchUpListsDTO.java new file mode 100644 index 000000000..755558a56 --- /dev/null +++ b/BE_baseball/src/main/java/com/dong/baseball/DTO/MatchUpListsDTO.java @@ -0,0 +1,19 @@ +package com.dong.baseball.DTO; + +import java.util.List; + +public class MatchUpListsDTO { + List matchUpList; + + public MatchUpListsDTO(List matchUpList) { + this.matchUpList = matchUpList; + } + + public List getMatchUpList() { + return matchUpList; + } + + public void setMatchUpList(List matchUpList) { + this.matchUpList = matchUpList; + } +} diff --git a/BE_baseball/src/main/java/com/dong/baseball/DTO/ProgressDTO.java b/BE_baseball/src/main/java/com/dong/baseball/DTO/ProgressDTO.java new file mode 100644 index 000000000..d471d6a37 --- /dev/null +++ b/BE_baseball/src/main/java/com/dong/baseball/DTO/ProgressDTO.java @@ -0,0 +1,186 @@ +package com.dong.baseball.DTO; + +import com.dong.baseball.Domain.Board; +import com.dong.baseball.Domain.Player; + +import java.util.ArrayList; +import java.util.List; + +public class ProgressDTO { + private Long matchId; + private String away; + private String home; + private int inning; + private String offenseTeam; + private List firstBase; + private List secondBase; + private List thirdBase; + private String pitcher; + private String batter; + private int strike; + private int ball; + private int out; + private int homePoint; + private int awayPoint; + + public ProgressDTO(Board board) { + this.matchId = board.getId(); + this.away = "awayteam to string"; + this.home = "hometeam to string"; + this.inning = board.getInning(); + this.offenseTeam = "offenseTeam to String"; + + this.firstBase = new ArrayList<>(); + this.secondBase = new ArrayList<>(); + this.thirdBase = new ArrayList<>(); + + this.pitcher = board.getPitcher(); + this.batter = board.getBatter(); + this.strike = board.getStrike(); + this.ball = board.getBall(); + this.out = board.getOut(); + this.homePoint = board.getHomePoint(); + this.awayPoint = board.getAwayPoint(); + } + + public Long getMatchId() { + return matchId; + } + + public void setMatchId(Long matchId) { + this.matchId = matchId; + } + + public String getAway() { + return away; + } + + public void setAway(String away) { + this.away = away; + } + + public String getHome() { + return home; + } + + public void setHome(String home) { + this.home = home; + } + + public int getInning() { + return inning; + } + + public void setInning(int inning) { + this.inning = inning; + } + + public String getOffenseTeam() { + return offenseTeam; + } + + public void setOffenseTeam(String offenseTeam) { + this.offenseTeam = offenseTeam; + } + + public List getFirstBase() { + return firstBase; + } + + public void setFirstBase(List firstBase) { + this.firstBase = firstBase; + } + + public List getSecondBase() { + return secondBase; + } + + public void setSecondBase(List secondBase) { + this.secondBase = secondBase; + } + + public List getThirdBase() { + return thirdBase; + } + + public void setThirdBase(List thirdBase) { + this.thirdBase = thirdBase; + } + + public String getPitcher() { + return pitcher; + } + + public void setPitcher(String pitcher) { + this.pitcher = pitcher; + } + + public String getBatter() { + return batter; + } + + public void setBatter(String batter) { + this.batter = batter; + } + + public int getStrike() { + return strike; + } + + public void setStrike(int strike) { + this.strike = strike; + } + + public int getBall() { + return ball; + } + + public void setBall(int ball) { + this.ball = ball; + } + + public int getOut() { + return out; + } + + public void setOut(int out) { + this.out = out; + } + + public int getHomePoint() { + return homePoint; + } + + public void setHomePoint(int homePoint) { + this.homePoint = homePoint; + } + + public int getAwayPoint() { + return awayPoint; + } + + public void setAwayPoint(int awayPoint) { + this.awayPoint = awayPoint; + } + + @Override + public String toString() { + return "ProgressDTO{" + + "matchId=" + matchId + + ", away='" + away + '\'' + + ", home='" + home + '\'' + + ", inning=" + inning + + ", offenseTeam='" + offenseTeam + '\'' + + ", firstBase=" + firstBase + + ", secondBase=" + secondBase + + ", thirdBase=" + thirdBase + + ", pitcher='" + pitcher + '\'' + + ", batter='" + batter + '\'' + + ", strike=" + strike + + ", ball=" + ball + + ", out=" + out + + ", homePoint=" + homePoint + + ", awayPoint=" + awayPoint + + '}'; + } +} diff --git a/BE_baseball/src/main/java/com/dong/baseball/DTO/TeamRankDTO.java b/BE_baseball/src/main/java/com/dong/baseball/DTO/TeamRankDTO.java new file mode 100644 index 000000000..f19d8bd3c --- /dev/null +++ b/BE_baseball/src/main/java/com/dong/baseball/DTO/TeamRankDTO.java @@ -0,0 +1,81 @@ +package com.dong.baseball.DTO; + +import com.dong.baseball.Domain.Team; + +public class TeamRankDTO { + private Long teamId; + private String teamName; + private int win; + private int lose; + private int draw; + private int victoryPoint; + + public TeamRankDTO(Team team) { + this.teamId = team.getTeamId(); + this.teamName = team.getTeamName(); + this.win = team.getWin(); + this.lose = team.getLose(); + this.draw = team.getDraw(); + this.victoryPoint = team.getVictoryPoint(); + } + + public Long getTeamId() { + return teamId; + } + + public void setTeamId(Long teamId) { + this.teamId = teamId; + } + + public String getTeamName() { + return teamName; + } + + public void setTeamName(String teamName) { + this.teamName = teamName; + } + + public int getWin() { + return win; + } + + public void setWin(int win) { + this.win = win; + } + + public int getLose() { + return lose; + } + + public void setLose(int lose) { + this.lose = lose; + } + + public int getDraw() { + return draw; + } + + public void setDraw(int draw) { + this.draw = draw; + } + + public int getVictoryPoint() { + return victoryPoint; + } + + public void setVictoryPoint(int victoryPoint) { + this.victoryPoint = victoryPoint; + } + + @Override + public String toString() { + return "TeamRankDTO{" + + "teamId=" + teamId + + ", teamName='" + teamName + '\'' + + ", win=" + win + + ", lose=" + lose + + ", draw=" + draw + + ", victoryPoint=" + victoryPoint + + '}'; + } +} diff --git a/BE_baseball/src/main/java/com/dong/baseball/Domain/Board.java b/BE_baseball/src/main/java/com/dong/baseball/Domain/Board.java new file mode 100644 index 000000000..92ac0dfb3 --- /dev/null +++ b/BE_baseball/src/main/java/com/dong/baseball/Domain/Board.java @@ -0,0 +1,115 @@ +package com.dong.baseball.Domain; + + +import org.springframework.data.annotation.Id; + +public class Board { + + @Id + private Long id; + + private int inning; + private String turn; + private int strike; + private int ball; + private int out; + private int HomePoint; + private int AwayPoint; + private String pitcher; + private String batter; + + //@Todo 시간 기입해주기 + //@CreatedDate + //private LocalDateTime createdAt; + + public Long getId() { + return id; + } + + public int getInning() { + return inning; + } + + public void setInning(int inning) { + this.inning = inning; + } + + public String getTurn() { + return turn; + } + + public void setTurn(String turn) { + this.turn = turn; + } + + public int getStrike() { + return strike; + } + + public void setStrike(int strike) { + this.strike = strike; + } + + public int getBall() { + return ball; + } + + public void setBall(int ball) { + this.ball = ball; + } + + public int getOut() { + return out; + } + + public void setOut(int out) { + this.out = out; + } + + public int getHomePoint() { + return HomePoint; + } + + public void setHomePoint(int homePoint) { + HomePoint = homePoint; + } + + public int getAwayPoint() { + return AwayPoint; + } + + public void setAwayPoint(int awayPoint) { + AwayPoint = awayPoint; + } + + public String getPitcher() { + return pitcher; + } + + public void setPitcher(String pitcher) { + this.pitcher = pitcher; + } + + public String getBatter() { + return batter; + } + + public void setBatter(String batter) { + this.batter = batter; + } + + @Override + public String toString() { + return "Board{" + + ", inning=" + inning + + ", turn='" + turn + '\'' + + ", strike=" + strike + + ", ball=" + ball + + ", out=" + out + + ", HomePoint=" + HomePoint + + ", AwayPoint=" + AwayPoint + + ", pitcher='" + pitcher + '\'' + + ", batter='" + batter + '\'' + + '}'; + } +} diff --git a/BE_baseball/src/main/java/com/dong/baseball/Domain/Match.java b/BE_baseball/src/main/java/com/dong/baseball/Domain/Match.java new file mode 100644 index 000000000..b40933f02 --- /dev/null +++ b/BE_baseball/src/main/java/com/dong/baseball/Domain/Match.java @@ -0,0 +1,54 @@ +package com.dong.baseball.Domain; + +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.MappedCollection; + +import java.util.ArrayList; +import java.util.List; + +public class Match { + + @Id + private Long id; + private String home; + private String away; + + @MappedCollection(keyColumn = "match_id") + List gameBoards = new ArrayList<>(); + + public void addGameBoards(Board... boards) { + for (Board board : boards) { + this.gameBoards.add(board); + } + } + + public List getGameBoards() { + return gameBoards; + } + + public Long getId() { + return id; + } + + public String getHome() { + return home; + } + + public String getAway() { + return away; + } + + public void setAway(String away) { + this.away = away; + } + + @Override + public String toString() { + return "Match{" + + "id=" + id + + ", home='" + home + '\'' + + ", away='" + away + '\'' + + ", gameBoards=" + gameBoards + + '}'; + } +} diff --git a/BE_baseball/src/main/java/com/dong/baseball/Domain/Player.java b/BE_baseball/src/main/java/com/dong/baseball/Domain/Player.java new file mode 100644 index 000000000..0d548b29d --- /dev/null +++ b/BE_baseball/src/main/java/com/dong/baseball/Domain/Player.java @@ -0,0 +1,90 @@ +package com.dong.baseball.Domain; + +public class Player { + private String name; + private Integer uniformNumber; + private Integer playedGames; + private Integer atBat; + private Integer hit; + private Integer ball; + private Integer strike; + private Double battingAverage; + + public Integer getUniformNumber() { + return uniformNumber; + } + + public void setUniformNumber(Integer uniformNumber) { + this.uniformNumber = uniformNumber; + } + + public Integer getPlayedGames() { + return playedGames; + } + + public void setPlayedGames(Integer playedGames) { + this.playedGames = playedGames; + } + + public Integer getAtBat() { + return atBat; + } + + public void setAtBat(Integer atBat) { + this.atBat = atBat; + } + + public Integer getHit() { + return hit; + } + + public void setHit(Integer hit) { + this.hit = hit; + } + + public Integer getBall() { + return ball; + } + + public void setBall(Integer ball) { + this.ball = ball; + } + + public Integer getStrike() { + return strike; + } + + public void setStrike(Integer strike) { + this.strike = strike; + } + + public Double getBattingAverage() { + return battingAverage; + } + + public void setBattingAverage(Double battingAverage) { + this.battingAverage = (double) (this.hit + this.strike) / (double) (this.atBat); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public String toString() { + return "Player{" + + "name='" + name + '\'' + + ", uniformNumber=" + uniformNumber + + ", playedGames=" + playedGames + + ", atBat=" + atBat + + ", hit=" + hit + + ", ball=" + ball + + ", strike=" + strike + + ", battingAverage=" + battingAverage + + '}'; + } +} diff --git a/BE_baseball/src/main/java/com/dong/baseball/Domain/Team.java b/BE_baseball/src/main/java/com/dong/baseball/Domain/Team.java new file mode 100644 index 000000000..cb55c8bc2 --- /dev/null +++ b/BE_baseball/src/main/java/com/dong/baseball/Domain/Team.java @@ -0,0 +1,71 @@ +package com.dong.baseball.Domain; + +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.MappedCollection; + +import java.util.ArrayList; +import java.util.List; + +public class Team { + @MappedCollection(idColumn = "team_id", keyColumn = "player_index") + List members = new ArrayList<>(); + @Id + private Long teamId; + private String teamName; + private int win; + private int lose; + private int draw; + private int victoryPoint; + + public Long getTeamId() { + return teamId; + } + + public void setTeamId(Long teamId) { + this.teamId = teamId; + } + + public String getTeamName() { + return teamName; + } + + public void setTeamName(String teamName) { + this.teamName = teamName; + } + + public int getWin() { + return win; + } + + public void setWin(int win) { + this.win = win; + } + + public int getLose() { + return lose; + } + + public void setLose(int lose) { + this.lose = lose; + } + + public int getDraw() { + return draw; + } + + public void setDraw(int draw) { + this.draw = draw; + } + + public int getVictoryPoint() { + return victoryPoint; + } + + public void setVictoryPoint(int victoryPoint) { + this.victoryPoint = victoryPoint; + } + + public List getMembers() { + return members; + } +} diff --git a/BE_baseball/src/main/java/com/dong/baseball/Exception/MatchNotFoundException.java b/BE_baseball/src/main/java/com/dong/baseball/Exception/MatchNotFoundException.java new file mode 100644 index 000000000..7f422f28c --- /dev/null +++ b/BE_baseball/src/main/java/com/dong/baseball/Exception/MatchNotFoundException.java @@ -0,0 +1,9 @@ +package com.dong.baseball.Exception; + +public class MatchNotFoundException extends NotFoundException { + private static final String MATCH_NOT_FOUND_MESSAGE = "Cannot Found Match";; + + public MatchNotFoundException() { + super(MATCH_NOT_FOUND_MESSAGE); + } +} diff --git a/BE_baseball/src/main/java/com/dong/baseball/Exception/NotFoundException.java b/BE_baseball/src/main/java/com/dong/baseball/Exception/NotFoundException.java new file mode 100644 index 000000000..c862ec4b7 --- /dev/null +++ b/BE_baseball/src/main/java/com/dong/baseball/Exception/NotFoundException.java @@ -0,0 +1,7 @@ +package com.dong.baseball.Exception; + +public abstract class NotFoundException extends RuntimeException { + public NotFoundException(String message) { + super(message); + } +} diff --git a/BE_baseball/src/main/java/com/dong/baseball/Exception/PlayerNotFoundException.java b/BE_baseball/src/main/java/com/dong/baseball/Exception/PlayerNotFoundException.java new file mode 100644 index 000000000..7f9e9200c --- /dev/null +++ b/BE_baseball/src/main/java/com/dong/baseball/Exception/PlayerNotFoundException.java @@ -0,0 +1,10 @@ +package com.dong.baseball.Exception; + +public class PlayerNotFoundException extends NotFoundException { + private static final String PLAYER_NOT_FOUND_MESSAGE = "Cannot Found Player"; + + public PlayerNotFoundException() { + super(PLAYER_NOT_FOUND_MESSAGE); + } + +} diff --git a/BE_baseball/src/main/java/com/dong/baseball/Exception/TeamNotFoundException.java b/BE_baseball/src/main/java/com/dong/baseball/Exception/TeamNotFoundException.java new file mode 100644 index 000000000..c1059133c --- /dev/null +++ b/BE_baseball/src/main/java/com/dong/baseball/Exception/TeamNotFoundException.java @@ -0,0 +1,10 @@ +package com.dong.baseball.Exception; + +public class TeamNotFoundException extends NotFoundException { + private static final String TEAM_NOT_FOUND_MESSAGE = "Cannot Found Team"; + + public TeamNotFoundException() { + super(TEAM_NOT_FOUND_MESSAGE); + } + +} diff --git a/BE_baseball/src/main/java/com/dong/baseball/Repository/MatchRepository.java b/BE_baseball/src/main/java/com/dong/baseball/Repository/MatchRepository.java new file mode 100644 index 000000000..1019d0286 --- /dev/null +++ b/BE_baseball/src/main/java/com/dong/baseball/Repository/MatchRepository.java @@ -0,0 +1,13 @@ +package com.dong.baseball.Repository; + +import com.dong.baseball.Domain.Match; +import org.springframework.data.repository.CrudRepository; + +import java.util.List; + +public interface MatchRepository extends CrudRepository { + + @Override + List findAll(); + +} diff --git a/BE_baseball/src/main/java/com/dong/baseball/Repository/TeamRepository.java b/BE_baseball/src/main/java/com/dong/baseball/Repository/TeamRepository.java new file mode 100644 index 000000000..93b08e38a --- /dev/null +++ b/BE_baseball/src/main/java/com/dong/baseball/Repository/TeamRepository.java @@ -0,0 +1,18 @@ +package com.dong.baseball.Repository; + +import com.dong.baseball.Domain.Team; +import org.springframework.data.repository.CrudRepository; + +import java.util.List; +import java.util.Optional; + +public interface TeamRepository extends CrudRepository { + + @Override + List findAll(); + + @Override + Optional findById(Long aLong); + + Optional findByTeamName(String teamName); +} diff --git a/BE_baseball/src/main/java/com/dong/baseball/Service/GameService.java b/BE_baseball/src/main/java/com/dong/baseball/Service/GameService.java new file mode 100644 index 000000000..0b348c459 --- /dev/null +++ b/BE_baseball/src/main/java/com/dong/baseball/Service/GameService.java @@ -0,0 +1,72 @@ +package com.dong.baseball.Service; + +import com.dong.baseball.DTO.BaseballServerResponseDTO; +import com.dong.baseball.DTO.MatchDTO; +import com.dong.baseball.DTO.MatchUpListsDTO; +import com.dong.baseball.DTO.ProgressDTO; +import com.dong.baseball.Domain.Board; +import com.dong.baseball.Domain.Match; +import com.dong.baseball.Exception.MatchNotFoundException; +import com.dong.baseball.Repository.MatchRepository; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +@Service +public class GameService { + + private final MatchRepository leagueRepository; + + public GameService(MatchRepository leagueRepository) { + this.leagueRepository = leagueRepository; + } + + public MatchUpListsDTO matchList() { + List matchList = leagueRepository.findAll(); + List dtoList = new ArrayList<>(); + for (Match match : matchList) { + dtoList.add(new MatchDTO(match)); + } + return new MatchUpListsDTO(dtoList); + } + + public List matchInformations(Long matchId) { + Match match = leagueRepository.findById(matchId).orElseThrow(() -> new MatchNotFoundException()); + List matchBoards = match.getGameBoards(); + List matchBoardInfo = new ArrayList<>(); + + for (Board board : matchBoards) { + matchBoardInfo.add(new ProgressDTO(board)); + } + + return matchBoardInfo; + } + + public Board matchSingleInfo(Long matchId) { + Match match = leagueRepository.findById(matchId).get();//@Todo get + List matchBoards = match.getGameBoards(); + return matchBoards.get(matchBoards.size() - 1); + } + + + public BaseballServerResponseDTO gameStart(Long matchId) { + System.out.println("start!"); + return new BaseballServerResponseDTO(); + } + + public BaseballServerResponseDTO gameEnd(Long matchId) { + System.out.println("end"); + return new BaseballServerResponseDTO(); + } + + public BaseballServerResponseDTO gameProgress(Long matchId) { + System.out.println("progress"); + return new BaseballServerResponseDTO(); + } + + public MatchDTO findMatch(Long matchId) { + return new MatchDTO(leagueRepository.findById(matchId).orElseThrow(() -> new MatchNotFoundException())); + } +} + diff --git a/BE_baseball/src/main/java/com/dong/baseball/Service/TeamService.java b/BE_baseball/src/main/java/com/dong/baseball/Service/TeamService.java new file mode 100644 index 000000000..84541871b --- /dev/null +++ b/BE_baseball/src/main/java/com/dong/baseball/Service/TeamService.java @@ -0,0 +1,47 @@ +package com.dong.baseball.Service; + +import com.dong.baseball.DTO.TeamRankDTO; +import com.dong.baseball.Domain.Team; +import com.dong.baseball.Exception.TeamNotFoundException; +import com.dong.baseball.Repository.TeamRepository; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; + +@Service +public class TeamService { + + private final TeamRepository teamRepository; + + public TeamService(TeamRepository teamRepository) { + this.teamRepository = teamRepository; + } + + + public List teamRanking() { + List teamList = teamRepository.findAll(); + List teamRankDTOList = new ArrayList<>(); + + for (Team team : teamList) { + teamRankDTOList.add(new TeamRankDTO(team)); + } + + teamRankDTOList.sort(new Comparator() { + @Override + public int compare(TeamRankDTO t1, TeamRankDTO t2) { + return Integer.compare(t2.getVictoryPoint(), t1.getVictoryPoint()); + } + }); + return teamRankDTOList; + } + + public Team teamInfoById(Long teamId) { + return teamRepository.findById(teamId).orElseThrow(() -> new TeamNotFoundException()); + } + + public Team teamInfoByName(String teamName) { + return teamRepository.findByTeamName(teamName).orElseThrow(() -> new TeamNotFoundException()); + } +} diff --git a/BE_baseball/src/main/resources/application.properties b/BE_baseball/src/main/resources/application.properties new file mode 100644 index 000000000..823c0877a --- /dev/null +++ b/BE_baseball/src/main/resources/application.properties @@ -0,0 +1,13 @@ +# DB +spring.datasource.url=jdbc:mysql://localhost:3306/baseball?serverTimezone=UTC&characterEncoding=UTF-8 +spring.datasource.username=root +spring.datasource.password=password +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver +spring.datasource.initialization-mode=always +# schema.sql, data.sql 파일이 있다면 서버 시작 시 스크립트를 실행합니다. + +# logs +logging.level.sql=debug +# logging.level.com.codesquad.team14.*=DEBUG +logging.level.root=info +logging.file.path=logs diff --git a/BE_baseball/src/main/resources/data.sql b/BE_baseball/src/main/resources/data.sql new file mode 100644 index 000000000..c61ab7c05 --- /dev/null +++ b/BE_baseball/src/main/resources/data.sql @@ -0,0 +1,88 @@ +-- schema.sql 파일은 DDL 스크립트 +-- data.sql 파일은 DML 스크립트 +use baseball; + + +-- ---------------------------------------------------------- +-- match 관련 데이터 +-- ---------------------------------------------------------- +DESC `match`; +INSERT INTO `match`(home,away) values + ('Tigers','Bears'), + ('Bears','Twins'), + ('Twins','Dinos'), + ('Dinos','Lions'), + ('Lions','Eagles'), + ('Eagles','Giants'), + ('Giants','Tigers'); +-- ---------------------------------------------------------- + + + +-- ---------------------------------------------------------- +-- board 관련 데이터 +-- ---------------------------------------------------------- +-- -- turn 은 둘중하나 TOP/AWAY or BOT/HOME +desc `board`; +INSERT INTO `board`(`match`,`inning`,`turn`,`strike`,`ball`,`out`,`home_point`,`away_point`,`pitcher`,`batter`) values +(1,1,'TOP/AWAY',0,0,0,0,0,'kim','dong'), +(1,1,'TOP/AWAY',1,0,0,0,0,'kim','dong'), -- 1 스트라이크 +(1,1,'TOP/AWAY',2,0,0,0,0,'kim','dong'), -- 2 스트라이크 +(1,1,'TOP/AWAY',3,0,1,0,0,'kim','dong'), -- 3 스트라이크 , 삼진아웃 +(1,1,'TOP/AWAY',0,0,1,0,0,'kim','hun'), -- 타자변경 +(1,1,'TOP/AWAY',0,1,1,0,0,'kim','hun'), -- 1 볼 +(1,1,'TOP/AWAY',0,2,1,0,0,'kim','hun'), -- 2 볼 +(1,1,'TOP/AWAY',1,2,1,0,0,'kim','hun'), -- 2 볼 1스트라이크 +(1,1,'TOP/AWAY',0,0,1,0,0,'kim','honux'), -- 앞에서 안타 쳐서 호눅스로 타자변경 +(1,1,'TOP/AWAY',1,0,1,0,0,'kim','honux'), -- 앞에서 안타 쳐서 호눅스로 타자변경 +(1,1,'TOP/AWAY',2,0,1,0,0,'kim','honux'), -- 앞에서 안타 쳐서 호눅스로 타자변경 +(1,1,'TOP/AWAY',3,0,1,0,0,'kim','honux'), -- 앞에서 안타 쳐서 호눅스로 타자변경 +(1,1,'BOT/HOME',0,0,0,0,0,'kim','dong'); -- */ +-- ---------------------------------------------------------- + + + +-- ---------------------------------------------------------- +-- team 관련 데이터 +-- ---------------------------------------------------------- +-- Tigers, Bears, Twins, Dinos, Lions, Eagles, Giants; +DESC `team`; +-- DELETE FROM `team` WHERE team_id = *; +INSERT INTO `team`(`team_name`,`win`,`lose`,`draw`,`victory_point`) values +('Tigers',10,10,2,10*3+2), +('Bears',1,19,2,1*3+2), +('Twins',3,17,2,3*3+2), +('Dinos',5,15,2,5*3+2), +('Lions',7,13,2,7*3+2), +('Eagles',9,11,2,9*3+2), +('Giants',12,8,2,12*3+2); +-- ---------------------------------------------------------- + + +-- ---------------------------------------------------------- +-- player 관련 데이터 +-- ---------------------------------------------------------- +DESC `player`; +INSERT INTO `player`(`team_id`, `name`,`uniform_number`,`played_games`,`at_bat`,`hit`,`ball`,`strike`) values +-- 1번 팀 선수 +(1,'최동원',411,120,355,1518,111,120), +(1,'이대호',140,720,6454,158,411,201), +(1,'윤학길',229,2200,545,444,112,132), +(1,'손섭',2224,839,144,445,456,485), +(1,'강민호',345,345,123,235,152,98), +(1,'염김종석',247,567,546,346,83,662), +-- 2번팀 선수 +(2,'손민한',411,120,355,158,111,1), +(2,'김응국',140,720,645,158,41,201), +(2,'로드리게스',229,200,5445,444,112,132), +(2,'산쵸스',224,839,144,445,456,485), +(2,'효도르',345,3245,123,235,152,998), +(2,'김추찬',2247,567,546,346,823,662), +-- 3번팀 선수 +(3,'홍문종',411,120,355,158,111,120), +(3,'박현승',140,720,645,158,411,201), +(3,'페르디난드',229,200,545,444,112,132), +(3,'한영준',224,839,144,445,456,485), +(3,'강병철',345,345,123,235,152,998), +(3,'레일리',247,567,546,346,823,662); +-- ---------------------------------------------------------- diff --git a/BE_baseball/src/main/resources/deploy.sh b/BE_baseball/src/main/resources/deploy.sh new file mode 100644 index 000000000..d7c4446a8 --- /dev/null +++ b/BE_baseball/src/main/resources/deploy.sh @@ -0,0 +1,48 @@ +#!/bin/zsh +# 설정 +LINE='#########################################################' +SERVADDR='ec2-3-35-226-74.ap-northeast-2.compute.amazonaws.com' #배포할 AWS EC2 서버 +KEYFILE='~/Downloads/Dong210511.pem' # 내 개발콤퓨터에서 AWS key 위치 +AUTOINJECT_JAR=1 #1:자동으로 scp명령어로 밀어넣기, #0=안밀어넣고 명령어만 보여주고 끝내기 +# +echo $LINE +echo "## DongDong's 바이너리파일 밀어넣기 스크립트 " +echo "## >> 프로젝트 : baseball << " +echo $LINE + +cd ../../../ +./gradlew build -x test +cd build/libs +BINFILE=`ls | grep *.jar` +echo $BINFILE +echo $LINE +echo "sdfwef" + +if [ ${AUTOINJECT_JAR} -eq 1 ];then + scp -i $KEYFILE $BINFILE ubuntu@$SERVADDR:/home/ubuntu + echo "fffff" + echo "JAR FILE SEND OK...!" + + echo "" + echo "## tip!" + echo "" + echo "#how to run?" + echo "nohup java -jar ${BINFILE} &" + echo "" + echo "#how to show log file?" + echo "tail -F nohup.out" + echo "" + echo "#java start fail?" + echo "ps -ef | grep java" + echo "" + echo "go EC2 SERVER" + echo $LINE + + ssh -i $KEYFILE ubuntu@$SERVADDR +fi + + + + + + diff --git a/BE_baseball/src/main/resources/schema.sql b/BE_baseball/src/main/resources/schema.sql new file mode 100644 index 000000000..d60496cc4 --- /dev/null +++ b/BE_baseball/src/main/resources/schema.sql @@ -0,0 +1,106 @@ +-- schema.sql 파일은 DDL 스크립트 +-- data.sql 파일은 DML 스크립트 +CREATE DATABASE IF NOT EXISTS `baseball`; +use baseball; + + + +-- ------------------------------------------------- +-- match +-- ------------------------------------------------- +drop table IF EXISTS `match`; +-- +CREATE TABLE IF NOT EXISTS `baseball`.`match`( + `id` BIGINT PRIMARY KEY AUTO_INCREMENT, + `home` VARCHAR(45) NOT NULL, + `away` VARCHAR(45) NOT NULL +); +-- +ALTER TABLE `match` CONVERT TO character SET utf8; +-- +DESC `match`; +-- + + + +-- ------------------------------------------------- +-- match +-- ------------------------------------------------- +drop table IF EXISTS `board`; +-- +CREATE TABLE IF NOT EXISTS `baseball`.`board` +( + `id` BIGINT PRIMARY KEY AUTO_INCREMENT, + `match` BIGINT REFERENCES `match`(id), + `match_id` INT, + `inning` INT NOT NULL, -- 이닝, 몇회차인지 + `turn` VARCHAR(45) NOT NULL, -- 둘중하나 TOP/AWAY or BOT/HOME + `strike` INT NOT NULL, -- 스트라이크 갯수 + `ball` INT NOT NULL, -- 볼 갯수 + `out` INT NOT NULL, -- 현 회차에서 아웃한 타자의 수 + `home_point` INT NOT NULL, -- 홈팀의 득점 + `away_point` INT NOT NULL, -- 원정팀의 득점 + `pitcher` VARCHAR(45) NOT NULL, + `batter` VARCHAR(45) NOT NULL +); +-- +ALTER TABLE `board` CONVERT TO character SET utf8; +-- +DESC `board`; +-- + + + +-- ------------------------------------------------- +-- team +-- ------------------------------------------------- +drop table IF EXISTS `team`; +-- +CREATE TABLE IF NOT EXISTS `baseball`.`team` +( + `team_id` BIGINT PRIMARY KEY AUTO_INCREMENT, + `team_name` VARCHAR(45) NOT NULL, + `win` INT NOT NULL, + `lose` INT NOT NULL, + `draw` INT NOT NULL, + `victory_point` INT NOT NULL +); +-- +ALTER TABLE `team` CONVERT TO character SET utf8; +-- +DESC `team`; +-- + + + +-- ------------------------------------------------- +-- player +-- ------------------------------------------------- +drop table IF EXISTS `player`; +-- +CREATE TABLE IF NOT EXISTS `baseball`.`player` +( + `player_id` BIGINT PRIMARY KEY AUTO_INCREMENT, + `team_id` BIGINT REFERENCES `team` (team_id), + `player_index` INT, + `name` VARCHAR(64) NOT NULL, + `uniform_number` INT NOT NULL, + `played_games` INT NOT NULL, + `at_bat` INT NOT NULL, + `hit` INT NOT NULL, + `ball` INT NOT NULL, + `strike` INT NOT NULL, + `batting_average` DOUBLE DEFAULT NULL +); +-- +SELECT * FROM player; +ALTER TABLE `player` CONVERT TO character SET utf8; +-- +DESC `player`; +-- + + +-- ------------------------------------------------- +-- END OF SQL +-- ------------------------------------------------- +-- show tables; diff --git a/BE_baseball/src/test/java/com/dong/baseball/BaseballApplicationTests.java b/BE_baseball/src/test/java/com/dong/baseball/BaseballApplicationTests.java new file mode 100644 index 000000000..91fa6bcb5 --- /dev/null +++ b/BE_baseball/src/test/java/com/dong/baseball/BaseballApplicationTests.java @@ -0,0 +1,13 @@ +package com.dong.baseball; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class BaseballApplicationTests { + + @Test + void contextLoads() { + } + +}