diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..e48b6be6 --- /dev/null +++ b/.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/ \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 00000000..e3fdc4ae --- /dev/null +++ b/build.gradle @@ -0,0 +1,34 @@ +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' + developmentOnly 'org.springframework.boot:spring-boot-devtools' + runtimeOnly 'com.mysql:mysql-connector-j' + annotationProcessor 'org.projectlombok:lombok' + testImplementation 'org.springframework.boot:spring-boot-starter-test' + implementation 'org.springdoc:springdoc-openapi-ui:1.6.8' +} + +tasks.named('test') { + useJUnitPlatform() +} \ No newline at end of file diff --git a/build/classes/java/main/com/techeer/hackathon/TecheerApplication.class b/build/classes/java/main/com/techeer/hackathon/TecheerApplication.class new file mode 100644 index 00000000..1424f418 Binary files /dev/null and b/build/classes/java/main/com/techeer/hackathon/TecheerApplication.class differ diff --git a/build/classes/java/test/com/techeer/hackathon/TecheerApplicationTests.class b/build/classes/java/test/com/techeer/hackathon/TecheerApplicationTests.class new file mode 100644 index 00000000..7c77ea55 Binary files /dev/null and b/build/classes/java/test/com/techeer/hackathon/TecheerApplicationTests.class differ diff --git a/build/reports/tests/test/classes/com.techeer.hackathon.TecheerApplicationTests.html b/build/reports/tests/test/classes/com.techeer.hackathon.TecheerApplicationTests.html new file mode 100644 index 00000000..637285b4 --- /dev/null +++ b/build/reports/tests/test/classes/com.techeer.hackathon.TecheerApplicationTests.html @@ -0,0 +1,134 @@ + + + + + +Test results - TecheerApplicationTests + + + + + +
+

TecheerApplicationTests

+ +
+ + + + + +
+
+ + + + + + + +
+
+
1
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.166s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Tests

+ + + + + + + + + + + + + +
TestDurationResult
contextLoads()0.166spassed
+
+
+

Standard output

+ +
00:40:57.356 [Test worker] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
+00:40:57.361 [Test worker] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]
+00:40:57.384 [Test worker] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [com.techeer.hackathon.TecheerApplicationTests] from class [org.springframework.boot.test.context.SpringBootTestContextBootstrapper]
+00:40:57.390 [Test worker] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [com.techeer.hackathon.TecheerApplicationTests], using SpringBootContextLoader
+00:40:57.392 [Test worker] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.techeer.hackathon.TecheerApplicationTests]: class path resource [com/techeer/hackathon/TecheerApplicationTests-context.xml] does not exist
+00:40:57.392 [Test worker] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.techeer.hackathon.TecheerApplicationTests]: class path resource [com/techeer/hackathon/TecheerApplicationTestsContext.groovy] does not exist
+00:40:57.393 [Test worker] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [com.techeer.hackathon.TecheerApplicationTests]: no resource found for suffixes {-context.xml, Context.groovy}.
+00:40:57.393 [Test worker] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [com.techeer.hackathon.TecheerApplicationTests]: TecheerApplicationTests does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
+00:40:57.425 [Test worker] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [com.techeer.hackathon.TecheerApplicationTests]
+00:40:57.453 [Test worker] DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider - Identified candidate component class: file [/Users/hangyeol/Good-Night-Hackathon-SpringBoot/build/classes/java/main/com/techeer/hackathon/TecheerApplication.class]
+00:40:57.454 [Test worker] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Found @SpringBootConfiguration com.techeer.hackathon.TecheerApplication for test class com.techeer.hackathon.TecheerApplicationTests
+00:40:57.499 [Test worker] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - @TestExecutionListeners is not present for class [com.techeer.hackathon.TecheerApplicationTests]: using defaults.
+00:40:57.499 [Test worker] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.event.ApplicationEventsTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.test.context.event.EventPublishingTestExecutionListener]
+00:40:57.504 [Test worker] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Skipping candidate TestExecutionListener [org.springframework.test.context.transaction.TransactionalTestExecutionListener] due to a missing dependency. Specify custom listener classes or make the default listener classes and their required dependencies available. Offending class: [org/springframework/transaction/interceptor/TransactionAttributeSource]
+00:40:57.504 [Test worker] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Skipping candidate TestExecutionListener [org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener] due to a missing dependency. Specify custom listener classes or make the default listener classes and their required dependencies available. Offending class: [org/springframework/transaction/interceptor/TransactionAttribute]
+00:40:57.505 [Test worker] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@70d2e40b, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@120f38e6, org.springframework.test.context.event.ApplicationEventsTestExecutionListener@7a0e1b5e, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@702ed190, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@173b9122, org.springframework.test.context.support.DirtiesContextTestExecutionListener@7c18432b, org.springframework.test.context.event.EventPublishingTestExecutionListener@7646731d, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@70e29e14, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@3b1bb3ab, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@5a4bef8, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@40bffbca, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener@2449cff7, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@42a9a63e]
+00:40:57.507 [Test worker] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - Before test class: context [DefaultTestContext@596df867 testClass = TecheerApplicationTests, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@c1fca1e testClass = TecheerApplicationTests, locations = '{}', classes = '{class com.techeer.hackathon.TecheerApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.autoconfigure.actuate.metrics.MetricsExportContextCustomizerFactory$DisableMetricExportContextCustomizer@765f05af, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@3543df7d, org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@1e7aa82b, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@1c6804cd, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@488eb7f2, org.springframework.boot.test.context.SpringBootTestArgs@1, org.springframework.boot.test.context.SpringBootTestWebEnvironment@41f69e84], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> true]], class annotated with @DirtiesContext [false] with mode [null].
+
+  .   ____          _            __ _ _
+ /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
+( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
+ \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
+  '  |____| .__|_| |_|_| |_\__, | / / / /
+ =========|_|==============|___/=/_/_/_/
+ :: Spring Boot ::                (v2.7.9)
+
+2023-02-26 00:40:57.744  INFO 15893 --- [    Test worker] c.t.hackathon.TecheerApplicationTests    : Starting TecheerApplicationTests using Java 11.0.18 on baeghangyeol-ui-MacBookPro.local with PID 15893 (started by hangyeol in /Users/hangyeol/Good-Night-Hackathon-SpringBoot)
+2023-02-26 00:40:57.745  INFO 15893 --- [    Test worker] c.t.hackathon.TecheerApplicationTests    : No active profile set, falling back to 1 default profile: "default"
+2023-02-26 00:40:58.356  INFO 15893 --- [    Test worker] c.t.hackathon.TecheerApplicationTests    : Started TecheerApplicationTests in 0.832 seconds (JVM running for 1.379)
+
+
+
+
+ +
+ + diff --git a/build/reports/tests/test/css/base-style.css b/build/reports/tests/test/css/base-style.css new file mode 100644 index 00000000..4afa73e3 --- /dev/null +++ b/build/reports/tests/test/css/base-style.css @@ -0,0 +1,179 @@ + +body { + margin: 0; + padding: 0; + font-family: sans-serif; + font-size: 12pt; +} + +body, a, a:visited { + color: #303030; +} + +#content { + padding-left: 50px; + padding-right: 50px; + padding-top: 30px; + padding-bottom: 30px; +} + +#content h1 { + font-size: 160%; + margin-bottom: 10px; +} + +#footer { + margin-top: 100px; + font-size: 80%; + white-space: nowrap; +} + +#footer, #footer a { + color: #a0a0a0; +} + +#line-wrapping-toggle { + vertical-align: middle; +} + +#label-for-line-wrapping-toggle { + vertical-align: middle; +} + +ul { + margin-left: 0; +} + +h1, h2, h3 { + white-space: nowrap; +} + +h2 { + font-size: 120%; +} + +ul.tabLinks { + padding-left: 0; + padding-top: 10px; + padding-bottom: 10px; + overflow: auto; + min-width: 800px; + width: auto !important; + width: 800px; +} + +ul.tabLinks li { + float: left; + height: 100%; + list-style: none; + padding-left: 10px; + padding-right: 10px; + padding-top: 5px; + padding-bottom: 5px; + margin-bottom: 0; + -moz-border-radius: 7px; + border-radius: 7px; + margin-right: 25px; + border: solid 1px #d4d4d4; + background-color: #f0f0f0; +} + +ul.tabLinks li:hover { + background-color: #fafafa; +} + +ul.tabLinks li.selected { + background-color: #c5f0f5; + border-color: #c5f0f5; +} + +ul.tabLinks a { + font-size: 120%; + display: block; + outline: none; + text-decoration: none; + margin: 0; + padding: 0; +} + +ul.tabLinks li h2 { + margin: 0; + padding: 0; +} + +div.tab { +} + +div.selected { + display: block; +} + +div.deselected { + display: none; +} + +div.tab table { + min-width: 350px; + width: auto !important; + width: 350px; + border-collapse: collapse; +} + +div.tab th, div.tab table { + border-bottom: solid #d0d0d0 1px; +} + +div.tab th { + text-align: left; + white-space: nowrap; + padding-left: 6em; +} + +div.tab th:first-child { + padding-left: 0; +} + +div.tab td { + white-space: nowrap; + padding-left: 6em; + padding-top: 5px; + padding-bottom: 5px; +} + +div.tab td:first-child { + padding-left: 0; +} + +div.tab td.numeric, div.tab th.numeric { + text-align: right; +} + +span.code { + display: inline-block; + margin-top: 0em; + margin-bottom: 1em; +} + +span.code pre { + font-size: 11pt; + padding-top: 10px; + padding-bottom: 10px; + padding-left: 10px; + padding-right: 10px; + margin: 0; + background-color: #f7f7f7; + border: solid 1px #d0d0d0; + min-width: 700px; + width: auto !important; + width: 700px; +} + +span.wrapped pre { + word-wrap: break-word; + white-space: pre-wrap; + word-break: break-all; +} + +label.hidden { + display: none; +} \ No newline at end of file diff --git a/build/reports/tests/test/css/style.css b/build/reports/tests/test/css/style.css new file mode 100644 index 00000000..3dc4913e --- /dev/null +++ b/build/reports/tests/test/css/style.css @@ -0,0 +1,84 @@ + +#summary { + margin-top: 30px; + margin-bottom: 40px; +} + +#summary table { + border-collapse: collapse; +} + +#summary td { + vertical-align: top; +} + +.breadcrumbs, .breadcrumbs a { + color: #606060; +} + +.infoBox { + width: 110px; + padding-top: 15px; + padding-bottom: 15px; + text-align: center; +} + +.infoBox p { + margin: 0; +} + +.counter, .percent { + font-size: 120%; + font-weight: bold; + margin-bottom: 8px; +} + +#duration { + width: 125px; +} + +#successRate, .summaryGroup { + border: solid 2px #d0d0d0; + -moz-border-radius: 10px; + border-radius: 10px; +} + +#successRate { + width: 140px; + margin-left: 35px; +} + +#successRate .percent { + font-size: 180%; +} + +.success, .success a { + color: #008000; +} + +div.success, #successRate.success { + background-color: #bbd9bb; + border-color: #008000; +} + +.failures, .failures a { + color: #b60808; +} + +.skipped, .skipped a { + color: #c09853; +} + +div.failures, #successRate.failures { + background-color: #ecdada; + border-color: #b60808; +} + +ul.linkList { + padding-left: 0; +} + +ul.linkList li { + list-style: none; + margin-bottom: 5px; +} diff --git a/build/reports/tests/test/index.html b/build/reports/tests/test/index.html new file mode 100644 index 00000000..b47feaa0 --- /dev/null +++ b/build/reports/tests/test/index.html @@ -0,0 +1,133 @@ + + + + + +Test results - Test Summary + + + + + +
+

Test Summary

+
+ + + + + +
+
+ + + + + + + +
+
+
1
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.166s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Packages

+ + + + + + + + + + + + + + + + + + + + + +
PackageTestsFailuresIgnoredDurationSuccess rate
+com.techeer.hackathon +1000.166s100%
+
+
+

Classes

+ + + + + + + + + + + + + + + + + + + + + +
ClassTestsFailuresIgnoredDurationSuccess rate
+com.techeer.hackathon.TecheerApplicationTests +1000.166s100%
+
+
+ +
+ + diff --git a/build/reports/tests/test/js/report.js b/build/reports/tests/test/js/report.js new file mode 100644 index 00000000..83bab4a1 --- /dev/null +++ b/build/reports/tests/test/js/report.js @@ -0,0 +1,194 @@ +(function (window, document) { + "use strict"; + + var tabs = {}; + + function changeElementClass(element, classValue) { + if (element.getAttribute("className")) { + element.setAttribute("className", classValue); + } else { + element.setAttribute("class", classValue); + } + } + + function getClassAttribute(element) { + if (element.getAttribute("className")) { + return element.getAttribute("className"); + } else { + return element.getAttribute("class"); + } + } + + function addClass(element, classValue) { + changeElementClass(element, getClassAttribute(element) + " " + classValue); + } + + function removeClass(element, classValue) { + changeElementClass(element, getClassAttribute(element).replace(classValue, "")); + } + + function initTabs() { + var container = document.getElementById("tabs"); + + tabs.tabs = findTabs(container); + tabs.titles = findTitles(tabs.tabs); + tabs.headers = findHeaders(container); + tabs.select = select; + tabs.deselectAll = deselectAll; + tabs.select(0); + + return true; + } + + function getCheckBox() { + return document.getElementById("line-wrapping-toggle"); + } + + function getLabelForCheckBox() { + return document.getElementById("label-for-line-wrapping-toggle"); + } + + function findCodeBlocks() { + var spans = document.getElementById("tabs").getElementsByTagName("span"); + var codeBlocks = []; + for (var i = 0; i < spans.length; ++i) { + if (spans[i].className.indexOf("code") >= 0) { + codeBlocks.push(spans[i]); + } + } + return codeBlocks; + } + + function forAllCodeBlocks(operation) { + var codeBlocks = findCodeBlocks(); + + for (var i = 0; i < codeBlocks.length; ++i) { + operation(codeBlocks[i], "wrapped"); + } + } + + function toggleLineWrapping() { + var checkBox = getCheckBox(); + + if (checkBox.checked) { + forAllCodeBlocks(addClass); + } else { + forAllCodeBlocks(removeClass); + } + } + + function initControls() { + if (findCodeBlocks().length > 0) { + var checkBox = getCheckBox(); + var label = getLabelForCheckBox(); + + checkBox.onclick = toggleLineWrapping; + checkBox.checked = false; + + removeClass(label, "hidden"); + } + } + + function switchTab() { + var id = this.id.substr(1); + + for (var i = 0; i < tabs.tabs.length; i++) { + if (tabs.tabs[i].id === id) { + tabs.select(i); + break; + } + } + + return false; + } + + function select(i) { + this.deselectAll(); + + changeElementClass(this.tabs[i], "tab selected"); + changeElementClass(this.headers[i], "selected"); + + while (this.headers[i].firstChild) { + this.headers[i].removeChild(this.headers[i].firstChild); + } + + var h2 = document.createElement("H2"); + + h2.appendChild(document.createTextNode(this.titles[i])); + this.headers[i].appendChild(h2); + } + + function deselectAll() { + for (var i = 0; i < this.tabs.length; i++) { + changeElementClass(this.tabs[i], "tab deselected"); + changeElementClass(this.headers[i], "deselected"); + + while (this.headers[i].firstChild) { + this.headers[i].removeChild(this.headers[i].firstChild); + } + + var a = document.createElement("A"); + + a.setAttribute("id", "ltab" + i); + a.setAttribute("href", "#tab" + i); + a.onclick = switchTab; + a.appendChild(document.createTextNode(this.titles[i])); + + this.headers[i].appendChild(a); + } + } + + function findTabs(container) { + return findChildElements(container, "DIV", "tab"); + } + + function findHeaders(container) { + var owner = findChildElements(container, "UL", "tabLinks"); + return findChildElements(owner[0], "LI", null); + } + + function findTitles(tabs) { + var titles = []; + + for (var i = 0; i < tabs.length; i++) { + var tab = tabs[i]; + var header = findChildElements(tab, "H2", null)[0]; + + header.parentNode.removeChild(header); + + if (header.innerText) { + titles.push(header.innerText); + } else { + titles.push(header.textContent); + } + } + + return titles; + } + + function findChildElements(container, name, targetClass) { + var elements = []; + var children = container.childNodes; + + for (var i = 0; i < children.length; i++) { + var child = children.item(i); + + if (child.nodeType === 1 && child.nodeName === name) { + if (targetClass && child.className.indexOf(targetClass) < 0) { + continue; + } + + elements.push(child); + } + } + + return elements; + } + + // Entry point. + + window.onload = function() { + initTabs(); + initControls(); + }; +} (window, window.document)); \ No newline at end of file diff --git a/build/reports/tests/test/packages/com.techeer.hackathon.html b/build/reports/tests/test/packages/com.techeer.hackathon.html new file mode 100644 index 00000000..3c7917c0 --- /dev/null +++ b/build/reports/tests/test/packages/com.techeer.hackathon.html @@ -0,0 +1,103 @@ + + + + + +Test results - Package com.techeer.hackathon + + + + + +
+

Package com.techeer.hackathon

+ +
+ + + + + +
+
+ + + + + + + +
+
+
1
+

tests

+
+
+
+
0
+

failures

+
+
+
+
0
+

ignored

+
+
+
+
0.166s
+

duration

+
+
+
+
+
+
100%
+

successful

+
+
+
+
+ +
+

Classes

+ + + + + + + + + + + + + + + + + + + +
ClassTestsFailuresIgnoredDurationSuccess rate
+TecheerApplicationTests +1000.166s100%
+
+
+ +
+ + diff --git a/build/resources/main/application.yml b/build/resources/main/application.yml new file mode 100644 index 00000000..2e76a0cc --- /dev/null +++ b/build/resources/main/application.yml @@ -0,0 +1,20 @@ +spring: + jpa: + database: "mysql" + show-sql: "true" + hibernate: + ddl-auto: "update" + properties: + hibernate: + format_sql: true + generate-ddl: true + + datasource: + driver-class-name: "com.mysql.cj.jdbc.Driver" + url: "jdbc:mysql://localhost:3306/test_db?useSSL=false&useLegacyDatetimeCode=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul&characterEncoding=UTF-8&autoReconnect=true&createDatabaseIfNotExist=true" + username: "root" + password: "0000" + + flyway: + enabled: false + baseline-on-migrate: true diff --git a/build/test-results/test/TEST-com.techeer.hackathon.TecheerApplicationTests.xml b/build/test-results/test/TEST-com.techeer.hackathon.TecheerApplicationTests.xml new file mode 100644 index 00000000..85450f08 --- /dev/null +++ b/build/test-results/test/TEST-com.techeer.hackathon.TecheerApplicationTests.xml @@ -0,0 +1,36 @@ + + + + + true]], class annotated with @DirtiesContext [false] with mode [null]. + + . ____ _ __ _ _ + /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ +( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ + \\/ ___)| |_)| | | | | || (_| | ) ) ) ) + ' |____| .__|_| |_|_| |_\__, | / / / / + =========|_|==============|___/=/_/_/_/ + :: Spring Boot :: (v2.7.9) + +2023-02-26 00:40:57.744 INFO 15893 --- [ Test worker] c.t.hackathon.TecheerApplicationTests : Starting TecheerApplicationTests using Java 11.0.18 on baeghangyeol-ui-MacBookPro.local with PID 15893 (started by hangyeol in /Users/hangyeol/Good-Night-Hackathon-SpringBoot) +2023-02-26 00:40:57.745 INFO 15893 --- [ Test worker] c.t.hackathon.TecheerApplicationTests : No active profile set, falling back to 1 default profile: "default" +2023-02-26 00:40:58.356 INFO 15893 --- [ Test worker] c.t.hackathon.TecheerApplicationTests : Started TecheerApplicationTests in 0.832 seconds (JVM running for 1.379) +]]> + + diff --git a/build/test-results/test/binary/output.bin b/build/test-results/test/binary/output.bin new file mode 100644 index 00000000..609be40d Binary files /dev/null and b/build/test-results/test/binary/output.bin differ diff --git a/build/test-results/test/binary/output.bin.idx b/build/test-results/test/binary/output.bin.idx new file mode 100644 index 00000000..567cb5fc Binary files /dev/null and b/build/test-results/test/binary/output.bin.idx differ diff --git a/build/test-results/test/binary/results.bin b/build/test-results/test/binary/results.bin new file mode 100644 index 00000000..90453c7f Binary files /dev/null and b/build/test-results/test/binary/results.bin differ diff --git a/build/tmp/compileJava/previous-compilation-data.bin b/build/tmp/compileJava/previous-compilation-data.bin new file mode 100644 index 00000000..81f17af7 Binary files /dev/null and b/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/build/tmp/compileTestJava/previous-compilation-data.bin b/build/tmp/compileTestJava/previous-compilation-data.bin new file mode 100644 index 00000000..3be8d9a9 Binary files /dev/null and b/build/tmp/compileTestJava/previous-compilation-data.bin differ diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..249e5832 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..070cb702 --- /dev/null +++ b/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/gradlew b/gradlew new file mode 100755 index 00000000..a69d9cb6 --- /dev/null +++ b/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/gradlew.bat b/gradlew.bat new file mode 100644 index 00000000..f127cfd4 --- /dev/null +++ b/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/out/production/resources/application.yml b/out/production/resources/application.yml new file mode 100644 index 00000000..5272f25d --- /dev/null +++ b/out/production/resources/application.yml @@ -0,0 +1,20 @@ +spring: + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://localhost:3306/restaurant + username: root + password: qorgksruf123 + + jpa: + hibernate: + ddl-auto : create #update + properties: + hibernate: + format_sql: true + use_sql_comments: true + show_sql: true + +logging: + level: + org: + hibernate: info \ No newline at end of file diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 00000000..d3c254e6 --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'techeer' diff --git a/src/main/java/com/techeer/hackathon/TecheerApplication.java b/src/main/java/com/techeer/hackathon/TecheerApplication.java new file mode 100644 index 00000000..511312db --- /dev/null +++ b/src/main/java/com/techeer/hackathon/TecheerApplication.java @@ -0,0 +1,15 @@ +package com.techeer.hackathon; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.data.jpa.repository.config.EnableJpaAuditing; + +@SpringBootApplication +@EnableJpaAuditing +public class TecheerApplication { + + public static void main(String[] args) { + SpringApplication.run(TecheerApplication.class, args); + } + +} diff --git a/src/main/java/com/techeer/hackathon/domain/restaurant/controller/ControllerRestaurant.java b/src/main/java/com/techeer/hackathon/domain/restaurant/controller/ControllerRestaurant.java new file mode 100644 index 00000000..c32d7700 --- /dev/null +++ b/src/main/java/com/techeer/hackathon/domain/restaurant/controller/ControllerRestaurant.java @@ -0,0 +1,74 @@ +package com.techeer.hackathon.domain.restaurant.controller; + +import com.techeer.hackathon.domain.restaurant.dto.InquiryRestaurantDTO; +import com.techeer.hackathon.domain.restaurant.dto.RegisterRestaurantDTO; +import com.techeer.hackathon.domain.restaurant.dto.mapper.RestaurantMapper; +import com.techeer.hackathon.domain.restaurant.entity.Restaurant; +import com.techeer.hackathon.domain.restaurant.repository.RepositoryRestaurant; +import com.techeer.hackathon.domain.restaurant.service.ServiceRestaurant; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.util.List; +import java.util.stream.Collectors; + +@Controller +@RequestMapping("/api/v1/restaurant") +@RestController +@RequiredArgsConstructor +public class ControllerRestaurant { + private final ServiceRestaurant Res_Service; + private final RestaurantMapper Res_Mapper; + + private final RepositoryRestaurant Res_Repo; + + @PostMapping + @ResponseStatus(HttpStatus.CREATED) + public ResponseEntity createRestaurant( + @RequestBody @Valid RegisterRestaurantDTO registerRestaurantDTO) { + Restaurant insertRestaurant = Res_Service.insertRestaurant(registerRestaurantDTO); + return new ResponseEntity(Res_Mapper.DtoFromEntity(insertRestaurant), HttpStatus.CREATED); + } + + @GetMapping + @ResponseStatus(HttpStatus.OK) + public List getAllRestaurants() { + List restaurants = Res_Repo.findByDeletedFalse(); + return restaurants.stream() + .map(Res_Mapper::DtoFromEntity) + .collect(Collectors.toList()); + } + + @DeleteMapping("/{id}") + public ResponseEntity deleteRestaurant(@PathVariable Long id) { + Res_Service.deleteRestaurant(id); + return ResponseEntity.noContent().build(); + } + + @GetMapping("/category") + public List getRestaurantsByCategory(String category) { + List restaurants = Res_Repo.findByCategoryAndDeletedFalse(category); + return restaurants.stream().map(Res_Mapper::DtoFromEntity).collect(Collectors.toList()); + } + + @GetMapping("/{id}") + public InquiryRestaurantDTO getRestaurantById(@PathVariable Long id) { + Restaurant restaurant = Res_Service.getRestaurantByIdAndDeletedIsFalse(id); + return InquiryRestaurantDTO.builder() + .id(restaurant.getId()) + .name(restaurant.getName()) + .category(restaurant.getCategory()) + .createdAt(restaurant.getCreatedAt()) + .build(); + } + + @PutMapping("/id/{id}/{category}") + public ResponseEntity updateRestaurantCategory(@PathVariable("id") Long id, @PathVariable("category") String category) { + return ResponseEntity.ok(Res_Service.updateRestaurantCategory(id,category)); + } + +} diff --git a/src/main/java/com/techeer/hackathon/domain/restaurant/dto/InquiryRestaurantDTO.java b/src/main/java/com/techeer/hackathon/domain/restaurant/dto/InquiryRestaurantDTO.java new file mode 100644 index 00000000..a7119242 --- /dev/null +++ b/src/main/java/com/techeer/hackathon/domain/restaurant/dto/InquiryRestaurantDTO.java @@ -0,0 +1,16 @@ +package com.techeer.hackathon.domain.restaurant.dto; + +import lombok.Builder; +import lombok.Getter; + +import java.time.LocalDateTime; + +@Builder +@Getter +public class InquiryRestaurantDTO { + private Long id; + private String name; + private String category; + private LocalDateTime createdAt; + +} \ No newline at end of file diff --git a/src/main/java/com/techeer/hackathon/domain/restaurant/dto/RegisterRestaurantDTO.java b/src/main/java/com/techeer/hackathon/domain/restaurant/dto/RegisterRestaurantDTO.java new file mode 100644 index 00000000..81df0a87 --- /dev/null +++ b/src/main/java/com/techeer/hackathon/domain/restaurant/dto/RegisterRestaurantDTO.java @@ -0,0 +1,18 @@ +package com.techeer.hackathon.domain.restaurant.dto; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +import javax.validation.constraints.NotNull; +import java.time.LocalDateTime; + +@Getter +@RequiredArgsConstructor + +public class RegisterRestaurantDTO { + private final LocalDateTime createDate; + @NotNull + private final String name; + @NotNull + private final String category; +} diff --git a/src/main/java/com/techeer/hackathon/domain/restaurant/dto/UpdateRestaurantDTO.java b/src/main/java/com/techeer/hackathon/domain/restaurant/dto/UpdateRestaurantDTO.java new file mode 100644 index 00000000..90e72884 --- /dev/null +++ b/src/main/java/com/techeer/hackathon/domain/restaurant/dto/UpdateRestaurantDTO.java @@ -0,0 +1,17 @@ +package com.techeer.hackathon.domain.restaurant.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; + +import javax.validation.constraints.NotNull; +import java.time.LocalDateTime; + +@Getter +@Builder +@AllArgsConstructor +public class UpdateRestaurantDTO { + @NotNull + private final String category; + private final LocalDateTime updatedAt; +} diff --git a/src/main/java/com/techeer/hackathon/domain/restaurant/dto/mapper/RestaurantMapper.java b/src/main/java/com/techeer/hackathon/domain/restaurant/dto/mapper/RestaurantMapper.java new file mode 100644 index 00000000..85145253 --- /dev/null +++ b/src/main/java/com/techeer/hackathon/domain/restaurant/dto/mapper/RestaurantMapper.java @@ -0,0 +1,39 @@ +package com.techeer.hackathon.domain.restaurant.dto.mapper; + +import com.techeer.hackathon.domain.restaurant.dto.RegisterRestaurantDTO; +import com.techeer.hackathon.domain.restaurant.dto.InquiryRestaurantDTO; +import com.techeer.hackathon.domain.restaurant.dto.UpdateRestaurantDTO; +import com.techeer.hackathon.domain.restaurant.entity.Restaurant; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; +import org.springframework.stereotype.Component; + + +@NoArgsConstructor(access = AccessLevel.PRIVATE) +@Component +public class RestaurantMapper { + public Restaurant DtoToEntity(RegisterRestaurantDTO registerRestaurantDTO) { + return Restaurant.builder() + .name(registerRestaurantDTO.getName()) + .category(registerRestaurantDTO.getCategory()) + .build(); + } + + public InquiryRestaurantDTO DtoFromEntity(Restaurant restaurant) { + return InquiryRestaurantDTO.builder() + .id(restaurant.getId()) + .name(restaurant.getName()) + .category(restaurant.getCategory()) + .createdAt(restaurant.getCreatedAt()) + .build(); + } + + public UpdateRestaurantDTO UpdateFromEntity(Restaurant restaurant) { + return UpdateRestaurantDTO.builder() + .category(restaurant.getCategory()) + .updatedAt(restaurant.getUpdatedAt()) + .build(); + } + + +} \ No newline at end of file diff --git a/src/main/java/com/techeer/hackathon/domain/restaurant/entity/Restaurant.java b/src/main/java/com/techeer/hackathon/domain/restaurant/entity/Restaurant.java new file mode 100644 index 00000000..f204f5e9 --- /dev/null +++ b/src/main/java/com/techeer/hackathon/domain/restaurant/entity/Restaurant.java @@ -0,0 +1,45 @@ +package com.techeer.hackathon.domain.restaurant.entity; + +import com.techeer.hackathon.global.BaseEntity; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import javax.persistence.*; + +@Entity +@Getter +@NoArgsConstructor +@AllArgsConstructor +@Table(name="restaurant") +public class Restaurant extends BaseEntity { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "category", nullable = false) + private String category; + + @Column(name = "name", nullable = false) + private String name; + + @Column(name = "deleted", nullable = false) + private boolean deleted; + + @Builder + public Restaurant(String category, String name, boolean deleted) { + + this.category = category; + this.name = name; + this.deleted = false; + } + + public void setDeleted(boolean deleted) { + this.deleted = deleted; + } + + public void setCategory(String category) { + this.category = category; + } +} \ No newline at end of file diff --git a/src/main/java/com/techeer/hackathon/domain/restaurant/repository/RepositoryRestaurant.java b/src/main/java/com/techeer/hackathon/domain/restaurant/repository/RepositoryRestaurant.java new file mode 100644 index 00000000..12565540 --- /dev/null +++ b/src/main/java/com/techeer/hackathon/domain/restaurant/repository/RepositoryRestaurant.java @@ -0,0 +1,15 @@ +package com.techeer.hackathon.domain.restaurant.repository; + +import com.techeer.hackathon.domain.restaurant.entity.Restaurant; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Optional; + +@Repository +public interface RepositoryRestaurant extends JpaRepository { + Optional findByIdAndDeletedIsFalse(Long id); + List findByDeletedFalse(); + List findByCategoryAndDeletedFalse(String category); +} diff --git a/src/main/java/com/techeer/hackathon/domain/restaurant/service/ServiceRestaurant.java b/src/main/java/com/techeer/hackathon/domain/restaurant/service/ServiceRestaurant.java new file mode 100644 index 00000000..654a16d0 --- /dev/null +++ b/src/main/java/com/techeer/hackathon/domain/restaurant/service/ServiceRestaurant.java @@ -0,0 +1,75 @@ +package com.techeer.hackathon.domain.restaurant.service; + +import com.techeer.hackathon.domain.restaurant.dto.InquiryRestaurantDTO; +import com.techeer.hackathon.domain.restaurant.dto.RegisterRestaurantDTO; +import com.techeer.hackathon.domain.restaurant.dto.UpdateRestaurantDTO; +import com.techeer.hackathon.domain.restaurant.dto.mapper.RestaurantMapper; +import com.techeer.hackathon.domain.restaurant.entity.Restaurant; +import com.techeer.hackathon.domain.restaurant.repository.RepositoryRestaurant; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.webjars.NotFoundException; + +import javax.persistence.EntityNotFoundException; +import javax.transaction.Transactional; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +@Service +@RequiredArgsConstructor +@Transactional +public class ServiceRestaurant { + private final RepositoryRestaurant Res_Repo; + private final RestaurantMapper Res_Mapper; + + public Restaurant insertRestaurant(RegisterRestaurantDTO registerRestaurantDTO) { + return Res_Repo.save(Res_Mapper.DtoToEntity(registerRestaurantDTO)); + } + + public List getAllRestaurants(){ + + return Res_Repo.findAll(); + } + + public void deleteRestaurant(Long id) { + Restaurant restaurant = getRestaurantById(id); + restaurant.setDeleted(true); + Res_Repo.save(restaurant); + } + + private Restaurant getRestaurantById(Long id) { + return Res_Repo.findByIdAndDeletedIsFalse(id) + .orElseThrow(() -> new NotFoundException("Restaurant no found")); + } + + public List getRestaurantsByCategory(String category) { + List restaurants = Res_Repo.findByCategoryAndDeletedFalse(category); + return restaurants.stream() + .map(Res_Mapper::DtoFromEntity) + .collect(Collectors.toList()); + } + +// public InquiryRestaurantDTO getRestaurant(Long id) { +// Restaurant restaurant = Res_Repo.findById(id) +// .orElseThrow(() -> new NotFoundException("Restaurant not found")); +// +// return Res_Mapper.DtoFromEntity(restaurant); +// } + public Restaurant getRestaurantByIdAndDeletedIsFalse(Long id) { + Optional optionalRestaurant = Res_Repo.findByIdAndDeletedIsFalse(id); + if (optionalRestaurant.isEmpty()) { + throw new RuntimeException(); + } + return optionalRestaurant.get(); + } + + public UpdateRestaurantDTO updateRestaurantCategory(Long id, String newCategory){ + Restaurant restaurant = Res_Repo.findById(id).orElseThrow( + () -> new EntityNotFoundException("Restaurant not found with id " + id)); + restaurant.setCategory(newCategory); + Res_Repo.save(restaurant); + return Res_Mapper.UpdateFromEntity(restaurant); + } + +} diff --git a/src/main/java/com/techeer/hackathon/domain/review/controller/ControllerReview.java b/src/main/java/com/techeer/hackathon/domain/review/controller/ControllerReview.java new file mode 100644 index 00000000..77106a06 --- /dev/null +++ b/src/main/java/com/techeer/hackathon/domain/review/controller/ControllerReview.java @@ -0,0 +1,85 @@ +package com.techeer.hackathon.domain.review.controller; + +import com.techeer.hackathon.domain.review.dto.CreateReviewDTO; +import com.techeer.hackathon.domain.review.dto.InquiryReviewDTO; +import com.techeer.hackathon.domain.review.dto.UpdateReviewDTO; +import com.techeer.hackathon.domain.review.dto.mapper.ReviewMapper; +import com.techeer.hackathon.domain.review.entity.Review; +import com.techeer.hackathon.domain.review.service.ServiceReview; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.util.List; +import java.util.stream.Collectors; + +@Controller +@RequestMapping("/api/v1/review") +@RestController +@RequiredArgsConstructor +public class ControllerReview { + private final ServiceReview Rev_Serv; + private final ReviewMapper Rev_Mapper; + + @PostMapping("/register") + @ResponseStatus(HttpStatus.CREATED) + public ResponseEntity createReview( + @RequestBody @Valid CreateReviewDTO createReviewDTO) { + Review insertReview = Rev_Serv.insertReview(createReviewDTO); + return new ResponseEntity(Rev_Mapper.ReviewEntityToDto(insertReview), HttpStatus.CREATED); + } + + @GetMapping("/{id}") + public ResponseEntity getReview(@PathVariable Long id) { + InquiryReviewDTO review = Rev_Serv.getReview(id); + return ResponseEntity.ok().body(review); + } + + @DeleteMapping("/{id}") + @ResponseStatus(HttpStatus.NO_CONTENT) + public void deleteReview(@PathVariable("id") Long id) { + Rev_Serv.deleteReview(id); + } + + @PutMapping("/{id}") + public ResponseEntity updateReview(@PathVariable Long id, @RequestBody UpdateReviewDTO updateReviewDTO) { + InquiryReviewDTO result = Rev_Serv.updateReview(id, updateReviewDTO); + return ResponseEntity.status(HttpStatus.OK).body(result); + } + + @GetMapping("/search") + public ResponseEntity getReviewsForSearch( + @RequestParam(defaultValue = "0") Integer page, + @RequestParam(defaultValue = "10") Integer size, + @RequestParam(required = false) String title, + @RequestParam(required = false) String content) { + return ResponseEntity.ok(Rev_Serv.getReviewForSearch(page, size, title, content)); + } + + @GetMapping("/list") + public List getReviewsByCreatedTime() { + List reviews = Rev_Serv.getReviewsByCreatedTime(); + return reviews.stream() + .map(this::mapToInquiryReviewDTO) + .collect(Collectors.toList()); + } + + @GetMapping("/list/reverse") + public List getReviewsByReverseCreatedTime() { + List reviews = Rev_Serv.getReviewsByReverseCreatedTime(); + return reviews.stream() + .map(this::mapToInquiryReviewDTO) + .collect(Collectors.toList()); + } + private InquiryReviewDTO mapToInquiryReviewDTO(Review review) { + return InquiryReviewDTO.builder() + .id(review.getId()) + .restaurantName(review.getRestaurant().getName()) + .title(review.getTitle()) + .content(review.getContent()) + .build(); + } +} diff --git a/src/main/java/com/techeer/hackathon/domain/review/dto/CreateReviewDTO.java b/src/main/java/com/techeer/hackathon/domain/review/dto/CreateReviewDTO.java new file mode 100644 index 00000000..3c21683a --- /dev/null +++ b/src/main/java/com/techeer/hackathon/domain/review/dto/CreateReviewDTO.java @@ -0,0 +1,16 @@ +package com.techeer.hackathon.domain.review.dto; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +import javax.validation.constraints.NotNull; + +@Getter +@RequiredArgsConstructor +public class CreateReviewDTO { + @NotNull + private Long restaurantId; + @NotNull + private String title; + private String content; +} diff --git a/src/main/java/com/techeer/hackathon/domain/review/dto/InquiryReviewDTO.java b/src/main/java/com/techeer/hackathon/domain/review/dto/InquiryReviewDTO.java new file mode 100644 index 00000000..3e289b0e --- /dev/null +++ b/src/main/java/com/techeer/hackathon/domain/review/dto/InquiryReviewDTO.java @@ -0,0 +1,14 @@ +package com.techeer.hackathon.domain.review.dto; + +import lombok.Builder; +import lombok.Getter; + +@Builder +@Getter +public class InquiryReviewDTO { + private Long id; + private String restaurantName; + private String title; + private String content; + +} \ No newline at end of file diff --git a/src/main/java/com/techeer/hackathon/domain/review/dto/UpdateReviewDTO.java b/src/main/java/com/techeer/hackathon/domain/review/dto/UpdateReviewDTO.java new file mode 100644 index 00000000..84ec64d7 --- /dev/null +++ b/src/main/java/com/techeer/hackathon/domain/review/dto/UpdateReviewDTO.java @@ -0,0 +1,15 @@ +package com.techeer.hackathon.domain.review.dto; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +import javax.validation.constraints.NotNull; + +@Getter +@RequiredArgsConstructor +public class UpdateReviewDTO { + @NotNull + private String title; + @NotNull + private String content; +} diff --git a/src/main/java/com/techeer/hackathon/domain/review/dto/mapper/ReviewMapper.java b/src/main/java/com/techeer/hackathon/domain/review/dto/mapper/ReviewMapper.java new file mode 100644 index 00000000..3795a3e5 --- /dev/null +++ b/src/main/java/com/techeer/hackathon/domain/review/dto/mapper/ReviewMapper.java @@ -0,0 +1,41 @@ +package com.techeer.hackathon.domain.review.dto.mapper; + +import com.techeer.hackathon.domain.restaurant.entity.Restaurant; +import com.techeer.hackathon.domain.restaurant.repository.RepositoryRestaurant; +import com.techeer.hackathon.domain.review.dto.CreateReviewDTO; +import com.techeer.hackathon.domain.review.dto.InquiryReviewDTO; +import com.techeer.hackathon.domain.review.entity.Review; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.stream.Collectors; + +@RequiredArgsConstructor +//@NoArgsConstructor(access = AccessLevel.PRIVATE) +@Component +public class ReviewMapper { + private final RepositoryRestaurant Res_Repo; + public Review ReviewDtoToEntity(CreateReviewDTO createReviewDTO) { + Restaurant restaurant = Res_Repo.findById(createReviewDTO.getRestaurantId()).orElseThrow(RuntimeException::new); + return Review.builder() + .title(createReviewDTO.getTitle()) + .content(createReviewDTO.getContent()) + .restaurant(restaurant) + .build(); + } + public InquiryReviewDTO ReviewEntityToDto(Review review) { + return InquiryReviewDTO.builder() + .id(review.getId()) + .title(review.getTitle()) + .content(review.getContent()) + .restaurantName(review.getRestaurant().getName()) + .build(); + } + + public List inquiryReviewDTOListFromEntity(Page reviewPage) { + List inquiryReviewDTOList = reviewPage.stream().map(this::ReviewEntityToDto).collect(Collectors.toList()); + return inquiryReviewDTOList; + } +} diff --git a/src/main/java/com/techeer/hackathon/domain/review/entity/Review.java b/src/main/java/com/techeer/hackathon/domain/review/entity/Review.java new file mode 100644 index 00000000..c2a8a22c --- /dev/null +++ b/src/main/java/com/techeer/hackathon/domain/review/entity/Review.java @@ -0,0 +1,54 @@ +package com.techeer.hackathon.domain.review.entity; + +import com.techeer.hackathon.domain.restaurant.entity.Restaurant; +import com.techeer.hackathon.global.BaseEntity; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import javax.persistence.*; + +@Entity +@Getter +@NoArgsConstructor +@AllArgsConstructor +@Table(name="review") +public class Review extends BaseEntity { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "restaurant", nullable = false) + private Restaurant restaurant; + + @Column(name = "title", nullable = false) + private String title; + + @Column(name = "content", nullable = false) + private String content; + + @Column(name = "deleted", nullable = false) + private boolean deleted; + + @Builder + public Review(String title, String content, Restaurant restaurant, boolean deleted){ + this.title = title; + this.content = content; + this.restaurant = restaurant; + this.deleted = false; + } + + public void setDeleted(boolean deleted) { + this.deleted = deleted; + } + + public void setTitle(String title) { + this.title = title; + } + + public void setContent(String content) { + this.content = content; + } +} \ No newline at end of file diff --git a/src/main/java/com/techeer/hackathon/domain/review/repository/RepositoryReview.java b/src/main/java/com/techeer/hackathon/domain/review/repository/RepositoryReview.java new file mode 100644 index 00000000..e2d62d76 --- /dev/null +++ b/src/main/java/com/techeer/hackathon/domain/review/repository/RepositoryReview.java @@ -0,0 +1,23 @@ +package com.techeer.hackathon.domain.review.repository; + +import com.techeer.hackathon.domain.review.entity.Review; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; + +import java.util.List; +import java.util.Optional; + +public interface RepositoryReview extends JpaRepository { + Optional findByIdAndDeletedFalse(Long id); + + @Query(value = "SELECT r\n " + + "FROM Review r\n " + + "WHERE (r.title = '' OR r.title Like CONCAT('%', :title, '%'))\n " + + "AND (r.content = '' OR r.content Like CONCAT('%', :content, '%'))\n") + Page findAllBySearch(String title, String content, Pageable pageable); + + List findAllByOrderByCreatedAtAsc(); + List findAllByOrderByCreatedAtDesc(); +} diff --git a/src/main/java/com/techeer/hackathon/domain/review/service/ServiceReview.java b/src/main/java/com/techeer/hackathon/domain/review/service/ServiceReview.java new file mode 100644 index 00000000..26c3d48b --- /dev/null +++ b/src/main/java/com/techeer/hackathon/domain/review/service/ServiceReview.java @@ -0,0 +1,75 @@ +package com.techeer.hackathon.domain.review.service; + +import com.techeer.hackathon.domain.restaurant.entity.Restaurant; +import com.techeer.hackathon.domain.restaurant.repository.RepositoryRestaurant; +import com.techeer.hackathon.domain.review.dto.CreateReviewDTO; +import com.techeer.hackathon.domain.review.dto.InquiryReviewDTO; +import com.techeer.hackathon.domain.review.dto.UpdateReviewDTO; +import com.techeer.hackathon.domain.review.dto.mapper.ReviewMapper; +import com.techeer.hackathon.domain.review.entity.Review; +import com.techeer.hackathon.domain.review.repository.RepositoryReview; +import lombok.RequiredArgsConstructor; + +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.webjars.NotFoundException; + +import java.util.List; + +@Service +@RequiredArgsConstructor +public class ServiceReview { + private final RepositoryReview Rev_Repo; + private final ReviewMapper Rev_Mapper; + private final RepositoryRestaurant Res_Repo; + + public Review insertReview(CreateReviewDTO createReviewDTO) { + return Rev_Repo.save(Rev_Mapper.ReviewDtoToEntity(createReviewDTO)); + } + + public InquiryReviewDTO getReview(Long id) { + Review review = Rev_Repo.findById(id) + .orElseThrow(() -> new NotFoundException("Review not found")); + return Rev_Mapper.ReviewEntityToDto(review); + } + + public void deleteReview(Long id) { + Review review = Rev_Repo.findByIdAndDeletedFalse(id) + .orElseThrow(() -> new NotFoundException("Review is not found")); + review.setDeleted(true); + Rev_Repo.delete(review); + } + + public InquiryReviewDTO updateReview(Long id, UpdateReviewDTO updateReviewDTO) { + Review review = Rev_Repo.findById(id) + .orElseThrow(() -> new RuntimeException()); + + review.setTitle(updateReviewDTO.getTitle()); + review.setContent(updateReviewDTO.getContent()); + + Restaurant restaurant = Res_Repo.findById(review.getRestaurant().getId()) + .orElseThrow(() -> new RuntimeException()); + InquiryReviewDTO inquiryReviewDTO = InquiryReviewDTO.builder() + .id(review.getId()) + .restaurantName(restaurant.getName()) + .title(review.getTitle()) + .content(review.getContent()) + .build(); + return inquiryReviewDTO; + } + + public Object getReviewForSearch(Integer page, Integer size, String title, String content) { + Pageable pageable = PageRequest.of(page, size); + return Rev_Mapper.inquiryReviewDTOListFromEntity(Rev_Repo.findAllBySearch(title, content, pageable)); + } + + public List getReviewsByCreatedTime() { + return Rev_Repo.findAllByOrderByCreatedAtAsc(); + } + + public List getReviewsByReverseCreatedTime() { + return Rev_Repo.findAllByOrderByCreatedAtDesc(); + } + +} diff --git a/src/main/java/com/techeer/hackathon/global/BaseEntity.java b/src/main/java/com/techeer/hackathon/global/BaseEntity.java new file mode 100644 index 00000000..50db78f4 --- /dev/null +++ b/src/main/java/com/techeer/hackathon/global/BaseEntity.java @@ -0,0 +1,30 @@ +package com.techeer.hackathon.global; + +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; + +@MappedSuperclass +@EntityListeners(AuditingEntityListener.class) +public abstract class BaseEntity { + @CreatedDate + @Column(name = "created_at", nullable = false, updatable = false) + private LocalDateTime createdAt; + + @LastModifiedDate + @Column(name = "updated_at", nullable = false) + private LocalDateTime updatedAt; + + public LocalDateTime getCreatedAt() { + return createdAt; + } + + public LocalDateTime getUpdatedAt() { + return updatedAt; + } +} \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 00000000..5272f25d --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,20 @@ +spring: + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://localhost:3306/restaurant + username: root + password: qorgksruf123 + + jpa: + hibernate: + ddl-auto : create #update + properties: + hibernate: + format_sql: true + use_sql_comments: true + show_sql: true + +logging: + level: + org: + hibernate: info \ No newline at end of file diff --git a/src/test/java/com/techeer/hackathon/TecheerApplicationTests.java b/src/test/java/com/techeer/hackathon/TecheerApplicationTests.java new file mode 100644 index 00000000..a504a07a --- /dev/null +++ b/src/test/java/com/techeer/hackathon/TecheerApplicationTests.java @@ -0,0 +1,13 @@ +package com.techeer.hackathon; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class TecheerApplicationTests { + + @Test + void contextLoads() { + } + +}