package com.example.todolist.entity;

import java.sql.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Version;

import org.hibernate.annotations.Where;
import org.hibernate.envers.Audited;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

@Entity
@Audited // ①追加
@Table(name = "task")
@Where(clause = "is_deleted = 'N'")
@EntityListeners(AuditingEntityListener.class)
@AllArgsConstructor
@NoArgsConstructor
@Data
@EqualsAndHashCode(callSuper = true)
public class Task extends AuditInfo {
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "id")
	private Integer id;

	@ManyToOne
	@JoinColumn(name = "todo_id")
	private Todo todo;

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

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

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

	@Column(name = "assigned_to")
	private Integer assignedTo;
	
	@Column(name = "progress")
	private Integer progress;

	@Column(name = "version")
	@Version
	private Integer version;

	@Column(name = "is_deleted")
	private String isDeleted;

}
