0% found this document useful (0 votes)
12 views2 pages

Todo Repository

The document defines a Todo application using Spring Boot, including a Todo entity and a repository interface for database operations. The Todo class includes fields for id, username, description, target date, and completion status, along with validation for the description length. The TodoRepository interface extends JpaRepository to provide methods for accessing Todo records, specifically allowing retrieval by username.

Uploaded by

David Pavlovski
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views2 pages

Todo Repository

The document defines a Todo application using Spring Boot, including a Todo entity and a repository interface for database operations. The Todo class includes fields for id, username, description, target date, and completion status, along with validation for the description length. The TodoRepository interface extends JpaRepository to provide methods for accessing Todo records, specifically allowing retrieval by username.

Uploaded by

David Pavlovski
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

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;
}

You might also like