├── NMC_EPC_PROCESS.xml ├── model ├── .settings │ ├── org.eclipse.m2e.core.prefs │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.jdt.core.prefs ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── tomniu │ │ │ │ ├── model │ │ │ │ ├── DeptRepository.java │ │ │ │ ├── DeptJson.java │ │ │ │ ├── Employee.java │ │ │ │ └── Department.java │ │ │ │ ├── Application.java │ │ │ │ └── config │ │ │ │ └── DatabaseConfig.java │ │ └── resources │ │ │ └── application.properties │ └── test │ │ └── java │ │ └── com │ │ └── tomniu │ │ └── model │ │ └── DeptRepositoryTest.java ├── target │ └── classes │ │ ├── META-INF │ │ ├── maven │ │ │ └── staffmanager │ │ │ │ └── model │ │ │ │ ├── pom.properties │ │ │ │ └── pom.xml │ │ └── MANIFEST.MF │ │ └── application.properties ├── .project ├── .classpath └── pom.xml ├── rest ├── .settings │ ├── org.eclipse.m2e.core.prefs │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.jdt.core.prefs ├── src │ └── main │ │ ├── webapp │ │ ├── index.jsp │ │ └── WEB-INF │ │ │ └── web.xml │ │ ├── resources │ │ └── application.properties │ │ └── java │ │ └── com │ │ └── tomniu │ │ ├── Application.java │ │ ├── controller │ │ └── DeptController.java │ │ └── config │ │ └── DatabaseConfig.java ├── target │ └── classes │ │ ├── META-INF │ │ ├── maven │ │ │ └── staffmanager │ │ │ │ └── rest │ │ │ │ ├── pom.properties │ │ │ │ └── pom.xml │ │ └── MANIFEST.MF │ │ └── application.properties ├── .project ├── pom.xml └── .classpath ├── oauth2 ├── .settings │ ├── org.eclipse.m2e.core.prefs │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.jdt.core.prefs ├── src │ └── main │ │ ├── webapp │ │ ├── index.jsp │ │ └── WEB-INF │ │ │ └── web.xml │ │ ├── resources │ │ └── application.properties │ │ └── java │ │ └── com │ │ └── tomniu │ │ ├── Application.java │ │ ├── config │ │ ├── SecurityConfig.java │ │ └── DatabaseConfig.java │ │ └── controller │ │ └── DeptController.java ├── target │ └── classes │ │ ├── META-INF │ │ ├── maven │ │ │ └── staffmanager │ │ │ │ └── oauth2 │ │ │ │ ├── pom.properties │ │ │ │ └── pom.xml │ │ └── MANIFEST.MF │ │ └── application.properties ├── .project ├── pom.xml └── .classpath ├── security ├── .settings │ ├── org.eclipse.m2e.core.prefs │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.jdt.core.prefs ├── src │ └── main │ │ ├── webapp │ │ ├── index.jsp │ │ └── WEB-INF │ │ │ └── web.xml │ │ ├── resources │ │ └── application.properties │ │ └── java │ │ └── com │ │ └── tomniu │ │ ├── Application.java │ │ ├── config │ │ ├── SecurityConfig.java │ │ └── DatabaseConfig.java │ │ └── controller │ │ └── DeptController.java ├── target │ └── classes │ │ ├── META-INF │ │ ├── maven │ │ │ └── staffmanager │ │ │ │ └── security │ │ │ │ ├── pom.properties │ │ │ │ └── pom.xml │ │ └── MANIFEST.MF │ │ └── application.properties ├── .project ├── pom.xml └── .classpath ├── Jenkinsfile ├── pom.xml └── README.md /NMC_EPC_PROCESS.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /model/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /rest/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /oauth2/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /security/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /oauth2/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | http://docs.spring.io/spring-data/rest/docs/current/reference/html/ 3 | 4 |

Hello World!

5 | 6 | 7 | -------------------------------------------------------------------------------- /rest/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | http://docs.spring.io/spring-data/rest/docs/current/reference/html/ 3 | 4 |

Hello World!

5 | 6 | 7 | -------------------------------------------------------------------------------- /security/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | http://docs.spring.io/spring-data/rest/docs/current/reference/html/ 3 | 4 |

Hello World!

5 | 6 | 7 | -------------------------------------------------------------------------------- /model/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding//src/test/java=UTF-8 5 | encoding/=UTF-8 6 | -------------------------------------------------------------------------------- /rest/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding//src/test/java=UTF-8 5 | encoding/=UTF-8 6 | -------------------------------------------------------------------------------- /oauth2/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding//src/test/java=UTF-8 5 | encoding/=UTF-8 6 | -------------------------------------------------------------------------------- /security/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding//src/test/java=UTF-8 5 | encoding/=UTF-8 6 | -------------------------------------------------------------------------------- /model/src/main/java/com/tomniu/model/DeptRepository.java: -------------------------------------------------------------------------------- 1 | package com.tomniu.model; 2 | 3 | import org.springframework.data.repository.CrudRepository; 4 | 5 | public interface DeptRepository extends CrudRepository { 6 | } 7 | -------------------------------------------------------------------------------- /oauth2/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | Archetype Created Web Application 7 | 8 | -------------------------------------------------------------------------------- /rest/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | Archetype Created Web Application 7 | 8 | -------------------------------------------------------------------------------- /security/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | Archetype Created Web Application 7 | 8 | -------------------------------------------------------------------------------- /model/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 3 | org.eclipse.jdt.core.compiler.compliance=1.8 4 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 5 | org.eclipse.jdt.core.compiler.source=1.8 6 | -------------------------------------------------------------------------------- /oauth2/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 3 | org.eclipse.jdt.core.compiler.compliance=1.8 4 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 5 | org.eclipse.jdt.core.compiler.source=1.8 6 | -------------------------------------------------------------------------------- /rest/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 3 | org.eclipse.jdt.core.compiler.compliance=1.8 4 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 5 | org.eclipse.jdt.core.compiler.source=1.8 6 | -------------------------------------------------------------------------------- /security/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 3 | org.eclipse.jdt.core.compiler.compliance=1.8 4 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 5 | org.eclipse.jdt.core.compiler.source=1.8 6 | -------------------------------------------------------------------------------- /rest/target/classes/META-INF/maven/staffmanager/rest/pom.properties: -------------------------------------------------------------------------------- 1 | #Generated by Maven Integration for Eclipse 2 | #Mon May 30 16:27:59 AEST 2016 3 | version=0.0.1-SNAPSHOT 4 | groupId=staffmanager 5 | m2e.projectName=rest 6 | m2e.projectLocation=C\:\\Work\\eclipse\\staffmanager\\rest 7 | artifactId=rest 8 | -------------------------------------------------------------------------------- /model/target/classes/META-INF/maven/staffmanager/model/pom.properties: -------------------------------------------------------------------------------- 1 | #Generated by Maven Integration for Eclipse 2 | #Mon May 30 16:27:59 AEST 2016 3 | version=0.0.1-SNAPSHOT 4 | groupId=staffmanager 5 | m2e.projectName=model 6 | m2e.projectLocation=C\:\\Work\\eclipse\\staffmanager\\model 7 | artifactId=model 8 | -------------------------------------------------------------------------------- /oauth2/target/classes/META-INF/maven/staffmanager/oauth2/pom.properties: -------------------------------------------------------------------------------- 1 | #Generated by Maven Integration for Eclipse 2 | #Mon May 30 16:27:59 AEST 2016 3 | version=0.0.1-SNAPSHOT 4 | groupId=staffmanager 5 | m2e.projectName=oauth2 6 | m2e.projectLocation=C\:\\Work\\eclipse\\staffmanager\\oauth2 7 | artifactId=oauth2 8 | -------------------------------------------------------------------------------- /security/target/classes/META-INF/maven/staffmanager/security/pom.properties: -------------------------------------------------------------------------------- 1 | #Generated by Maven Integration for Eclipse 2 | #Mon May 30 16:27:59 AEST 2016 3 | version=0.0.1-SNAPSHOT 4 | groupId=staffmanager 5 | m2e.projectName=security 6 | m2e.projectLocation=C\:\\Work\\eclipse\\staffmanager\\security 7 | artifactId=security 8 | -------------------------------------------------------------------------------- /model/target/classes/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Implementation-Title: model 3 | Implementation-Version: 0.0.1-SNAPSHOT 4 | Built-By: Administrator 5 | Implementation-Vendor-Id: staffmanager 6 | Build-Jdk: 1.8.0_73 7 | Created-By: Maven Integration for Eclipse 8 | Implementation-Vendor: Pivotal Software, Inc. 9 | 10 | -------------------------------------------------------------------------------- /rest/target/classes/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Implementation-Title: rest 3 | Implementation-Version: 0.0.1-SNAPSHOT 4 | Built-By: Administrator 5 | Implementation-Vendor-Id: staffmanager 6 | Build-Jdk: 1.8.0_73 7 | Created-By: Maven Integration for Eclipse 8 | Implementation-Vendor: Pivotal Software, Inc. 9 | 10 | -------------------------------------------------------------------------------- /oauth2/target/classes/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Implementation-Title: oauth2 3 | Implementation-Version: 0.0.1-SNAPSHOT 4 | Built-By: Administrator 5 | Implementation-Vendor-Id: staffmanager 6 | Build-Jdk: 1.8.0_73 7 | Created-By: Maven Integration for Eclipse 8 | Implementation-Vendor: Pivotal Software, Inc. 9 | 10 | -------------------------------------------------------------------------------- /security/target/classes/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Implementation-Title: security 3 | Implementation-Version: 0.0.1-SNAPSHOT 4 | Built-By: Administrator 5 | Implementation-Vendor-Id: staffmanager 6 | Build-Jdk: 1.8.0_73 7 | Created-By: Maven Integration for Eclipse 8 | Implementation-Vendor: Pivotal Software, Inc. 9 | 10 | -------------------------------------------------------------------------------- /Jenkinsfile: -------------------------------------------------------------------------------- 1 | pipeline { 2 | agent { 3 | docker { 4 | image 'maven:3-alpine' 5 | args '-v /root/.m2:/root/.m2' 6 | } 7 | } 8 | stages { 9 | stage('Build') { 10 | steps { 11 | sh 'mvn -B -DskipTests clean package' 12 | } 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /model/target/classes/application.properties: -------------------------------------------------------------------------------- 1 | # Database 2 | db.driver: com.mysql.jdbc.Driver 3 | db.url: jdbc:mysql:///hib_model 4 | db.username: root 5 | db.password: root 6 | 7 | # Hibernate 8 | hibernate.dialect: org.hibernate.dialect.MySQL5Dialect 9 | hibernate.show_sql: true 10 | hibernate.hbm2ddl.auto: update 11 | entitymanager.packagesToScan: com.tomniu.model -------------------------------------------------------------------------------- /oauth2/target/classes/application.properties: -------------------------------------------------------------------------------- 1 | # Database 2 | db.driver: com.mysql.jdbc.Driver 3 | db.url: jdbc:mysql:///hib_rest 4 | db.username: root 5 | db.password: root 6 | 7 | # Hibernate 8 | hibernate.dialect: org.hibernate.dialect.MySQL5Dialect 9 | hibernate.show_sql: true 10 | hibernate.hbm2ddl.auto: update 11 | entitymanager.packagesToScan: com.tomniu.model -------------------------------------------------------------------------------- /rest/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Database 2 | db.driver: com.mysql.jdbc.Driver 3 | db.url: jdbc:mysql:///hib_rest 4 | db.username: root 5 | db.password: root 6 | 7 | # Hibernate 8 | hibernate.dialect: org.hibernate.dialect.MySQL5Dialect 9 | hibernate.show_sql: true 10 | hibernate.hbm2ddl.auto: update 11 | entitymanager.packagesToScan: com.tomniu.model -------------------------------------------------------------------------------- /rest/target/classes/application.properties: -------------------------------------------------------------------------------- 1 | # Database 2 | db.driver: com.mysql.jdbc.Driver 3 | db.url: jdbc:mysql:///hib_rest 4 | db.username: root 5 | db.password: root 6 | 7 | # Hibernate 8 | hibernate.dialect: org.hibernate.dialect.MySQL5Dialect 9 | hibernate.show_sql: true 10 | hibernate.hbm2ddl.auto: update 11 | entitymanager.packagesToScan: com.tomniu.model -------------------------------------------------------------------------------- /security/target/classes/application.properties: -------------------------------------------------------------------------------- 1 | # Database 2 | db.driver: com.mysql.jdbc.Driver 3 | db.url: jdbc:mysql:///hib_rest 4 | db.username: root 5 | db.password: root 6 | 7 | # Hibernate 8 | hibernate.dialect: org.hibernate.dialect.MySQL5Dialect 9 | hibernate.show_sql: true 10 | hibernate.hbm2ddl.auto: update 11 | entitymanager.packagesToScan: com.tomniu.model -------------------------------------------------------------------------------- /model/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Database 2 | db.driver: com.mysql.jdbc.Driver 3 | db.url: jdbc:mysql:///hib_model 4 | db.username: root 5 | db.password: root 6 | 7 | # Hibernate 8 | hibernate.dialect: org.hibernate.dialect.MySQL5Dialect 9 | hibernate.show_sql: true 10 | hibernate.hbm2ddl.auto: update 11 | entitymanager.packagesToScan: com.tomniu.model -------------------------------------------------------------------------------- /oauth2/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Database 2 | db.driver: com.mysql.jdbc.Driver 3 | db.url: jdbc:mysql:///hib_rest 4 | db.username: root 5 | db.password: root 6 | 7 | # Hibernate 8 | hibernate.dialect: org.hibernate.dialect.MySQL5Dialect 9 | hibernate.show_sql: true 10 | hibernate.hbm2ddl.auto: update 11 | entitymanager.packagesToScan: com.tomniu.model -------------------------------------------------------------------------------- /security/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Database 2 | db.driver: com.mysql.jdbc.Driver 3 | db.url: jdbc:mysql:///hib_rest 4 | db.username: root 5 | db.password: root 6 | 7 | # Hibernate 8 | hibernate.dialect: org.hibernate.dialect.MySQL5Dialect 9 | hibernate.show_sql: true 10 | hibernate.hbm2ddl.auto: update 11 | entitymanager.packagesToScan: com.tomniu.model -------------------------------------------------------------------------------- /rest/src/main/java/com/tomniu/Application.java: -------------------------------------------------------------------------------- 1 | package com.tomniu; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /model/src/main/java/com/tomniu/Application.java: -------------------------------------------------------------------------------- 1 | package com.tomniu; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /oauth2/src/main/java/com/tomniu/Application.java: -------------------------------------------------------------------------------- 1 | package com.tomniu; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /security/src/main/java/com/tomniu/Application.java: -------------------------------------------------------------------------------- 1 | package com.tomniu; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Application { 8 | // TODO 9 | public static void main(String[] args) { 10 | SpringApplication.run(Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /model/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | model 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /oauth2/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | rest 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /rest/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | rest 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /security/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | rest 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /model/src/main/java/com/tomniu/model/DeptJson.java: -------------------------------------------------------------------------------- 1 | package com.tomniu.model; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | public class DeptJson { 7 | private Department dept; 8 | private Set emps = new HashSet(); 9 | 10 | public DeptJson(){} 11 | 12 | public DeptJson(Department dept, Set emps) { 13 | super(); 14 | this.dept = dept; 15 | this.emps = emps; 16 | this.dept.setEmps(emps); 17 | } 18 | public Department getDept() { 19 | return dept; 20 | } 21 | public void setDept(Department dept) { 22 | this.dept = dept; 23 | this.dept.setEmps(this.emps); 24 | } 25 | public Set getEmps() { 26 | return emps; 27 | } 28 | public void setEmps(Set emps) { 29 | this.emps = emps; 30 | this.dept.setEmps(this.emps); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /rest/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | staffmanager 8 | staffmanager 9 | 0.0.1-SNAPSHOT 10 | 11 | 12 | rest 13 | 14 | 15 | 16 | 17 | staffmanager 18 | model 19 | 0.0.1-SNAPSHOT 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-web 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /rest/target/classes/META-INF/maven/staffmanager/rest/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | staffmanager 8 | staffmanager 9 | 0.0.1-SNAPSHOT 10 | 11 | 12 | rest 13 | 14 | 15 | 16 | 17 | staffmanager 18 | model 19 | 0.0.1-SNAPSHOT 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-web 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /security/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | staffmanager 7 | staffmanager 8 | 0.0.1-SNAPSHOT 9 | 10 | 11 | security 12 | 13 | 14 | ${project.groupId} 15 | model 16 | ${project.version} 17 | 18 | 19 | 20 | org.springframework.boot 21 | spring-boot-starter-web 22 | 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-security 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /security/target/classes/META-INF/maven/staffmanager/security/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | staffmanager 7 | staffmanager 8 | 0.0.1-SNAPSHOT 9 | 10 | 11 | security 12 | 13 | 14 | ${project.groupId} 15 | model 16 | ${project.version} 17 | 18 | 19 | 20 | org.springframework.boot 21 | spring-boot-starter-web 22 | 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-security 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /security/src/main/java/com/tomniu/config/SecurityConfig.java: -------------------------------------------------------------------------------- 1 | package com.tomniu.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 5 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 6 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 7 | import org.springframework.security.config.annotation.web.servlet.configuration.EnableWebMvcSecurity; 8 | 9 | @SuppressWarnings("deprecation") 10 | @Configuration 11 | @EnableWebMvcSecurity 12 | public class SecurityConfig extends WebSecurityConfigurerAdapter { 13 | @Override 14 | protected void configure(AuthenticationManagerBuilder auth) throws Exception { 15 | auth.inMemoryAuthentication() 16 | .withUser("root").password("root").roles("USER"); 17 | } 18 | @Override 19 | protected void configure(HttpSecurity http) throws Exception { 20 | http.authorizeRequests().anyRequest().fullyAuthenticated(); 21 | http.httpBasic(); 22 | http.csrf().disable(); 23 | } 24 | } -------------------------------------------------------------------------------- /oauth2/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | oauth2 6 | 7 | 8 | staffmanager 9 | staffmanager 10 | 0.0.1-SNAPSHOT 11 | 12 | 13 | 14 | 15 | ${project.groupId} 16 | model 17 | ${project.version} 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-web 23 | 24 | 25 | 26 | org.springframework.boot 27 | spring-boot-starter-security 28 | 29 | 30 | 31 | org.springframework.security.oauth 32 | spring-security-oauth2 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /oauth2/target/classes/META-INF/maven/staffmanager/oauth2/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | oauth2 6 | 7 | 8 | staffmanager 9 | staffmanager 10 | 0.0.1-SNAPSHOT 11 | 12 | 13 | 14 | 15 | ${project.groupId} 16 | model 17 | ${project.version} 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-web 23 | 24 | 25 | 26 | org.springframework.boot 27 | spring-boot-starter-security 28 | 29 | 30 | 31 | org.springframework.security.oauth 32 | spring-security-oauth2 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /model/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /rest/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /oauth2/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /security/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /model/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | 8 | staffmanager 9 | staffmanager 10 | 0.0.1-SNAPSHOT 11 | 12 | 13 | model 14 | 15 | 16 | org.springframework.boot 17 | spring-boot-starter-web 18 | 19 | 20 | org.springframework.boot 21 | spring-boot-starter-data-jpa 22 | 23 | 24 | mysql 25 | mysql-connector-java 26 | 27 | 28 | 29 | junit 30 | junit 31 | test 32 | 33 | 34 | org.springframework 35 | spring-test 36 | test 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /model/target/classes/META-INF/maven/staffmanager/model/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | 8 | staffmanager 9 | staffmanager 10 | 0.0.1-SNAPSHOT 11 | 12 | 13 | model 14 | 15 | 16 | org.springframework.boot 17 | spring-boot-starter-web 18 | 19 | 20 | org.springframework.boot 21 | spring-boot-starter-data-jpa 22 | 23 | 24 | mysql 25 | mysql-connector-java 26 | 27 | 28 | 29 | junit 30 | junit 31 | test 32 | 33 | 34 | org.springframework 35 | spring-test 36 | test 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | staffmanager 6 | staffmanager 7 | 0.0.1-SNAPSHOT 8 | pom 9 | 10 | 11 | 12 | sonatype-snapshots 13 | https://oss.sonatype.org/content/repositories/snapshots 14 | 15 | 16 | 17 | 18 | org.springframework.boot 19 | spring-boot-starter-parent 20 | 1.3.5.RELEASE 21 | 22 | 23 | 24 | UTF-8 25 | 1.8 26 | 27 | 28 | rest 29 | model 30 | security 31 | oauth2 32 | 33 | 34 | 35 | org.springframework.plugin 36 | spring-plugin-core 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-test 41 | test 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /model/src/main/java/com/tomniu/model/Employee.java: -------------------------------------------------------------------------------- 1 | package com.tomniu.model; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Entity; 5 | import javax.persistence.Id; 6 | import javax.persistence.JoinColumn; 7 | import javax.persistence.ManyToOne; 8 | import javax.persistence.Table; 9 | 10 | import com.fasterxml.jackson.annotation.JsonIgnore; 11 | 12 | @Entity 13 | @Table(name="t_employee") 14 | public class Employee { 15 | @Id 16 | private int empId; 17 | @Column 18 | private String empName; 19 | @Column 20 | private double salary; 21 | @JsonIgnore 22 | @ManyToOne 23 | @JoinColumn(name="_deptId") 24 | private Department dept; 25 | 26 | public int getEmpId() { 27 | return empId; 28 | } 29 | 30 | public void setEmpId(int empId) { 31 | this.empId = empId; 32 | } 33 | 34 | public String getEmpName() { 35 | return empName; 36 | } 37 | 38 | public void setEmpName(String empName) { 39 | this.empName = empName; 40 | } 41 | 42 | public double getSalary() { 43 | return salary; 44 | } 45 | 46 | public void setSalary(double salary) { 47 | this.salary = salary; 48 | } 49 | 50 | public Department getDept() { 51 | return dept; 52 | } 53 | 54 | public void setDept(Department dept) { 55 | this.dept = dept; 56 | } 57 | 58 | @Override 59 | public String toString() { 60 | String empInfo = "[empId:" + empId + "][" + 61 | "empName:" + empName + "][" + 62 | "salary:" + salary + "]"; 63 | return empInfo; 64 | } 65 | 66 | 67 | } 68 | -------------------------------------------------------------------------------- /model/src/main/java/com/tomniu/model/Department.java: -------------------------------------------------------------------------------- 1 | package com.tomniu.model; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | import com.fasterxml.jackson.annotation.JsonIgnore; 7 | import javax.persistence.Column; 8 | import javax.persistence.Entity; 9 | import javax.persistence.GeneratedValue; 10 | import javax.persistence.GenerationType; 11 | import javax.persistence.Id; 12 | import javax.persistence.OneToMany; 13 | import javax.persistence.Table; 14 | 15 | @Entity 16 | @Table(name="t_department") 17 | public class Department { 18 | @Id 19 | @GeneratedValue(strategy=GenerationType.AUTO) 20 | private long deptId; 21 | @Column 22 | private String deptName; 23 | @JsonIgnore 24 | @OneToMany(mappedBy="dept") 25 | private Set emps = new HashSet(); 26 | 27 | public long getDeptId() { 28 | return deptId; 29 | } 30 | 31 | public void setDeptId(long deptId) { 32 | this.deptId = deptId; 33 | } 34 | 35 | public String getDeptName() { 36 | return deptName; 37 | } 38 | 39 | public void setDeptName(String deptName) { 40 | this.deptName = deptName; 41 | } 42 | public Set getEmps() { 43 | return emps; 44 | } 45 | public void setEmps(Set emps) { 46 | this.emps = emps; 47 | } 48 | 49 | @Override 50 | public String toString() { 51 | String deptInfo = "[deptI:" + deptId + "][" + 52 | "deptName:" + deptName + "]"; 53 | 54 | for (Employee emp: emps) { 55 | deptInfo += emp.toString(); 56 | } 57 | return deptInfo; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /model/src/test/java/com/tomniu/model/DeptRepositoryTest.java: -------------------------------------------------------------------------------- 1 | package com.tomniu.model; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import org.hibernate.Hibernate; 6 | import org.junit.*; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.test.SpringApplicationConfiguration; 11 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 12 | import org.springframework.transaction.annotation.Transactional; 13 | 14 | import com.tomniu.Application; 15 | 16 | 17 | @RunWith(SpringJUnit4ClassRunner.class) 18 | @SpringApplicationConfiguration(Application.class) 19 | public class DeptRepositoryTest { 20 | 21 | @Before 22 | @After 23 | public void init() { 24 | deptRepo.deleteAll(); 25 | } 26 | 27 | @Test 28 | public void testDeptRepoDeletAll() { 29 | int total = 0; 30 | deptRepo.deleteAll(); 31 | Iterable depts = deptRepo.findAll(); 32 | for(Department dept:depts){ 33 | total++; 34 | } 35 | assertEquals(0, total); 36 | System.out.println("total: " + total); 37 | System.out.println("ETR-140: " + total); 38 | } 39 | 40 | @Test 41 | public void testDeptRepoSave() { 42 | String name = "test123"; 43 | Department dept = new Department(); 44 | dept.setDeptName(name); 45 | Department dept1 = deptRepo.save(dept); 46 | 47 | assertEquals(name, dept1.getDeptName()); 48 | } 49 | 50 | @Test 51 | public void testDeptRepDeleteById(){ 52 | String name = "test123"; 53 | Department dept = new Department(); 54 | dept.setDeptName(name); 55 | Department dept1 = deptRepo.save(dept); 56 | deptRepo.delete(dept1.getDeptId()); 57 | 58 | int total = 0; 59 | deptRepo.deleteAll(); 60 | Iterable depts = deptRepo.findAll(); 61 | for(Department temp:depts){ 62 | total++; 63 | } 64 | assertEquals(0, total); 65 | } 66 | 67 | @Autowired 68 | private DeptRepository deptRepo; 69 | } 70 | -------------------------------------------------------------------------------- /oauth2/src/main/java/com/tomniu/config/SecurityConfig.java: -------------------------------------------------------------------------------- 1 | package com.tomniu.config; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.security.authentication.AuthenticationManager; 6 | import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 7 | import org.springframework.security.config.annotation.authentication.configurers.GlobalAuthenticationConfigurerAdapter; 8 | import org.springframework.security.core.Authentication; 9 | import org.springframework.security.core.AuthenticationException; 10 | import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer; 11 | import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter; 12 | import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer; 13 | import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer; 14 | import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer; 15 | 16 | @Configuration 17 | class WebSecurityConfiguration extends GlobalAuthenticationConfigurerAdapter { 18 | @Override 19 | public void init(AuthenticationManagerBuilder auth) throws Exception { 20 | auth.inMemoryAuthentication() 21 | .withUser("admin").password("123456").roles("USER"); 22 | } 23 | } 24 | 25 | @Configuration 26 | @EnableResourceServer 27 | @EnableAuthorizationServer 28 | class OAuth2ServerConfig extends AuthorizationServerConfigurerAdapter { 29 | String applicationName = "staffmanager"; 30 | @Autowired 31 | AuthenticationManagerBuilder authenticationManager; 32 | 33 | @Override 34 | public void configure(AuthorizationServerEndpointsConfigurer endpoints) 35 | throws Exception { 36 | 37 | endpoints.authenticationManager(new AuthenticationManager() { 38 | @Override 39 | public Authentication authenticate(Authentication authentication) 40 | throws AuthenticationException { 41 | return authenticationManager.getOrBuild().authenticate(authentication); 42 | } 43 | }); 44 | } 45 | 46 | @Override 47 | public void configure(ClientDetailsServiceConfigurer clients) throws Exception { 48 | 49 | clients.inMemory().withClient(applicationName) 50 | .authorizedGrantTypes("password", "authorization_code", "refresh_token") 51 | .authorities("ROLE_USER").scopes("write").resourceIds(applicationName) 52 | .secret("888888"); 53 | } 54 | } -------------------------------------------------------------------------------- /rest/src/main/java/com/tomniu/controller/DeptController.java: -------------------------------------------------------------------------------- 1 | package com.tomniu.controller; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.hibernate.Hibernate; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.http.HttpHeaders; 9 | import org.springframework.http.HttpStatus; 10 | import org.springframework.http.MediaType; 11 | import org.springframework.http.ResponseEntity; 12 | import org.springframework.transaction.annotation.Transactional; 13 | import org.springframework.web.bind.annotation.*; 14 | import org.springframework.web.util.UriComponentsBuilder; 15 | 16 | import com.tomniu.model.Department; 17 | import com.tomniu.model.DeptJson; 18 | import com.tomniu.model.DeptRepository; 19 | 20 | /** 21 | *

User: Tom Niu 22 | *

Version: 1.0 23 | */ 24 | 25 | @RestController 26 | public class DeptController { 27 | 28 | @Autowired 29 | private DeptRepository deptRepo; 30 | //-------------------Retrieve All Departments------------------------------ 31 | @RequestMapping(value="/dept", method = RequestMethod.GET) 32 | public ResponseEntity> listAllDepts() { 33 | Iterable depts = deptRepo.findAll(); 34 | List deptJsons = new ArrayList(); 35 | if(depts==null){ 36 | return new ResponseEntity>(HttpStatus.NO_CONTENT);//You many decide to return HttpStatus.NOT_FOUND 37 | } else { 38 | for (Department dept: depts) { 39 | DeptJson deptJson = new DeptJson(dept, dept.getEmps()); 40 | deptJsons.add(deptJson); 41 | } 42 | return new ResponseEntity>(deptJsons, HttpStatus.OK); 43 | } 44 | } 45 | //-------------------Retrieve One Departments by Dept Id------------------- 46 | @RequestMapping(value = "/dept/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) 47 | public ResponseEntity getUser(@PathVariable("id") long id) { 48 | System.out.println("Fetching User with id " + id); 49 | 50 | Department dept = deptRepo.findOne(id); 51 | if (dept == null) { 52 | System.out.println("dept with id " + id + " not found"); 53 | return new ResponseEntity(HttpStatus.NOT_FOUND); 54 | } else { 55 | System.out.println(dept.getDeptName()); 56 | System.out.println(dept.getEmps().size()); 57 | DeptJson deptInfo = new DeptJson(dept, dept.getEmps()); 58 | return new ResponseEntity(deptInfo, HttpStatus.OK); 59 | } 60 | } 61 | //-------------------Create new Department--------------------------------- 62 | @RequestMapping(value = "/dept", method = RequestMethod.POST) 63 | public ResponseEntity createUser(@RequestBody DeptJson deptJson, UriComponentsBuilder ucBuilder) { 64 | 65 | Department dept = deptJson.getDept(); 66 | System.out.println("Creating Dept " + deptJson.getDept()); 67 | dept = deptRepo.save(dept); 68 | System.out.println("saved Dept " + dept); 69 | HttpHeaders headers = new HttpHeaders(); 70 | headers.setLocation(ucBuilder.path("/dept/{id}").buildAndExpand(dept.getDeptId()).toUri()); 71 | return new ResponseEntity(headers, HttpStatus.CREATED); 72 | } 73 | } -------------------------------------------------------------------------------- /oauth2/src/main/java/com/tomniu/controller/DeptController.java: -------------------------------------------------------------------------------- 1 | package com.tomniu.controller; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.hibernate.Hibernate; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.http.HttpHeaders; 9 | import org.springframework.http.HttpStatus; 10 | import org.springframework.http.MediaType; 11 | import org.springframework.http.ResponseEntity; 12 | import org.springframework.transaction.annotation.Transactional; 13 | import org.springframework.web.bind.annotation.*; 14 | import org.springframework.web.util.UriComponentsBuilder; 15 | 16 | import com.tomniu.model.Department; 17 | import com.tomniu.model.DeptJson; 18 | import com.tomniu.model.DeptRepository; 19 | 20 | /** 21 | *

User: Tom Niu 22 | *

Version: 1.0 23 | */ 24 | 25 | @RestController 26 | public class DeptController { 27 | 28 | @Autowired 29 | private DeptRepository deptRepo; 30 | //-------------------Retrieve All Departments------------------------------ 31 | @RequestMapping(value="/dept", method = RequestMethod.GET) 32 | public ResponseEntity> listAllDepts() { 33 | Iterable depts = deptRepo.findAll(); 34 | List deptJsons = new ArrayList(); 35 | if(depts==null){ 36 | return new ResponseEntity>(HttpStatus.NO_CONTENT);//You many decide to return HttpStatus.NOT_FOUND 37 | } else { 38 | for (Department dept: depts) { 39 | DeptJson deptJson = new DeptJson(dept, dept.getEmps()); 40 | deptJsons.add(deptJson); 41 | } 42 | return new ResponseEntity>(deptJsons, HttpStatus.OK); 43 | } 44 | } 45 | //-------------------Retrieve One Departments by Dept Id------------------- 46 | @RequestMapping(value = "/dept/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) 47 | public ResponseEntity getUser(@PathVariable("id") long id) { 48 | System.out.println("Fetching Dept with id " + id); 49 | 50 | Department dept = deptRepo.findOne(id); 51 | if (dept == null) { 52 | System.out.println("dept with id " + id + " not found"); 53 | return new ResponseEntity(HttpStatus.NOT_FOUND); 54 | } else { 55 | System.out.println(dept.getDeptName()); 56 | System.out.println(dept.getEmps().size()); 57 | DeptJson deptInfo = new DeptJson(dept, dept.getEmps()); 58 | return new ResponseEntity(deptInfo, HttpStatus.OK); 59 | } 60 | } 61 | //-------------------Create new Department--------------------------------- 62 | @RequestMapping(value = "/dept", method = RequestMethod.POST) 63 | public ResponseEntity createUser(@RequestBody DeptJson deptJson, UriComponentsBuilder ucBuilder) { 64 | 65 | Department dept = deptJson.getDept(); 66 | System.out.println("Creating Dept " + deptJson.getDept()); 67 | dept = deptRepo.save(dept); 68 | System.out.println("saved Dept " + dept); 69 | HttpHeaders headers = new HttpHeaders(); 70 | headers.setLocation(ucBuilder.path("/dept/{id}").buildAndExpand(dept.getDeptId()).toUri()); 71 | return new ResponseEntity(headers, HttpStatus.CREATED); 72 | } 73 | } -------------------------------------------------------------------------------- /security/src/main/java/com/tomniu/controller/DeptController.java: -------------------------------------------------------------------------------- 1 | package com.tomniu.controller; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.hibernate.Hibernate; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.http.HttpHeaders; 9 | import org.springframework.http.HttpStatus; 10 | import org.springframework.http.MediaType; 11 | import org.springframework.http.ResponseEntity; 12 | import org.springframework.transaction.annotation.Transactional; 13 | import org.springframework.web.bind.annotation.*; 14 | import org.springframework.web.util.UriComponentsBuilder; 15 | 16 | import com.tomniu.model.Department; 17 | import com.tomniu.model.DeptJson; 18 | import com.tomniu.model.DeptRepository; 19 | 20 | /** 21 | *

User: Tom Niu 22 | *

Version: 1.0 23 | */ 24 | 25 | @RestController 26 | public class DeptController { 27 | 28 | @Autowired 29 | private DeptRepository deptRepo; 30 | //-------------------Retrieve All Departments------------------------------ 31 | @RequestMapping(value="/dept", method = RequestMethod.GET) 32 | public ResponseEntity> listAllDepts() { 33 | Iterable depts = deptRepo.findAll(); 34 | List deptJsons = new ArrayList(); 35 | if(depts==null){ 36 | return new ResponseEntity>(HttpStatus.NO_CONTENT);//You many decide to return HttpStatus.NOT_FOUND 37 | } else { 38 | for (Department dept: depts) { 39 | DeptJson deptJson = new DeptJson(dept, dept.getEmps()); 40 | deptJsons.add(deptJson); 41 | } 42 | return new ResponseEntity>(deptJsons, HttpStatus.OK); 43 | } 44 | } 45 | //-------------------Retrieve One Departments by Dept Id------------------- 46 | @RequestMapping(value = "/dept/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) 47 | public ResponseEntity getUser(@PathVariable("id") long id) { 48 | System.out.println("Fetching User with id " + id); 49 | 50 | Department dept = deptRepo.findOne(id); 51 | if (dept == null) { 52 | System.out.println("dept with id " + id + " not found"); 53 | return new ResponseEntity(HttpStatus.NOT_FOUND); 54 | } else { 55 | System.out.println(dept.getDeptName()); 56 | System.out.println(dept.getEmps().size()); 57 | DeptJson deptInfo = new DeptJson(dept, dept.getEmps()); 58 | return new ResponseEntity(deptInfo, HttpStatus.OK); 59 | } 60 | } 61 | //-------------------Create new Department--------------------------------- 62 | @RequestMapping(value = "/dept", method = RequestMethod.POST) 63 | public ResponseEntity createUser(@RequestBody DeptJson deptJson, UriComponentsBuilder ucBuilder) { 64 | 65 | Department dept = deptJson.getDept(); 66 | System.out.println("Creating Dept " + deptJson.getDept()); 67 | dept = deptRepo.save(dept); 68 | System.out.println("saved Dept " + dept); 69 | HttpHeaders headers = new HttpHeaders(); 70 | headers.setLocation(ucBuilder.path("/dept/{id}").buildAndExpand(dept.getDeptId()).toUri()); 71 | return new ResponseEntity(headers, HttpStatus.CREATED); 72 | } 73 | } -------------------------------------------------------------------------------- /oauth2/src/main/java/com/tomniu/config/DatabaseConfig.java: -------------------------------------------------------------------------------- 1 | package com.tomniu.config; 2 | 3 | import java.util.Properties; 4 | 5 | import javax.sql.DataSource; 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.core.env.Environment; 11 | import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; 12 | import org.springframework.jdbc.datasource.DriverManagerDataSource; 13 | import org.springframework.orm.jpa.JpaTransactionManager; 14 | import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; 15 | import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; 16 | import org.springframework.transaction.annotation.EnableTransactionManagement; 17 | 18 | 19 | /** 20 | * Database configurations. 21 | */ 22 | @Configuration 23 | @EnableTransactionManagement 24 | public class DatabaseConfig { 25 | 26 | @Bean 27 | public DataSource dataSource() { 28 | DriverManagerDataSource dataSource = new DriverManagerDataSource(); 29 | dataSource.setDriverClassName(env.getProperty("db.driver")); 30 | dataSource.setUrl(env.getProperty("db.url")); 31 | dataSource.setUsername(env.getProperty("db.username")); 32 | dataSource.setPassword(env.getProperty("db.password")); 33 | return dataSource; 34 | } 35 | 36 | /** 37 | * Declare the JPA entity manager factory. 38 | */ 39 | @Bean 40 | public LocalContainerEntityManagerFactoryBean entityManagerFactory() { 41 | LocalContainerEntityManagerFactoryBean entityManagerFactory = 42 | new LocalContainerEntityManagerFactoryBean(); 43 | 44 | entityManagerFactory.setDataSource(dataSource); 45 | 46 | // Classpath scanning of @Component, @Service, etc annotated class 47 | entityManagerFactory.setPackagesToScan( 48 | env.getProperty("entitymanager.packagesToScan")); 49 | 50 | // Vendor adapter 51 | HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); 52 | entityManagerFactory.setJpaVendorAdapter(vendorAdapter); 53 | 54 | // Hibernate properties 55 | Properties additionalProperties = new Properties(); 56 | additionalProperties.put( 57 | "hibernate.dialect", 58 | env.getProperty("hibernate.dialect")); 59 | additionalProperties.put( 60 | "hibernate.show_sql", 61 | env.getProperty("hibernate.show_sql")); 62 | additionalProperties.put( 63 | "hibernate.hbm2ddl.auto", 64 | env.getProperty("hibernate.hbm2ddl.auto")); 65 | entityManagerFactory.setJpaProperties(additionalProperties); 66 | 67 | return entityManagerFactory; 68 | } 69 | 70 | /** 71 | * Declare the transaction manager. 72 | */ 73 | @Bean 74 | public JpaTransactionManager transactionManager() { 75 | JpaTransactionManager transactionManager = 76 | new JpaTransactionManager(); 77 | transactionManager.setEntityManagerFactory( 78 | entityManagerFactory.getObject()); 79 | return transactionManager; 80 | } 81 | @Bean 82 | public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { 83 | return new PersistenceExceptionTranslationPostProcessor(); 84 | } 85 | // ------------------------ 86 | // PRIVATE 87 | // ------------------------ 88 | 89 | @Autowired 90 | private Environment env; 91 | 92 | @Autowired 93 | private DataSource dataSource; 94 | 95 | @Autowired 96 | private LocalContainerEntityManagerFactoryBean entityManagerFactory; 97 | } -------------------------------------------------------------------------------- /rest/src/main/java/com/tomniu/config/DatabaseConfig.java: -------------------------------------------------------------------------------- 1 | package com.tomniu.config; 2 | 3 | import java.util.Properties; 4 | 5 | import javax.sql.DataSource; 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.core.env.Environment; 11 | import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; 12 | import org.springframework.jdbc.datasource.DriverManagerDataSource; 13 | import org.springframework.orm.jpa.JpaTransactionManager; 14 | import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; 15 | import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; 16 | import org.springframework.transaction.annotation.EnableTransactionManagement; 17 | 18 | 19 | /** 20 | * Database configurations. 21 | */ 22 | @Configuration 23 | @EnableTransactionManagement 24 | public class DatabaseConfig { 25 | 26 | @Bean 27 | public DataSource dataSource() { 28 | DriverManagerDataSource dataSource = new DriverManagerDataSource(); 29 | dataSource.setDriverClassName(env.getProperty("db.driver")); 30 | dataSource.setUrl(env.getProperty("db.url")); 31 | dataSource.setUsername(env.getProperty("db.username")); 32 | dataSource.setPassword(env.getProperty("db.password")); 33 | return dataSource; 34 | } 35 | 36 | /** 37 | * Declare the JPA entity manager factory. 38 | */ 39 | @Bean 40 | public LocalContainerEntityManagerFactoryBean entityManagerFactory() { 41 | LocalContainerEntityManagerFactoryBean entityManagerFactory = 42 | new LocalContainerEntityManagerFactoryBean(); 43 | 44 | entityManagerFactory.setDataSource(dataSource); 45 | 46 | // Classpath scanning of @Component, @Service, etc annotated class 47 | entityManagerFactory.setPackagesToScan( 48 | env.getProperty("entitymanager.packagesToScan")); 49 | 50 | // Vendor adapter 51 | HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); 52 | entityManagerFactory.setJpaVendorAdapter(vendorAdapter); 53 | 54 | // Hibernate properties 55 | Properties additionalProperties = new Properties(); 56 | additionalProperties.put( 57 | "hibernate.dialect", 58 | env.getProperty("hibernate.dialect")); 59 | additionalProperties.put( 60 | "hibernate.show_sql", 61 | env.getProperty("hibernate.show_sql")); 62 | additionalProperties.put( 63 | "hibernate.hbm2ddl.auto", 64 | env.getProperty("hibernate.hbm2ddl.auto")); 65 | entityManagerFactory.setJpaProperties(additionalProperties); 66 | 67 | return entityManagerFactory; 68 | } 69 | 70 | /** 71 | * Declare the transaction manager. 72 | */ 73 | @Bean 74 | public JpaTransactionManager transactionManager() { 75 | JpaTransactionManager transactionManager = 76 | new JpaTransactionManager(); 77 | transactionManager.setEntityManagerFactory( 78 | entityManagerFactory.getObject()); 79 | return transactionManager; 80 | } 81 | @Bean 82 | public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { 83 | return new PersistenceExceptionTranslationPostProcessor(); 84 | } 85 | // ------------------------ 86 | // PRIVATE 87 | // ------------------------ 88 | 89 | @Autowired 90 | private Environment env; 91 | 92 | @Autowired 93 | private DataSource dataSource; 94 | 95 | @Autowired 96 | private LocalContainerEntityManagerFactoryBean entityManagerFactory; 97 | } -------------------------------------------------------------------------------- /model/src/main/java/com/tomniu/config/DatabaseConfig.java: -------------------------------------------------------------------------------- 1 | package com.tomniu.config; 2 | 3 | import java.util.Properties; 4 | 5 | import javax.sql.DataSource; 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.core.env.Environment; 11 | import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; 12 | import org.springframework.jdbc.datasource.DriverManagerDataSource; 13 | import org.springframework.orm.jpa.JpaTransactionManager; 14 | import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; 15 | import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; 16 | import org.springframework.transaction.annotation.EnableTransactionManagement; 17 | 18 | 19 | /** 20 | * Database configurations. 21 | */ 22 | @Configuration 23 | @EnableTransactionManagement 24 | public class DatabaseConfig { 25 | 26 | @Bean 27 | public DataSource dataSource() { 28 | DriverManagerDataSource dataSource = new DriverManagerDataSource(); 29 | dataSource.setDriverClassName(env.getProperty("db.driver")); 30 | dataSource.setUrl(env.getProperty("db.url")); 31 | dataSource.setUsername(env.getProperty("db.username")); 32 | dataSource.setPassword(env.getProperty("db.password")); 33 | return dataSource; 34 | } 35 | 36 | /** 37 | * Declare the JPA entity manager factory. 38 | */ 39 | @Bean 40 | public LocalContainerEntityManagerFactoryBean entityManagerFactory() { 41 | LocalContainerEntityManagerFactoryBean entityManagerFactory = 42 | new LocalContainerEntityManagerFactoryBean(); 43 | 44 | entityManagerFactory.setDataSource(dataSource); 45 | 46 | // Classpath scanning of @Component, @Service, etc annotated class 47 | entityManagerFactory.setPackagesToScan( 48 | env.getProperty("entitymanager.packagesToScan")); 49 | 50 | // Vendor adapter 51 | HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); 52 | entityManagerFactory.setJpaVendorAdapter(vendorAdapter); 53 | 54 | // Hibernate properties 55 | Properties additionalProperties = new Properties(); 56 | additionalProperties.put( 57 | "hibernate.dialect", 58 | env.getProperty("hibernate.dialect")); 59 | additionalProperties.put( 60 | "hibernate.show_sql", 61 | env.getProperty("hibernate.show_sql")); 62 | additionalProperties.put( 63 | "hibernate.hbm2ddl.auto", 64 | env.getProperty("hibernate.hbm2ddl.auto")); 65 | entityManagerFactory.setJpaProperties(additionalProperties); 66 | 67 | return entityManagerFactory; 68 | } 69 | 70 | /** 71 | * Declare the transaction manager. 72 | */ 73 | @Bean 74 | public JpaTransactionManager transactionManager() { 75 | JpaTransactionManager transactionManager = 76 | new JpaTransactionManager(); 77 | transactionManager.setEntityManagerFactory( 78 | entityManagerFactory.getObject()); 79 | return transactionManager; 80 | } 81 | @Bean 82 | public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { 83 | return new PersistenceExceptionTranslationPostProcessor(); 84 | } 85 | // ------------------------ 86 | // PRIVATE 87 | // ------------------------ 88 | 89 | @Autowired 90 | private Environment env; 91 | 92 | @Autowired 93 | private DataSource dataSource; 94 | 95 | @Autowired 96 | private LocalContainerEntityManagerFactoryBean entityManagerFactory; 97 | } 98 | -------------------------------------------------------------------------------- /security/src/main/java/com/tomniu/config/DatabaseConfig.java: -------------------------------------------------------------------------------- 1 | package com.tomniu.config; 2 | 3 | import java.util.Properties; 4 | 5 | import javax.sql.DataSource; 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.core.env.Environment; 11 | import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; 12 | import org.springframework.jdbc.datasource.DriverManagerDataSource; 13 | import org.springframework.orm.jpa.JpaTransactionManager; 14 | import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; 15 | import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; 16 | import org.springframework.transaction.annotation.EnableTransactionManagement; 17 | 18 | 19 | /** 20 | * Database configurations. 21 | */ 22 | @Configuration 23 | @EnableTransactionManagement 24 | public class DatabaseConfig { 25 | 26 | @Bean 27 | public DataSource dataSource() { 28 | DriverManagerDataSource dataSource = new DriverManagerDataSource(); 29 | dataSource.setDriverClassName(env.getProperty("db.driver")); 30 | dataSource.setUrl(env.getProperty("db.url")); 31 | dataSource.setUsername(env.getProperty("db.username")); 32 | dataSource.setPassword(env.getProperty("db.password")); 33 | return dataSource; 34 | } 35 | 36 | /** 37 | * Declare the JPA entity manager factory. 38 | */ 39 | @Bean 40 | public LocalContainerEntityManagerFactoryBean entityManagerFactory() { 41 | LocalContainerEntityManagerFactoryBean entityManagerFactory = 42 | new LocalContainerEntityManagerFactoryBean(); 43 | 44 | entityManagerFactory.setDataSource(dataSource); 45 | 46 | // Classpath scanning of @Component, @Service, etc annotated class 47 | entityManagerFactory.setPackagesToScan( 48 | env.getProperty("entitymanager.packagesToScan")); 49 | 50 | // Vendor adapter 51 | HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); 52 | entityManagerFactory.setJpaVendorAdapter(vendorAdapter); 53 | 54 | // Hibernate properties 55 | Properties additionalProperties = new Properties(); 56 | additionalProperties.put( 57 | "hibernate.dialect", 58 | env.getProperty("hibernate.dialect")); 59 | additionalProperties.put( 60 | "hibernate.show_sql", 61 | env.getProperty("hibernate.show_sql")); 62 | additionalProperties.put( 63 | "hibernate.hbm2ddl.auto", 64 | env.getProperty("hibernate.hbm2ddl.auto")); 65 | entityManagerFactory.setJpaProperties(additionalProperties); 66 | 67 | return entityManagerFactory; 68 | } 69 | 70 | /** 71 | * Declare the transaction manager. 72 | */ 73 | @Bean 74 | public JpaTransactionManager transactionManager() { 75 | JpaTransactionManager transactionManager = 76 | new JpaTransactionManager(); 77 | transactionManager.setEntityManagerFactory( 78 | entityManagerFactory.getObject()); 79 | return transactionManager; 80 | } 81 | @Bean 82 | public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { 83 | return new PersistenceExceptionTranslationPostProcessor(); 84 | } 85 | // ------------------------ 86 | // PRIVATE 87 | // ------------------------ 88 | 89 | @Autowired 90 | private Environment env; 91 | 92 | @Autowired 93 | private DataSource dataSource; 94 | 95 | @Autowired 96 | private LocalContainerEntityManagerFactoryBean entityManagerFactory; 97 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Spring Boot + REST API + Security + OAuth2 + JPA (demo) 2 | ========================================== 3 | This is a example integrating the above technologies. It is under active development, and more features are in progress. 4 | 5 | **Index**: 6 | [Purpose](#purpose) • 7 | [What you'll need](#what you'll need) • 8 | [Summary](#summary) • 9 | [Run example](#Run example) • 10 | [rest](#rest) • 11 | [security](#security) • 12 | [oauth2](#oauth2) • 13 | 14 | ## Purpose 15 | This example is designed to make it easy for beginner to learn the relevent knowledge about [Maven](http://maven.apache.org/download.cgi), [Spring boot](https://projects.spring.io/spring-boot/), [Spring REST API](https://spring.io/understanding/REST), [Spring JPA](https://projects.spring.io/spring-data-jpa/), [One-to-Many](https://en.wikibooks.org/wiki/Java_Persistence/OneToMany), and [Spring OAuth2](https://spring.io/understanding/oauth) 16 | ## What you'll need 17 | * JDK 1.8 or later 18 | * Maven 3.0+ 19 | * MySQL 5.6 or later 20 | ```javascript 21 | . ____ _ __ _ _ 22 | /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ 23 | ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ 24 | \\/ ___)| |_)| | | | | || (_| | ) ) ) ) 25 | ' |____| .__|_| |_|_| |_\__, | / / / / 26 | =========|_|==============|___/=/_/_/_/ 27 | :: Spring Boot :: (v1.3.5.RELEASE) 28 | ``` 29 | 30 | ## Summary 31 | staffManager has the following modules: 32 | * `model`: Implementing of One-to-Many relationship database with JPA 33 | * `rest`: REST endpoints and web interface 34 | * `security`: REST endpoints and web interface with Basic Authentication 35 | * `oauth2`: REST endpoints and web interface with OAuth2 Authentication 36 | 37 | ## Run example 38 | 39 | ### Installation 40 | ```javascript 41 | mvn package 42 | mvn install 43 | ``` 44 | ```javascript 45 | [INFO] staffmanager ...................................... SUCCESS [ 0.218 s] 46 | [INFO] model ............................................. SUCCESS [ 5.016 s] 47 | [INFO] rest .............................................. SUCCESS [ 0.109 s] 48 | [INFO] security .......................................... SUCCESS [ 0.078 s] 49 | [INFO] oauth2 ............................................ SUCCESS [ 0.766 s] 50 | [INFO] ------------------------------------------------------------------------ 51 | [INFO] BUILD SUCCESS 52 | [INFO] ------------------------------------------------------------------------ 53 | ``` 54 | 55 | ### Run the relevent modules 56 | ```javascript 57 | cd [rest|security|oauth2] 58 | mvn spring-boot:run 59 | ``` 60 | 61 | ## rest 62 | * You can learn how to depend to other model, how to deploy REST with spring-boot-starter-web. 63 | * You need to ensure that you've installed the module of model before you compile and run rest because rest depends on model. 64 | * It provides REST endpoints including create, find one, find All and update. 65 | 66 | ###Core sources 67 | Abbreviation 68 | 69 | ###Get All departments 70 | ```javascript 71 | curl -X GET -H "Cache-Control: no-cache" -H "Postman-Token: f7944f38-4358-d880-a22b-e1185f05403e" "http://localhost:8080/dept" 72 | ``` 73 | 74 | ```javascript 75 | [{"dept":{"deptId":1,"deptName":"HR"},"emps":[{"empId":1,"empName":"Tom","salary":5000.0}]},{"dept":{"deptId":2,"deptName":"IT"},"emps":[{"empId":2,"empName":"John","salary":6000.0}]},{"dept":{"deptId":3,"deptName":"Marketing"},"emps":[]},{"dept":{"deptId":4,"deptName":"IT"},"emps":[]},{"dept":{"deptId":5,"deptName":"IT"},"emps":[]}] 76 | ``` 77 | ###Get one department by Id 78 | ```javascript 79 | curl -X GET -H "Cache-Control: no-cache" -H "Postman-Token: a8e98c5a-4483-45bf-9b0d-604b6dd1bb8b" "http://localhost:8080/dept/1" 80 | ``` 81 | ```javascript 82 | {"dept":{"deptId":1,"deptName":"HR"},"emps":[{"empId":1,"empName":"Tom","salary":5000.0}]} 83 | ``` 84 | ###Create a new department 85 | ```javascript 86 | curl -X POST -H "Content-Type: application/json" -H "Cache-Control: no-cache" -H "Postman-Token: ed5b3db5-24aa-30bb-a70a-9512d411c222" -d '{"dept":{"deptName":"IT"},"emps":[{"empId":2,"empName":"John","salary":6000.0}]}' "http://localhost:8080/dept" 87 | ``` 88 | 89 | following is in progress 90 | * **delete** 91 | * **update** 92 | 93 | ## security 94 | * You can learn how to authenticate the client with Basic Authentication 95 | * Precompile requirement is same as rest 96 | 97 | ###Core sources 98 | * You can change username and password as you like 99 | ```java 100 | protected void configure(AuthenticationManagerBuilder auth) throws Exception { 101 | auth.inMemoryAuthentication() 102 | .withUser("root").password("root").roles("USER"); 103 | } 104 | 105 | protected void configure(HttpSecurity http) throws Exception { 106 | http.authorizeRequests().anyRequest().fullyAuthenticated(); 107 | http.httpBasic(); 108 | http.csrf().disable(); 109 | } 110 | ``` 111 | 112 | ###Get one department by Id with Basic Authentication 113 | ```javascript 114 | curl -X GET -H "Content-Type: application/json" -H "Authorization: Basic cm9vdDpyb290" -H "Cache-Control: no-cache" -H "Postman-Token: d6f03df9-2261-7981-d7cd-151b4e908753" "http://localhost:8080/dept" 115 | ``` 116 | 117 | ## oauth2 118 | * You can learn how to authenticate the client with oauth2 (password mode) 119 | * Precompile requirement is same as rest 120 | 121 | ###Core sources 122 | * You can change username and password as you like 123 | ```java 124 | public void init(AuthenticationManagerBuilder auth) throws Exception { 125 | auth.inMemoryAuthentication() 126 | .withUser("admin").password("123456").roles("USER"); 127 | } 128 | 129 | public void configure(ClientDetailsServiceConfigurer clients) throws Exception { 130 | clients.inMemory().withClient(applicationName) // applicationName="staffmanager" 131 | .authorizedGrantTypes("password", "authorization_code", "refresh_token") 132 | .authorities("ROLE_USER").scopes("write").resourceIds(applicationName) 133 | .secret("888888"); 134 | } 135 | ``` 136 | 137 | ###Get access token 138 | ```javascript 139 | curl -X POST -vu staffmanager:888888 http://localhost:8080/oauth/token -H "Accept: application/json" -d "password=123456&username=admin&grant_type=password&scope=write&client_secret=888888&client_id=staffmanager" 140 | ``` 141 | ```javascript 142 | {"access_token":"7fd3f22b-2bae-41ad-9f88-77c778b5a546","token_type":"bearer","refresh_token":"5c376a65-5bce-48c8-9fe8-95e41401b11e","xpires_in":43199,"scope":"write"} 143 | ``` 144 | ###Get One Department by Id with the access token obtained. 145 | ```javascript 146 | curl -X GET -H "Authorization: Bearer 7fd3f22b-2bae-41ad-9f88-77c778b5a546" -H "Cache-Control: no-cache" -H "Postman-Token: cb8ec0b9-ac7d-ddfc-481b-1e1b0664a912" "http://localhost:8080/dept/1" 147 | ``` 148 | ```javascript 149 | {"dept":{"deptId":1,"deptName":"HR"},"emps":[{"empId":1,"empName":"Tom","salary":5000.0}]} 150 | ``` 151 | --------------------------------------------------------------------------------