122 lines
3.2 KiB
Java
122 lines
3.2 KiB
Java
package ru.ulstu.activity.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 ru.ulstu.user.model.User;
|
|
|
|
import javax.persistence.Entity;
|
|
import javax.persistence.FetchType;
|
|
import javax.persistence.OneToMany;
|
|
import javax.persistence.Temporal;
|
|
import javax.persistence.TemporalType;
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
|
|
@Entity
|
|
public class Deadline extends BaseEntity {
|
|
|
|
private String description;
|
|
|
|
@Temporal(value = TemporalType.DATE)
|
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
|
private Date date;
|
|
|
|
@OneToMany(targetEntity = User.class, fetch = FetchType.LAZY)
|
|
private List<User> executors = new ArrayList<>();
|
|
|
|
private Boolean done;
|
|
|
|
public Deadline() {
|
|
}
|
|
|
|
public Deadline(Date deadlineDate, String description) {
|
|
this.date = deadlineDate;
|
|
this.description = description;
|
|
}
|
|
|
|
public Deadline(Date deadlineDate, String description, List<User> executors, Boolean done) {
|
|
this.date = deadlineDate;
|
|
this.description = description;
|
|
this.executors = executors;
|
|
this.done = done;
|
|
}
|
|
|
|
@JsonCreator
|
|
public Deadline(@JsonProperty("id") Integer id,
|
|
@JsonProperty("description") String description,
|
|
@JsonProperty("date") Date date,
|
|
@JsonProperty("executors") List<User> executors,
|
|
@JsonProperty("done") Boolean done) {
|
|
this.setId(id);
|
|
this.description = description;
|
|
this.date = date;
|
|
this.executors = executors;
|
|
this.done = done;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
public List<User> getExecutors() {
|
|
return executors;
|
|
}
|
|
|
|
public void setExecutors(List<User> executors) {
|
|
this.executors = executors;
|
|
}
|
|
|
|
public Boolean getDone() {
|
|
return done;
|
|
}
|
|
|
|
public void setDone(Boolean done) {
|
|
this.done = done;
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object o) {
|
|
if (this == o) {
|
|
return true;
|
|
}
|
|
if (o == null || getClass() != o.getClass()) {
|
|
return false;
|
|
}
|
|
if (!super.equals(o)) {
|
|
return false;
|
|
}
|
|
Deadline deadline = (Deadline) o;
|
|
if (getId() == null && deadline.getId() == null &&
|
|
description == null && deadline.description == null &&
|
|
date == null && deadline.date == null) {
|
|
return true;
|
|
}
|
|
return getId().equals(deadline.getId()) &&
|
|
description.equals(deadline.description) &&
|
|
date.equals(deadline.date) &&
|
|
executors.equals(deadline.executors) &&
|
|
done.equals(deadline.done);
|
|
}
|
|
|
|
@Override
|
|
public int hashCode() {
|
|
return Objects.hash(super.hashCode(), description, date, executors, done);
|
|
}
|
|
}
|