package com.davidpavlovski.springboot.todoApp.
todo;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.validation.constraints.Size;
import org.springframework.context.annotation.Primary;
import java.time.LocalDate;
@Table
@Entity
public class Todo {
@Id
@GeneratedValue
private int id;
private String username;
@Size(min = 5, message = "Description must be at least 5 characters")
private String description;
private LocalDate targetDate;
private boolean completed;
public Todo() {
super();
}
public Todo(String username, String description, LocalDate targetDate, boolean
completed) {
this.username = username;
this.description = description;
this.targetDate = targetDate;
this.completed = completed;
}
@Override
public String toString() {
return "Todo{" +
"id=" + id +
", username='" + username + '\'' +
", description='" + description + '\'' +
", targetDate=" + targetDate +
", completed=" + completed +
'}';
}
public void toggleComplete() {
completed = !completed;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public LocalDate getTargetDate() {
return targetDate;
}
public void setTargetDate(LocalDate targetDate) {
this.targetDate = targetDate;
}
public boolean isCompleted() {
return completed;
}
public void setCompleted(boolean completed) {
this.completed = completed;
}