aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrián Oliva <adrian.oliva@cimat.mx>2023-05-25 13:07:01 -0600
committerAdrián Oliva <adrian.oliva@cimat.mx>2023-05-25 13:07:01 -0600
commit70381b3187aab32d4facb74d327ac79bbc2669ba (patch)
tree7aa93ec98d6546b44a959c244ee651aa4ba91572
parent233f75c561d119cf4103343bd5df4faef81ac5a1 (diff)
downloadToDo-App-BE-70381b3187aab32d4facb74d327ac79bbc2669ba.tar.gz
ToDo-App-BE-70381b3187aab32d4facb74d327ac79bbc2669ba.zip
Added ToDos class.
Class for saving all single to dos.
-rw-r--r--pom.xml5
-rw-r--r--src/main/java/com/encora/ToDos.java124
2 files changed, 129 insertions, 0 deletions
diff --git a/pom.xml b/pom.xml
index 8431407..c2556ba 100644
--- a/pom.xml
+++ b/pom.xml
@@ -18,6 +18,11 @@
</properties>
<dependencies>
<dependency>
+ <groupId>jakarta.persistence</groupId>
+ <artifactId>jakarta.persistence-api</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
diff --git a/src/main/java/com/encora/ToDos.java b/src/main/java/com/encora/ToDos.java
new file mode 100644
index 0000000..9fc69e4
--- /dev/null
+++ b/src/main/java/com/encora/ToDos.java
@@ -0,0 +1,124 @@
+package com.encora;
+
+import jakarta.persistence.*;
+
+import java.util.Date;
+import java.util.Objects;
+
+enum Priority {
+ LOW, MEDIUM, HIGH;
+}
+
+@Entity
+public class ToDos {
+ @Id
+ @SequenceGenerator(
+ name = "to_do_id",
+ sequenceName = "to_do_id",
+ allocationSize = 1
+ )
+ @GeneratedValue(
+ strategy = GenerationType.SEQUENCE,
+ generator = "to_do_id"
+ )
+ private Integer id;
+ private String text;
+ private Date dueDate;
+ private boolean done;
+ private Date doneDate;
+ private Priority priority;
+ private Date creationDate;
+
+ public ToDos(String text, Date dueDate, Priority priority) {
+ this.text = text;
+ this.dueDate = dueDate;
+ this.priority = priority;
+ this.creationDate = new Date();
+ }
+
+ public ToDos() {
+ this.creationDate = new Date();
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public Date getDueDate() {
+ return dueDate;
+ }
+
+ public void setDueDate(Date dueDate) {
+ this.dueDate = dueDate;
+ }
+
+ public boolean isDone() {
+ return done;
+ }
+
+ public void setDone(boolean done) {
+ this.done = done;
+ }
+
+ public Date getDoneDate() {
+ return doneDate;
+ }
+
+ public void setDoneDate(Date doneDate) {
+ this.doneDate = doneDate;
+ }
+
+ public Priority getPriority() {
+ return priority;
+ }
+
+ public void setPriority(Priority priority) {
+ this.priority = priority;
+ }
+
+ public Date getCreationDate() {
+ return creationDate;
+ }
+
+ public void setCreationDate(Date creationDate) {
+ this.creationDate = creationDate;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ ToDos toDos = (ToDos) o;
+ return done == toDos.done && Objects.equals(id, toDos.id) && Objects.equals(text, toDos.text) && Objects.equals(dueDate, toDos.dueDate) && Objects.equals(doneDate, toDos.doneDate) && priority == toDos.priority && Objects.equals(creationDate, toDos.creationDate);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id, text, dueDate, done, doneDate, priority, creationDate);
+ }
+
+ @Override
+ public String toString() {
+ return "ToDos{" +
+ "id=" + id +
+ ", text='" + text + '\'' +
+ ", dueDate=" + dueDate +
+ ", done=" + done +
+ ", doneDate=" + doneDate +
+ ", priority=" + priority +
+ ", creationDate=" + creationDate +
+ '}';
+ }
+}