commit 8fe1e682d04a5eb5f8f08da43a5d0e34cfd5cdc5 Author: crusader Date: Tue Jul 16 23:56:13 2019 +0900 Initial commit 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 0000000..2da7a23 Binary files /dev/null and b/target/classes/com/loafle/totopia/Application.class differ diff --git a/target/classes/com/loafle/totopia/member/controller/MemberController.class b/target/classes/com/loafle/totopia/member/controller/MemberController.class new file mode 100644 index 0000000..a87f5be Binary files /dev/null and b/target/classes/com/loafle/totopia/member/controller/MemberController.class differ 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 0000000..30db8fa Binary files /dev/null and b/target/classes/com/loafle/totopia/member/dao/MemberRepository.class differ 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 0000000..e9f8d95 Binary files /dev/null and b/target/classes/com/loafle/totopia/member/model/Member.class differ 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