diff --git a/pom.xml b/pom.xml index b0a6389..f14e32c 100644 --- a/pom.xml +++ b/pom.xml @@ -27,6 +27,15 @@ spring-boot-starter-test test + + org.springframework.boot + spring-boot-starter-data-jpa + + + com.h2database + h2 + runtime + diff --git a/src/main/java/com/accenture/codingtest/springbootcodingtest/entity/Project.java b/src/main/java/com/accenture/codingtest/springbootcodingtest/entity/Project.java new file mode 100644 index 0000000..e3da3e5 --- /dev/null +++ b/src/main/java/com/accenture/codingtest/springbootcodingtest/entity/Project.java @@ -0,0 +1,35 @@ +package com.accenture.codingtest.springbootcodingtest.entity; + + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table(name = "project") +public class Project { + + @Id + @Column(name = "id") + private String id; + @Column(name = "name", length = 250, unique = true) + private String name; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + +} \ No newline at end of file diff --git a/src/main/java/com/accenture/codingtest/springbootcodingtest/entity/Task.java b/src/main/java/com/accenture/codingtest/springbootcodingtest/entity/Task.java new file mode 100644 index 0000000..aaa1176 --- /dev/null +++ b/src/main/java/com/accenture/codingtest/springbootcodingtest/entity/Task.java @@ -0,0 +1,75 @@ +package com.accenture.codingtest.springbootcodingtest.entity; + + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table(name = "task") +public class Task { + + @Id + @Column(name = "id") + private String id; + @Column(name = "title", length = 250, nullable = false) + private String title; + @Column(name = "description") + private String description; + @Column(name = "status", nullable = false) + private String status; + @Column(name = "project_id", nullable = false) + private String projectId; + @Column(name = "user_id", nullable = false) + private String userId; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getProjectId() { + return projectId; + } + + public void setProjectId(String projectId) { + this.projectId = projectId; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } +} + diff --git a/src/main/java/com/accenture/codingtest/springbootcodingtest/entity/User.java b/src/main/java/com/accenture/codingtest/springbootcodingtest/entity/User.java new file mode 100644 index 0000000..52519ec --- /dev/null +++ b/src/main/java/com/accenture/codingtest/springbootcodingtest/entity/User.java @@ -0,0 +1,45 @@ +package com.accenture.codingtest.springbootcodingtest.entity; + + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table(name = "user") +public class User { + + @Id + @Column(name = "id") + private String id; + @Column(name = "user_name", length = 150, unique = true) + private String userName; + @Column(name = "password", length = 50) + private String password; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + +} diff --git a/src/main/resources/Data.sql b/src/main/resources/Data.sql new file mode 100644 index 0000000..54fc587 --- /dev/null +++ b/src/main/resources/Data.sql @@ -0,0 +1,3 @@ +CREATE TABLE USER (id varchar,user_name varchar(150) unique,password varchar(50)); +CREATE TABLE PROJECT (id varchar,name varchar(150)); +CREATE TABLE TASK (id varchar,title varchar(250),description varchar,status varchar,project_id varchar,user_id varchar); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 8b13789..aa9aa18 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1 +1,8 @@ +spring.datasource.url=jdbc:h2:mem:testdb +spring.h2.console.enabled=true +spring.jpa.hibernate.ddl-auto=none +spring.jpa.show-sql=true +spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect +#logging level +logging.level.org.springframework.web=DEBUG \ No newline at end of file