package ru.ulstu.deadline.model;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.format.annotation.DateTimeFormat;
import ru.ulstu.core.model.BaseEntity;

import javax.persistence.Entity;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import java.util.Date;

@Entity
public class Deadline extends BaseEntity {

    private String description;

    @Temporal(value = TemporalType.TIMESTAMP)
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date date;

    public Deadline() {
    }

    public Deadline(Date deadlineDate, String description) {
        this.date = deadlineDate;
        this.description = description;
    }

    @JsonCreator
    public Deadline(@JsonProperty("id") Integer id,
                    @JsonProperty("description") String description,
                    @JsonProperty("date") Date date) {
        this.setId(id);
        this.description = description;
        this.date = date;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }
}
