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

Merged
alefly merged 6 commits from 21-Event-status into master 2018-11-09 15:15:01 +04:00
6 changed files with 67 additions and 0 deletions

View File

@ -6,6 +6,8 @@ import ru.ulstu.user.model.User;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.ManyToMany;
import javax.persistence.Temporal;
@ -15,9 +17,26 @@ 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 +62,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;
}

View File

@ -0,0 +1,13 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<changeSet author="alyona" id="20181031_000000-1">
<preConditions onFail="MARK_RAN">
<not><columnExists columnName="status" tableName="event"/></not>
</preConditions>
<addColumn tableName="event">
<column name="status" type="varchar(255)"/>
</addColumn>
</changeSet>
</databaseChangeLog>

View File

@ -13,5 +13,6 @@
<include file="db/changelog-20180505_000000-schema.xml"/>
<include file="db/changelog-20181027_000000-schema.xml"/>
<include file="db/changelog-20181030_000000-schema.xml"/>
<include file="db/changelog-20181031_000000-schema.xml"/>
<include file="db/changelog-20181108_000000-data.xml"/>
</databaseChangeLog>