Resolve "Добавить статус события" #141

Merged
alefly merged 6 commits from 21-Event-status into master 2018-11-09 15:15:01 +04:00
4 changed files with 52 additions and 6 deletions
Showing only changes of commit 92d3067dd3 - Show all commits

View File

@ -4,20 +4,32 @@ import org.hibernate.validator.constraints.NotBlank;
import ru.ulstu.core.model.BaseEntity;
import ru.ulstu.user.model.User;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.*;
import java.util.Date;
import java.util.List;
@Entity
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
private String title;
@Enumerated(value = EnumType.STRING)
private EventStatus status;
@Column(name = "execute_date")
@Temporal(TemporalType.TIMESTAMP)
private Date executeDate;
@ -43,6 +55,14 @@ public class Event extends BaseEntity {
this.title = title;
}
public EventStatus getStatus() {
return status;
}
public void setStatus(EventStatus status) {
this.status = status;
}
public Date getCreateDate() {
return createDate;
}

View File

@ -12,6 +12,7 @@ import static ru.ulstu.core.util.StreamApiUtils.convert;
public class EventDto {
private final Integer id;
private final String title;
private final Event.EventStatus status;
private final Date executeDate;
private final Date createDate;
private final Date updateDate;
@ -21,6 +22,7 @@ public class EventDto {
@JsonCreator
public EventDto(@JsonProperty("id") Integer id,
@JsonProperty("title") String title,
@JsonProperty("status") Event.EventStatus status,
@JsonProperty("executeDate") Date executeDate,
@JsonProperty("createDate") Date createDate,
@JsonProperty("updateDate") Date updateDate,
@ -28,6 +30,7 @@ public class EventDto {
@JsonProperty("recipients") List<UserDto> recipients) {
this.id = id;
this.title = title;
this.status = status;
this.executeDate = executeDate;
this.createDate = createDate;
this.updateDate = updateDate;
@ -38,6 +41,7 @@ public class EventDto {
public EventDto(Event event) {
this.id = event.getId();
this.title = event.getTitle();
this.status = event.getStatus();
this.executeDate = event.getExecuteDate();
this.createDate = event.getCreateDate();
this.updateDate = event.getUpdateDate();
@ -53,6 +57,8 @@ public class EventDto {
return title;
}
public Event.EventStatus getStatus() { return status; }
public Date getCreateDate() {
return createDate;
}

View 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;
}
}

View File

@ -46,6 +46,7 @@ public class EventService {
event.setDescription(eventDto.getDescription());
event.setRecipients(userService.findByIds(convert(eventDto.getRecipients(), UserDto::getId)));
event.setTitle(eventDto.getTitle());
event.setStatus(eventDto.getStatus());
event.setUpdateDate(eventDto.getUpdateDate());
return event;
}