package com.example.todolist.entity;

import java.time.LocalDate;
import java.util.List;

import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;

import lombok.Data;
import lombok.ToString;

@Entity
@Table(name = "todo")
@Data
//追加しないと toString()で循環参照が起こり StackOverFlow を引き起こす
@ToString(exclude = "taskList")

public class Todo {
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "id")
	private Integer id;

	@Column(name = "title")
	private String title;

	@Column(name = "importance")
	private Integer importance;

	@Column(name = "urgency")
	private Integer urgency;

	@Column(name = "deadline")
	private LocalDate deadline;

	@Column(name = "done")
	private String done;

	// taskList プロパティを追加
	@OneToMany(mappedBy = "todo", cascade = CascadeType.ALL)
	private List<Task> taskList;
}
