added event status
This commit is contained in:
parent
9013baa209
commit
92d3067dd3
@ -4,20 +4,32 @@ import org.hibernate.validator.constraints.NotBlank;
|
|||||||
import ru.ulstu.core.model.BaseEntity;
|
import ru.ulstu.core.model.BaseEntity;
|
||||||
import ru.ulstu.user.model.User;
|
import ru.ulstu.user.model.User;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.*;
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.FetchType;
|
|
||||||
import javax.persistence.ManyToMany;
|
|
||||||
import javax.persistence.Temporal;
|
|
||||||
import javax.persistence.TemporalType;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class Event extends BaseEntity {
|
public class Event extends BaseEntity {
|
||||||
|
public enum EventStatus {
|
||||||
|
POSSIBLE("Возможное"), NEW("Новое"), IN_PROGRESS("В процессе"), COMPLETED("Завершено");
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
EventStatus(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@NotBlank
|
@NotBlank
|
||||||
private String title;
|
private String title;
|
||||||
|
|
||||||
|
@Enumerated(value = EnumType.STRING)
|
||||||
|
private EventStatus status;
|
||||||
|
|
||||||
@Column(name = "execute_date")
|
@Column(name = "execute_date")
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
private Date executeDate;
|
private Date executeDate;
|
||||||
@ -43,6 +55,14 @@ public class Event extends BaseEntity {
|
|||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EventStatus getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(EventStatus status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
public Date getCreateDate() {
|
public Date getCreateDate() {
|
||||||
return createDate;
|
return createDate;
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import static ru.ulstu.core.util.StreamApiUtils.convert;
|
|||||||
public class EventDto {
|
public class EventDto {
|
||||||
private final Integer id;
|
private final Integer id;
|
||||||
private final String title;
|
private final String title;
|
||||||
|
private final Event.EventStatus status;
|
||||||
private final Date executeDate;
|
private final Date executeDate;
|
||||||
private final Date createDate;
|
private final Date createDate;
|
||||||
private final Date updateDate;
|
private final Date updateDate;
|
||||||
@ -21,6 +22,7 @@ public class EventDto {
|
|||||||
@JsonCreator
|
@JsonCreator
|
||||||
public EventDto(@JsonProperty("id") Integer id,
|
public EventDto(@JsonProperty("id") Integer id,
|
||||||
@JsonProperty("title") String title,
|
@JsonProperty("title") String title,
|
||||||
|
@JsonProperty("status") Event.EventStatus status,
|
||||||
@JsonProperty("executeDate") Date executeDate,
|
@JsonProperty("executeDate") Date executeDate,
|
||||||
@JsonProperty("createDate") Date createDate,
|
@JsonProperty("createDate") Date createDate,
|
||||||
@JsonProperty("updateDate") Date updateDate,
|
@JsonProperty("updateDate") Date updateDate,
|
||||||
@ -28,6 +30,7 @@ public class EventDto {
|
|||||||
@JsonProperty("recipients") List<UserDto> recipients) {
|
@JsonProperty("recipients") List<UserDto> recipients) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
|
this.status = status;
|
||||||
this.executeDate = executeDate;
|
this.executeDate = executeDate;
|
||||||
this.createDate = createDate;
|
this.createDate = createDate;
|
||||||
this.updateDate = updateDate;
|
this.updateDate = updateDate;
|
||||||
@ -38,6 +41,7 @@ public class EventDto {
|
|||||||
public EventDto(Event event) {
|
public EventDto(Event event) {
|
||||||
this.id = event.getId();
|
this.id = event.getId();
|
||||||
this.title = event.getTitle();
|
this.title = event.getTitle();
|
||||||
|
this.status = event.getStatus();
|
||||||
this.executeDate = event.getExecuteDate();
|
this.executeDate = event.getExecuteDate();
|
||||||
this.createDate = event.getCreateDate();
|
this.createDate = event.getCreateDate();
|
||||||
this.updateDate = event.getUpdateDate();
|
this.updateDate = event.getUpdateDate();
|
||||||
@ -53,6 +57,8 @@ public class EventDto {
|
|||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Event.EventStatus getStatus() { return status; }
|
||||||
|
|
||||||
public Date getCreateDate() {
|
public Date getCreateDate() {
|
||||||
return createDate;
|
return createDate;
|
||||||
}
|
}
|
||||||
|
19
src/main/java/ru/ulstu/timeline/model/EventStatusDto.java
Normal file
19
src/main/java/ru/ulstu/timeline/model/EventStatusDto.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package ru.ulstu.timeline.model;
|
||||||
|
|
||||||
|
public class EventStatusDto {
|
||||||
|
private final String id;
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
public EventStatusDto(Event.EventStatus status) {
|
||||||
|
this.id = status.name();
|
||||||
|
this.name = status.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
@ -46,6 +46,7 @@ public class EventService {
|
|||||||
event.setDescription(eventDto.getDescription());
|
event.setDescription(eventDto.getDescription());
|
||||||
event.setRecipients(userService.findByIds(convert(eventDto.getRecipients(), UserDto::getId)));
|
event.setRecipients(userService.findByIds(convert(eventDto.getRecipients(), UserDto::getId)));
|
||||||
event.setTitle(eventDto.getTitle());
|
event.setTitle(eventDto.getTitle());
|
||||||
|
event.setStatus(eventDto.getStatus());
|
||||||
event.setUpdateDate(eventDto.getUpdateDate());
|
event.setUpdateDate(eventDto.getUpdateDate());
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user