diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 59c3905..c44b679 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 98bcec3..568c50b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,4 +1,3 @@ -#Tue Feb 06 11:48:53 SAMT 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 9aa616c..cccdd3d 100755 --- a/gradlew +++ b/gradlew @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh ############################################################################## ## @@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS="" # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" -warn ( ) { +warn () { echo "$*" } -die ( ) { +die () { echo echo "$*" echo @@ -154,16 +154,19 @@ if $cygwin ; then esac fi -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " } -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [[ "$(uname)" == "Darwin" ]] && [[ "$HOME" == "$PWD" ]]; then +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then cd "$(dirname "$0")" fi -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" +exec "$JAVACMD" "$@" diff --git a/src/main/java/ru/ulstu/deadline/model/Deadline.java b/src/main/java/ru/ulstu/deadline/model/Deadline.java new file mode 100644 index 0000000..1a73e59 --- /dev/null +++ b/src/main/java/ru/ulstu/deadline/model/Deadline.java @@ -0,0 +1,41 @@ +package ru.ulstu.deadline.model; + +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) + private Date date; + + public Deadline() { + } + + public Deadline(Date deadlineDate, String description) { + this.date = deadlineDate; + this.description = description; + } + + 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; + } +} diff --git a/src/main/java/ru/ulstu/deadline/model/DeadlineDto.java b/src/main/java/ru/ulstu/deadline/model/DeadlineDto.java new file mode 100644 index 0000000..fbfb598 --- /dev/null +++ b/src/main/java/ru/ulstu/deadline/model/DeadlineDto.java @@ -0,0 +1,41 @@ +package ru.ulstu.deadline.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.Date; + +public class DeadlineDto { + private final Integer id; + + private final String description; + + private final Date date; + + @JsonCreator + public DeadlineDto(@JsonProperty("id") Integer id, + @JsonProperty("description") String description, + @JsonProperty("date") Date date) { + this.id = id; + this.description = description; + this.date = date; + } + + public DeadlineDto(Deadline deadline) { + this.id = deadline.getId(); + this.description = deadline.getDescription(); + this.date = deadline.getDate(); + } + + public Integer getId() { + return id; + } + + public String getDescription() { + return description; + } + + public Date getDate() { + return date; + } +} diff --git a/src/main/java/ru/ulstu/deadline/repository/DeadlineRepository.java b/src/main/java/ru/ulstu/deadline/repository/DeadlineRepository.java new file mode 100644 index 0000000..f26c572 --- /dev/null +++ b/src/main/java/ru/ulstu/deadline/repository/DeadlineRepository.java @@ -0,0 +1,9 @@ +package ru.ulstu.deadline.repository; + + +import org.springframework.data.jpa.repository.JpaRepository; +import ru.ulstu.deadline.model.Deadline; + +public interface DeadlineRepository extends JpaRepository { + +} diff --git a/src/main/java/ru/ulstu/deadline/service/DeadlineService.java b/src/main/java/ru/ulstu/deadline/service/DeadlineService.java new file mode 100644 index 0000000..c371d87 --- /dev/null +++ b/src/main/java/ru/ulstu/deadline/service/DeadlineService.java @@ -0,0 +1,45 @@ +package ru.ulstu.deadline.service; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import ru.ulstu.deadline.model.Deadline; +import ru.ulstu.deadline.model.DeadlineDto; +import ru.ulstu.deadline.repository.DeadlineRepository; + +import java.util.List; +import java.util.stream.Collectors; + +@Service +public class DeadlineService { + private final DeadlineRepository deadlineRepository; + + public DeadlineService(DeadlineRepository deadlineRepository) { + this.deadlineRepository = deadlineRepository; + } + + public List saveOrCreate(List deadlines) { + return deadlines.stream().map(deadlineDto -> { + return deadlineDto.getId() != null ? update(deadlineDto) : create(deadlineDto); + }).collect(Collectors.toList()); + } + + @Transactional + public Deadline update(DeadlineDto deadlineDto) { + Deadline deadline = deadlineRepository.findOne(deadlineDto.getId()); + deadlineRepository.save(copyFromDto(deadline, deadlineDto)); + return deadline; + } + + @Transactional + public Deadline create(DeadlineDto deadlineDto) { + Deadline newDeadline = copyFromDto(new Deadline(), deadlineDto); + newDeadline = deadlineRepository.save(newDeadline); + return newDeadline; + } + + private Deadline copyFromDto(Deadline deadline, DeadlineDto deadlineDto) { + deadline.setDate(deadlineDto.getDate()); + deadline.setDescription(deadlineDto.getDescription()); + return deadline; + } +} diff --git a/src/main/java/ru/ulstu/grant/model/Grant.java b/src/main/java/ru/ulstu/grant/model/Grant.java new file mode 100644 index 0000000..092317b --- /dev/null +++ b/src/main/java/ru/ulstu/grant/model/Grant.java @@ -0,0 +1,106 @@ +package ru.ulstu.grant.model; + +import org.hibernate.validator.constraints.NotBlank; +import ru.ulstu.core.model.BaseEntity; +import ru.ulstu.core.model.UserContainer; +import ru.ulstu.deadline.model.Deadline; +import ru.ulstu.file.model.FileData; +import ru.ulstu.project.model.Project; +import ru.ulstu.user.model.User; + +import javax.persistence.*; +import javax.validation.constraints.NotNull; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +@Entity +public class Grant extends BaseEntity { + public enum GrantStatus { + APPLICATION("Заявка"), + ON_COMPETITION("Отправлен на конкурс"), + SUCCESSFUL_PASSAGE("Успешное прохождение"), + IN_WORK("В работе"), + COMPLETED("Завершен"), + FAILED("Провалены сроки"); + + private String name; + + GrantStatus(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } + + @NotBlank + private String title; + + @Enumerated(value = EnumType.STRING) + private GrantStatus status = GrantStatus.APPLICATION; + + @OneToMany(cascade = CascadeType.ALL) + @JoinColumn(name = "grant_id") + private List deadlines = new ArrayList<>(); + + //Описание гранта + @NotNull + private String comment; + + //Заявка на грант + @ManyToOne + @JoinColumn(name = "file_id") + private FileData application; + + @ManyToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "project_id") + private Project project; + + public GrantStatus getStatus() { + return status; + } + + public void setStatus(GrantStatus status) { + this.status = status; + } + + public List getDeadlines() { + return deadlines; + } + + public void setDeadlines(List deadlines) { + this.deadlines = deadlines; + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + + public FileData getApplication() { + return application; + } + + public void setApplication(FileData application) { this.application = application; } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { this.title = title; } + + public Project getProject() { + return project; + } + + public void setProject(Project project) { + this.project = project; + } +} diff --git a/src/main/java/ru/ulstu/grant/model/GrantDto.java b/src/main/java/ru/ulstu/grant/model/GrantDto.java new file mode 100644 index 0000000..922df89 --- /dev/null +++ b/src/main/java/ru/ulstu/grant/model/GrantDto.java @@ -0,0 +1,76 @@ +package ru.ulstu.grant.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.hibernate.validator.constraints.NotEmpty; +import ru.ulstu.deadline.model.DeadlineDto; +import ru.ulstu.project.model.ProjectDto; + +import java.util.List; + +import static ru.ulstu.core.util.StreamApiUtils.convert; + +public class GrantDto { + private final Integer id; + @NotEmpty + private final String title; + private final Grant.GrantStatus status; + private final List deadlines; + private final String comment; + private final String applicationFileName; + private final ProjectDto project; + + @JsonCreator + public GrantDto(@JsonProperty("id") Integer id, + @JsonProperty("title") String title, + @JsonProperty("status") Grant.GrantStatus status, + @JsonProperty("deadlines") List deadlines, + @JsonProperty("comment") String comment, + @JsonProperty("project") ProjectDto project) { + this.id = id; + this.title = title; + this.status = status; + this.deadlines = deadlines; + this.comment = comment; + this.applicationFileName = null; + this.project = project; + } + + public GrantDto(Grant grant) { + this.id = grant.getId(); + this.title = grant.getTitle(); + this.status = grant.getStatus(); + this.deadlines = convert(grant.getDeadlines(), DeadlineDto::new); + this.comment = grant.getComment(); + this.project = grant.getProject() == null ? null : new ProjectDto(grant.getProject()); + this.applicationFileName = grant.getApplication() == null ? null : grant.getApplication().getName(); + } + + public Integer getId() { + return id; + } + + public String getTitle() { + return title; + } + + public Grant.GrantStatus getStatus() { + return status; + } + + public List getDeadlines() { + return deadlines; + } + + public String getComment() { + return comment; + } + + public ProjectDto getProject() { + return project; + } + + public String getApplicationFileName() { + return applicationFileName; + } +} diff --git a/src/main/java/ru/ulstu/grant/model/GrantStatusDto.java b/src/main/java/ru/ulstu/grant/model/GrantStatusDto.java new file mode 100644 index 0000000..dae40e2 --- /dev/null +++ b/src/main/java/ru/ulstu/grant/model/GrantStatusDto.java @@ -0,0 +1,19 @@ +package ru.ulstu.grant.model; + +public class GrantStatusDto { + private final String id; + private final String name; + + public GrantStatusDto(Grant.GrantStatus status) { + this.id = status.name(); + this.name = status.getName(); + } + + public String getId() { + return id; + } + + public String getName() { + return name; + } +} diff --git a/src/main/java/ru/ulstu/paper/model/Paper.java b/src/main/java/ru/ulstu/paper/model/Paper.java index fc14dbe..cf83ddd 100644 --- a/src/main/java/ru/ulstu/paper/model/Paper.java +++ b/src/main/java/ru/ulstu/paper/model/Paper.java @@ -3,9 +3,11 @@ package ru.ulstu.paper.model; import org.hibernate.validator.constraints.NotBlank; import ru.ulstu.core.model.BaseEntity; import ru.ulstu.core.model.UserContainer; +import ru.ulstu.deadline.model.Deadline; import ru.ulstu.file.model.FileData; import ru.ulstu.user.model.User; +import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.EnumType; @@ -16,9 +18,14 @@ import javax.persistence.ManyToMany; import javax.persistence.ManyToOne; import javax.persistence.Temporal; import javax.persistence.TemporalType; +import javax.persistence.OneToMany; import javax.validation.constraints.NotNull; +import java.util.ArrayList; +import java.util.Comparator; import java.util.Date; import java.util.HashSet; +import java.util.List; +import java.util.Optional; import java.util.Set; @Entity @@ -56,10 +63,9 @@ public class Paper extends BaseEntity implements UserContainer { @Temporal(TemporalType.TIMESTAMP) private Date updateDate = new Date(); - @Column(name = "deadline_date") - @NotNull - @Temporal(TemporalType.DATE) - private Date deadlineDate; + @OneToMany(cascade = CascadeType.ALL) + @JoinColumn(name = "paper_id") + private List deadlines = new ArrayList<>(); private String comment; @@ -96,12 +102,12 @@ public class Paper extends BaseEntity implements UserContainer { this.updateDate = updateDate; } - public Date getDeadlineDate() { - return deadlineDate; + public List getDeadlines() { + return deadlines; } - public void setDeadlineDate(Date deadlineDate) { - this.deadlineDate = deadlineDate; + public void setDeadlines(List deadlines) { + this.deadlines = deadlines; } public String getComment() { @@ -148,4 +154,12 @@ public class Paper extends BaseEntity implements UserContainer { public Set getUsers() { return getAuthors(); } + + public Optional getNextDeadline() { + return deadlines + .stream() + .sorted(Comparator.comparing(Deadline::getDate)) + .filter(d -> d.getDate().after(new Date())) + .findFirst(); + } } diff --git a/src/main/java/ru/ulstu/paper/model/PaperDto.java b/src/main/java/ru/ulstu/paper/model/PaperDto.java index e611ab9..cdfa2f9 100644 --- a/src/main/java/ru/ulstu/paper/model/PaperDto.java +++ b/src/main/java/ru/ulstu/paper/model/PaperDto.java @@ -1,13 +1,18 @@ package ru.ulstu.paper.model; +import com.fasterxml.jackson.annotation.JsonCreator; import org.hibernate.validator.constraints.NotEmpty; import org.springframework.format.annotation.DateTimeFormat; +import ru.ulstu.deadline.model.DeadlineDto; +import ru.ulstu.deadline.model.DeadlineDto; import ru.ulstu.user.model.UserDto; import javax.validation.constraints.Future; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import java.util.Date; +import java.util.List; +import java.util.List; import java.util.Set; import java.util.stream.Collectors; @@ -21,9 +26,7 @@ public class PaperDto { private Paper.PaperStatus status; private Date createDate; private Date updateDate; - @NotNull - @DateTimeFormat(pattern = "yyyy-MM-dd") - private Date deadlineDate; + private final List deadlines; private String comment; private Boolean locked; private String tmpFileName; @@ -32,7 +35,30 @@ public class PaperDto { private Date fileCreateDate; private Set authors; - public PaperDto() { + @JsonCreator + public PaperDto(@JsonProperty("id") Integer id, + @JsonProperty("title") String title, + @JsonProperty("status") Paper.PaperStatus status, + @JsonProperty("createDate") Date createDate, + @JsonProperty("updateDate") Date updateDate, + @JsonProperty("deadlines") List deadlines, + @JsonProperty("comment") String comment, + @JsonProperty("locked") Boolean locked, + @JsonProperty("tmpFileName") String tmpFileName, + @JsonProperty("authors") Set authors) { + this.id = id; + this.title = title; + this.status = status; + this.createDate = createDate; + this.updateDate = updateDate; + this.deadlines = deadlines; + this.comment = comment; + this.locked = locked; + this.tmpFileName = tmpFileName; + this.fileId = null; + this.fileName = null; + this.fileCreateDate = null; + this.authors = authors; } public PaperDto(Paper paper) { @@ -41,7 +67,7 @@ public class PaperDto { this.status = paper.getStatus(); this.createDate = paper.getCreateDate(); this.updateDate = paper.getUpdateDate(); - this.deadlineDate = paper.getDeadlineDate(); + this.deadlines = convert(paper.getDeadlines(), DeadlineDto::new); this.comment = paper.getComment(); this.locked = paper.getLocked(); this.tmpFileName = null; @@ -71,8 +97,8 @@ public class PaperDto { return updateDate; } - public Date getDeadlineDate() { - return deadlineDate; + public List getDeadlines() { + return deadlines; } public String getComment() { @@ -123,10 +149,6 @@ public class PaperDto { this.updateDate = updateDate; } - public void setDeadlineDate(Date deadlineDate) { - this.deadlineDate = deadlineDate; - } - public void setComment(String comment) { this.comment = comment; } diff --git a/src/main/java/ru/ulstu/paper/service/PaperNotificationService.java b/src/main/java/ru/ulstu/paper/service/PaperNotificationService.java index 99e0c86..697958b 100644 --- a/src/main/java/ru/ulstu/paper/service/PaperNotificationService.java +++ b/src/main/java/ru/ulstu/paper/service/PaperNotificationService.java @@ -29,16 +29,16 @@ public class PaperNotificationService { } private boolean needToSendDeadlineNotification(Paper paper, Date compareDate, boolean isDeadlineBeforeWeek) { - return (paper.getDeadlineDate() != null) - && (compareDate.after(paper.getDeadlineDate()) && isDeadlineBeforeWeek - || compareDate.before(paper.getDeadlineDate()) && !isDeadlineBeforeWeek) - && paper.getDeadlineDate().after(new Date()); + return (paper.getNextDeadline().isPresent()) + && (compareDate.after(paper.getNextDeadline().get().getDate()) && isDeadlineBeforeWeek + || compareDate.before(paper.getNextDeadline().get().getDate()) && !isDeadlineBeforeWeek) + && paper.getNextDeadline().get().getDate().after(new Date()); } private void sendMessageDeadline(Paper paper) { paper.getAuthors().forEach(user -> { mailService.sendEmail(user.getEmail(), "Приближается срок сдачи статьи", - "Срок сдачи статьи " + paper.getTitle() + " " + paper.getDeadlineDate().toString()); + "Срок сдачи статьи " + paper.getTitle() + " " + paper.getNextDeadline().get().getDate().toString()); }); } diff --git a/src/main/java/ru/ulstu/paper/service/PaperService.java b/src/main/java/ru/ulstu/paper/service/PaperService.java index aa7a94a..b7cd9a3 100644 --- a/src/main/java/ru/ulstu/paper/service/PaperService.java +++ b/src/main/java/ru/ulstu/paper/service/PaperService.java @@ -2,6 +2,8 @@ package ru.ulstu.paper.service; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import ru.ulstu.deadline.model.Deadline; +import ru.ulstu.deadline.service.DeadlineService; import ru.ulstu.file.service.FileService; import ru.ulstu.paper.model.Paper; import ru.ulstu.paper.model.PaperDto; @@ -27,17 +29,19 @@ public class PaperService { private final PaperNotificationService paperNotificationService; private final PaperRepository paperRepository; private final UserService userService; + private final DeadlineService deadlineService; private final FileService fileService; - public PaperService(PaperRepository paperRepository, FileService fileService, PaperNotificationService paperNotificationService, - UserService userService) { + UserService userService, + DeadlineService deadlineService) { this.paperRepository = paperRepository; this.fileService = fileService; this.paperNotificationService = paperNotificationService; this.userService = userService; + this.deadlineService = deadlineService; } public List findAll() { @@ -75,7 +79,7 @@ public class PaperService { paper.setStatus(paperDto.getStatus() == null ? DRAFT : paperDto.getStatus()); paper.setTitle(paperDto.getTitle()); paper.setUpdateDate(new Date()); - paper.setDeadlineDate(paperDto.getDeadlineDate()); + paper.setDeadlines(deadlineService.saveOrCreate(paperDto.getDeadlines())); if (paperDto.getTmpFileName() != null) { paper.setFileData(fileService.createFileFromTmp(paperDto.getTmpFileName())); } @@ -121,7 +125,7 @@ public class PaperService { Paper paper = new Paper(); paper.setTitle(title); paper.getAuthors().add(user); - paper.setDeadlineDate(deadlineDate); + paper.getDeadlines().add(new Deadline(deadlineDate, "первый дедлайн")); paper.setCreateDate(new Date()); paper.setUpdateDate(new Date()); paper.setStatus(DRAFT); @@ -136,14 +140,18 @@ public class PaperService { return convert(paperRepository.filter(userService.findById(filterDto.getAuthorId()), filterDto.getYear()), PaperDto::new); } + public PaperDto findPaper(int id){ + return new PaperDto(paperRepository.getOne(id)); + } + public void closeFailedPapers() { List papers = paperRepository.findAll() .stream() - .filter(paper -> paper.getDeadlineDate() != null + .filter(paper -> paper.getNextDeadline().isPresent() && (paper.getStatus() == ON_PREPARATION || paper.getStatus() == DRAFT || paper.getStatus() == ATTENTION) - && paper.getDeadlineDate().before(new Date())) + && paper.getNextDeadline().get().getDate().before(new Date())) .collect(Collectors.toList()); papers.forEach(paper -> { Paper.PaperStatus oldStatus = paper.getStatus(); diff --git a/src/main/java/ru/ulstu/project/model/Project.java b/src/main/java/ru/ulstu/project/model/Project.java new file mode 100644 index 0000000..06722a1 --- /dev/null +++ b/src/main/java/ru/ulstu/project/model/Project.java @@ -0,0 +1,39 @@ +package ru.ulstu.project.model; + +import org.hibernate.validator.constraints.NotBlank; +import ru.ulstu.core.model.BaseEntity; +import ru.ulstu.deadline.model.Deadline; + +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.JoinColumn; +import javax.persistence.OneToMany; +import java.util.ArrayList; +import java.util.List; + +@Entity +public class Project extends BaseEntity { + + @NotBlank + private String title; + + @OneToMany(cascade = CascadeType.ALL) + @JoinColumn(name = "project_id") + private List deadlines = new ArrayList<>(); + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public List getDeadlines() { + return deadlines; + } + + public void setDeadlines(List deadlines) { + this.deadlines = deadlines; + } +} diff --git a/src/main/java/ru/ulstu/project/model/ProjectDto.java b/src/main/java/ru/ulstu/project/model/ProjectDto.java new file mode 100644 index 0000000..69e9b1b --- /dev/null +++ b/src/main/java/ru/ulstu/project/model/ProjectDto.java @@ -0,0 +1,42 @@ +package ru.ulstu.project.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.hibernate.validator.constraints.NotEmpty; +import ru.ulstu.deadline.model.DeadlineDto; + +import java.util.List; + +import static ru.ulstu.core.util.StreamApiUtils.convert; + +public class ProjectDto { + private final Integer id; + + @NotEmpty + private final String title; + + private final List deadlines; + + @JsonCreator + public ProjectDto(@JsonProperty("id") Integer id, + @JsonProperty("title") String title, + @JsonProperty("deadlines") List deadlines) { + this.id = id; + this.title = title; + this.deadlines = deadlines; + } + + public ProjectDto(Project project) { + this.id = project.getId(); + this.title = project.getTitle(); + this.deadlines = convert(project.getDeadlines(), DeadlineDto::new); + } + + public Integer getId() { + return id; + } + + public String getTitle() { + return title; + } +} diff --git a/src/main/resources/db/changelog-20181208_000000-schema.xml b/src/main/resources/db/changelog-20181208_000000-schema.xml new file mode 100644 index 0000000..1943b26 --- /dev/null +++ b/src/main/resources/db/changelog-20181208_000000-schema.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/db/changelog-master.xml b/src/main/resources/db/changelog-master.xml index d0199a1..6c7147b 100644 --- a/src/main/resources/db/changelog-master.xml +++ b/src/main/resources/db/changelog-master.xml @@ -16,4 +16,5 @@ + \ No newline at end of file diff --git a/src/main/resources/mail_templates/paperCreateNotification.html b/src/main/resources/mail_templates/paperCreateNotification.html index afbbe20..2758143 100644 --- a/src/main/resources/mail_templates/paperCreateNotification.html +++ b/src/main/resources/mail_templates/paperCreateNotification.html @@ -13,7 +13,7 @@ Вам нужно поработать над статьей "Title".

- Срок исполнения: . + Срок исполнения: .

Regards, diff --git a/src/main/resources/mail_templates/paperDeadlineNotification.html b/src/main/resources/mail_templates/paperDeadlineNotification.html index ee63f3b..a239421 100644 --- a/src/main/resources/mail_templates/paperDeadlineNotification.html +++ b/src/main/resources/mail_templates/paperDeadlineNotification.html @@ -13,7 +13,7 @@ Приближается срок сдачи статьи "Title".

- Срок исполнения: . + Срок исполнения: .

Regards, diff --git a/src/main/resources/public/js/papers.js b/src/main/resources/public/js/papers.js index 8fbce6f..bb621c5 100644 --- a/src/main/resources/public/js/papers.js +++ b/src/main/resources/public/js/papers.js @@ -1,6 +1,7 @@ var urlPapers = "/api/1.0/papers"; var urlPaperStatuses = "/api/1.0/papers/statuses"; var urlDeletePaper = "/api/1.0/papers/"; +var urlFilterPaper = "/api/1.0/papers/filter" function showPapers(papersElement, paperRowClass) { getFromRest(urlPapers, function (paperList) { @@ -32,7 +33,49 @@ function showPapers(papersElement, paperRowClass) { }); } -function deletePaper(idElement, papersElement, paperRowClass) { + +function filterPapers(papersElement, paperRowClass, authorId, year) { + var paperData = JSON.stringify({ + "authorId": authorId, + "year": year + }); + postToRest(urlFilterPaper, paperData, function (data) { + $(paperRowClass).remove(); + if(data.length > 0){ + data.forEach(function (paper, index) { + $(papersElement).parent().append("

" + + "
" + + " \n" + + " " + + " " + + " " + + " " + paper.title + "
" + + "
" + + "" + + "" + + "
"); + }); + + + $(paperRowClass).mouseenter(function (event) { + var paperRow = $(event.target).closest(paperRowClass); + $(paperRow).css("background-color", "#f8f9fa"); + $(paperRow).find(".remove-paper").removeClass("d-none"); + + }); + $(paperRowClass).mouseleave(function (event) { + var paperRow = $(event.target).closest(paperRowClass); + $(paperRow).css("background-color", "white"); + $(paperRow).closest(paperRowClass).find(".remove-paper").addClass("d-none"); + }); + } + }); + + +} + +function deletePaper(id, papersElement, paperRowClass) { var id = $(idElement).parent().find('.id-class').val(); $("#remove-paper-modal").modal('show'); @@ -50,16 +93,16 @@ function deletePaper(idElement, papersElement, paperRowClass) { }); } -function addPaper(title, status, comment, locked) { - var paperData = JSON.stringify({ +function addPaper(title, status, datePublish, dateUpdate, deadline, comment, locked, tmpFileName, authors) { + var paperData = JSON.stringify({ "title": title, "status": status, - "comment": comment, - "locked": locked - }); - postToRest(urlPapers, paperData, function (data) { + "deadlineDate":deadline, + "comment": comment + }); + postToRest(urlPapers, paperData, function (data) { alert(data); - }); + }); } function getPaperStatusClass(status) { diff --git a/src/main/resources/templates/papers/papers.html b/src/main/resources/templates/papers/papers.html index 738f9f5..b3989ee 100644 --- a/src/main/resources/templates/papers/papers.html +++ b/src/main/resources/templates/papers/papers.html @@ -28,7 +28,27 @@ Добавить статью + + + +
+
Фильтровать по:
+ + +
@@ -70,6 +90,11 @@ $(paperRow).css("background-color", "white"); $(paperRow).closest(".paper-row").find(".remove-paper").addClass("d-none"); }); + showPapers("#paper-list", ".paper-row"); + jQuery('.filter').on('change','#year',function(){ + + filterPapers("#paper-list", ".paper-row",'1','2018'); + }); }); /*]]>*/