From 8fe1e682d04a5eb5f8f08da43a5d0e34cfd5cdc5 Mon Sep 17 00:00:00 2001 From: crusader Date: Tue, 16 Jul 2019 23:56:13 +0900 Subject: [PATCH] Initial commit --- .classpath | 55 ++++++++++++++++++ .project | 23 ++++++++ .settings/org.eclipse.core.resources.prefs | 6 ++ .settings/org.eclipse.jdt.apt.core.prefs | 2 + .settings/org.eclipse.jdt.core.prefs | 10 ++++ .settings/org.eclipse.m2e.core.prefs | 4 ++ .vscode/launch.json | 11 ++++ .vscode/settings.json | 3 + pom.xml | 55 ++++++++++++++++++ .../java/com/loafle/totopia/Application.java | 12 ++++ .../member/controller/MemberController.java | 55 ++++++++++++++++++ .../totopia/member/dao/MemberRepository.java | 9 +++ .../loafle/totopia/member/model/Member.java | 5 ++ src/main/resources/application.properties | 11 ++++ target/classes/application.properties | 11 ++++ .../com/loafle/totopia/Application.class | Bin 0 -> 725 bytes .../member/controller/MemberController.class | Bin 0 -> 2319 bytes .../totopia/member/dao/MemberRepository.class | Bin 0 -> 358 bytes .../loafle/totopia/member/model/Member.class | Bin 0 -> 307 bytes .../compile/default-compile/createdFiles.lst | 0 .../compile/default-compile/inputFiles.lst | 4 ++ 21 files changed, 276 insertions(+) create mode 100644 .classpath create mode 100644 .project create mode 100644 .settings/org.eclipse.core.resources.prefs create mode 100644 .settings/org.eclipse.jdt.apt.core.prefs create mode 100644 .settings/org.eclipse.jdt.core.prefs create mode 100644 .settings/org.eclipse.m2e.core.prefs create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 pom.xml create mode 100644 src/main/java/com/loafle/totopia/Application.java create mode 100644 src/main/java/com/loafle/totopia/member/controller/MemberController.java create mode 100644 src/main/java/com/loafle/totopia/member/dao/MemberRepository.java create mode 100644 src/main/java/com/loafle/totopia/member/model/Member.java create mode 100644 src/main/resources/application.properties create mode 100644 target/classes/application.properties create mode 100644 target/classes/com/loafle/totopia/Application.class create mode 100644 target/classes/com/loafle/totopia/member/controller/MemberController.class create mode 100644 target/classes/com/loafle/totopia/member/dao/MemberRepository.class create mode 100644 target/classes/com/loafle/totopia/member/model/Member.class create mode 100644 target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst create mode 100644 target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..9160320 --- /dev/null +++ b/.classpath @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..9749748 --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + gs-rest-service + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..29abf99 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,6 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/main/resources=UTF-8 +encoding//src/test/java=UTF-8 +encoding//src/test/resources=UTF-8 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.apt.core.prefs b/.settings/org.eclipse.jdt.apt.core.prefs new file mode 100644 index 0000000..d4313d4 --- /dev/null +++ b/.settings/org.eclipse.jdt.apt.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.apt.aptEnabled=false diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..951833c --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,10 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.methodParameters=generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore +org.eclipse.jdt.core.compiler.processAnnotations=disabled +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..f14e7df --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,11 @@ +{ + "configurations": [ + { + "type": "java", + "name": "CodeLens (Launch) - Application", + "request": "launch", + "mainClass": "com.loafle.totopia.Application", + "projectName": "gs-rest-service" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..e0f15db --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "java.configuration.updateBuildConfiguration": "automatic" +} \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..fe6e9b8 --- /dev/null +++ b/pom.xml @@ -0,0 +1,55 @@ + + + 4.0.0 + + com.loafle.outsourcing + totopia-rest + 0.0.1-SNAPSHOT + jar + totopia-rest + REST Project of Totopia + + + org.springframework.boot + spring-boot-starter-parent + 2.1.6.RELEASE + + + + + UTF-8 + UTF-8 + 1.8 + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-web + + + org.postgresql + postgresql + runtime + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + \ No newline at end of file diff --git a/src/main/java/com/loafle/totopia/Application.java b/src/main/java/com/loafle/totopia/Application.java new file mode 100644 index 0000000..f05f30c --- /dev/null +++ b/src/main/java/com/loafle/totopia/Application.java @@ -0,0 +1,12 @@ +package com.loafle.totopia; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } +} \ No newline at end of file diff --git a/src/main/java/com/loafle/totopia/member/controller/MemberController.java b/src/main/java/com/loafle/totopia/member/controller/MemberController.java new file mode 100644 index 0000000..661a639 --- /dev/null +++ b/src/main/java/com/loafle/totopia/member/controller/MemberController.java @@ -0,0 +1,55 @@ +package com.loafle.totopia.member.controller; + +import java.util.List; + +import com.loafle.totopia.member.model.Member; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class MemberController { + + @GetMapping("/employees") + public List all() { + return repository.findAll(); + } + + @PostMapping("/employees") + public Member newMember(@RequestBody Member newMember) { + return repository.save(newMember); + } + + // Single item + + @GetMapping("/employees/{id}") + public Member one(@PathVariable Long id) { + + return repository.findById(id) + .orElseThrow(() -> new MemberNotFoundException(id)); + } + + @PutMapping("/employees/{id}") + public Member replaceMember(@RequestBody Member newMember, @PathVariable Long id) { + + return repository.findById(id) + .map(employee -> { + employee.setName(newMember.getName()); + employee.setRole(newMember.getRole()); + return repository.save(employee); + }) + .orElseGet(() -> { + newMember.setId(id); + return repository.save(newMember); + }); + } + + @DeleteMapping("/employees/{id}") + public void deleteMember(@PathVariable Long id) { + repository.deleteById(id); + } +} \ No newline at end of file diff --git a/src/main/java/com/loafle/totopia/member/dao/MemberRepository.java b/src/main/java/com/loafle/totopia/member/dao/MemberRepository.java new file mode 100644 index 0000000..ce73c35 --- /dev/null +++ b/src/main/java/com/loafle/totopia/member/dao/MemberRepository.java @@ -0,0 +1,9 @@ +package com.loafle.totopia.member.dao; + +import com.loafle.totopia.member.model.Member; + +import org.springframework.data.jpa.repository.JpaRepository; + +public interface MemberRepository extends JpaRepository { + +} diff --git a/src/main/java/com/loafle/totopia/member/model/Member.java b/src/main/java/com/loafle/totopia/member/model/Member.java new file mode 100644 index 0000000..d794a5e --- /dev/null +++ b/src/main/java/com/loafle/totopia/member/model/Member.java @@ -0,0 +1,5 @@ +package com.loafle.totopia.member.model; + +public class Member { + +} \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..250d69a --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,11 @@ +spring.datasource.url=jdbc:postgresql://localhost:5432/employees +spring.datasource.username=postgres +spring.datasource.password=root +spring.jpa.show-sql=true + +## Hibernate Properties +# The SQL dialect makes Hibernate generate better SQL for the chosen database +spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect + +# Hibernate ddl auto (create, create-drop, validate, update) +spring.jpa.hibernate.ddl-auto = update \ No newline at end of file diff --git a/target/classes/application.properties b/target/classes/application.properties new file mode 100644 index 0000000..250d69a --- /dev/null +++ b/target/classes/application.properties @@ -0,0 +1,11 @@ +spring.datasource.url=jdbc:postgresql://localhost:5432/employees +spring.datasource.username=postgres +spring.datasource.password=root +spring.jpa.show-sql=true + +## Hibernate Properties +# The SQL dialect makes Hibernate generate better SQL for the chosen database +spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect + +# Hibernate ddl auto (create, create-drop, validate, update) +spring.jpa.hibernate.ddl-auto = update \ No newline at end of file diff --git a/target/classes/com/loafle/totopia/Application.class b/target/classes/com/loafle/totopia/Application.class new file mode 100644 index 0000000000000000000000000000000000000000..2da7a23ef70ff1df7c63775e70096e0811741b45 GIT binary patch literal 725 zcmaJfgc5Ph2_P3i`krcfwff?JvcdqG@MRf0%8xlj=l4xHBR#@%A?MC*0oZ*c-~ z=nvpWq0YLM;zPv2GoG(EGjI0qzdzRi-r#u`ErAy)6*4Ea$hGw3X=#*vw_N5XRo;;8 zqAf7ER98yo%4YIoa;Z}w zUpQ6h@8rJ8gviTT?QHDU#{)d%4P3>*$*6%l%~e@W)^&>4!KY-s{^8}6?80P~3kx>- zusejq63S(~?%oT&hn@AaKxtd>uFtIQUdqZwfs(r3pQ) zC10P7Yme8CS~H<4PdsxytG?sqJyXu|&} zguw~hEc>?!tnab4h5OiHkWl=#1_OFSG5(FgmsNel5g@7&Rv10(;}QEG^Vi|)vufd> NmQV1Mb!htxxBh`OM0ynrA}h>Dk(3`#&rj8EO&0>$oh>~tZ-_%lrW z8$OX}qVN7FGz%UozwQ`udm+$UkYbk=ZB)wVB4oFHCDEPIf^B6K^JT!bRQq-z zQ4!S`o5JXJSE=5vo|0S|rU;0WvmcoBH|}at0JfGkwe`NwPOB6G30@@7h4mz8fmI74 zAG;tLitA5R8#$~|lQf;~YPnVwX}Cq;QygJxdrpz%A1c_1*9R78RlEM9m4wHw$9)`G zRj!0I%o6w}*yA2|F@+%(q~f%(`+d<~Ca{h7(ZIN-s<=L(<$ zNBD-|H-$3?dxCxY^Z}&5;2;53#R#AW&fvH+GQhqIX9T)&Jqf*`?OEu-jyigO1G-g1AB8b!tD#3 literal 0 HcmV?d00001 diff --git a/target/classes/com/loafle/totopia/member/dao/MemberRepository.class b/target/classes/com/loafle/totopia/member/dao/MemberRepository.class new file mode 100644 index 0000000000000000000000000000000000000000..30db8fa95057c3c98a0adc3b7c416b5727570ea1 GIT binary patch literal 358 zcmbV|Jx&8L5Jo>IfhD1#;To9+s*NZqqD4sL1e49g@?!5;jsv3RRumk7Lm|ux0g6OJ zF+auVdwTQs{_+ao0;d&52J=<}dF8Da%9=GgrXXQ0i8icsGpu(Kb?36CrwS8;vyLB_ zJolDv*PXPv!m+`nCQG}RTyM9DgFI@wFBzGsi%jV|f|ikg0u5#>-KSQrofm`iL*V?A zWiVYi+jHKha`W6A^6Tbb>_zjpe9(>fFa7!#u+iSuS9S3<7?(OKzXV38hJJ$SFlQgs CqjPHj literal 0 HcmV?d00001 diff --git a/target/classes/com/loafle/totopia/member/model/Member.class b/target/classes/com/loafle/totopia/member/model/Member.class new file mode 100644 index 0000000000000000000000000000000000000000..e9f8d95fd357227f88fefa84289366db53db39fc GIT binary patch literal 307 zcma)%v2MaJ5QhH?34uTh;tg03FyMu)RhLSgQW!w&PH>Bn6Qf}IUY#m+-~o6j)N{%M zu>9xmtUG;ox&EF3%+Ze#5JtHzgt79&DB-NL2Q5XRicD3auv=xsdkrx{LVqv6q%gAl z6w7R{az|)B>r%THLSsDH5W-iUNzg#MiwI3ZFV&@5oczAE%#0!oQkzS&k(Ks*Yld#8 zkA!i0pUo2?S=m#St2ga;cK#)2-VZ~t4POYZo(|>~pI-K45 O9dUhNB0O>i==}l5A4OXL literal 0 HcmV?d00001 diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..5247055 --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,4 @@ +/home/crusader/Projects/git.loafle.net/outsourcing/totopia/totopia-rest/src/main/java/com/loafle/totopia/member/controller/MemberController.java +/home/crusader/Projects/git.loafle.net/outsourcing/totopia/totopia-rest/src/main/java/com/loafle/totopia/member/dao/MemberRepository.java +/home/crusader/Projects/git.loafle.net/outsourcing/totopia/totopia-rest/src/main/java/com/loafle/totopia/Application.java +/home/crusader/Projects/git.loafle.net/outsourcing/totopia/totopia-rest/src/main/java/com/loafle/totopia/member/model/Member.java