package [Link].
todo;
import [Link];
import [Link];
import [Link];
@Repository
public interface TodoRepository extends JpaRepository<Todo, Integer> {
List<Todo> findByUsername(String username);
}
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@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) {
[Link] = username;
[Link] = description;
[Link] = targetDate;
[Link] = 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) {
[Link] = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
[Link] = username;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
[Link] = description;
}
public LocalDate getTargetDate() {
return targetDate;
}
public void setTargetDate(LocalDate targetDate) {
[Link] = targetDate;
}
public boolean isCompleted() {
return completed;
}
public void setCompleted(boolean completed) {
[Link] = completed;
}