#98 edited project executors
This commit is contained in:
parent
4bb4fd6bca
commit
7388e12e3f
@ -13,6 +13,7 @@ import ru.ulstu.deadline.model.Deadline;
|
||||
import ru.ulstu.project.model.Project;
|
||||
import ru.ulstu.project.model.ProjectDto;
|
||||
import ru.ulstu.project.service.ProjectService;
|
||||
import ru.ulstu.user.model.User;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import javax.validation.Valid;
|
||||
@ -92,6 +93,11 @@ public class ProjectController {
|
||||
return String.format("redirect:%s", "/projects/projects");
|
||||
}
|
||||
|
||||
@ModelAttribute("allExecutors")
|
||||
public List<User> getAllExecutors(ProjectDto projectDto) {
|
||||
return projectService.getProjectExecutors(projectDto);
|
||||
}
|
||||
|
||||
private void filterEmptyDeadlines(ProjectDto projectDto) {
|
||||
projectDto.setDeadlines(projectDto.getDeadlines().stream()
|
||||
.filter(dto -> dto.getDate() != null || !isEmpty(dto.getDescription()))
|
||||
|
@ -2,6 +2,7 @@ package ru.ulstu.project.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.grant.model.Grant;
|
||||
@ -23,7 +24,8 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Entity
|
||||
public class Project extends BaseEntity {
|
||||
public class Project extends BaseEntity implements UserContainer {
|
||||
|
||||
public enum ProjectStatus {
|
||||
APPLICATION("Заявка"),
|
||||
ON_COMPETITION("Отправлен на конкурс"),
|
||||
@ -133,4 +135,9 @@ public class Project extends BaseEntity {
|
||||
public void setExecutors(Set<User> executors) {
|
||||
this.executors = executors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<User> getUsers() {
|
||||
return getExecutors();
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,8 @@ public class ProjectDto {
|
||||
private List<Integer> removedDeadlineIds = new ArrayList<>();
|
||||
private Set<Integer> executorIds;
|
||||
private Set<UserDto> executors;
|
||||
private boolean hasAge;
|
||||
private boolean hasDegree;
|
||||
|
||||
private final static int MAX_EXECUTORS_LENGTH = 40;
|
||||
|
||||
@ -48,7 +50,9 @@ public class ProjectDto {
|
||||
@JsonProperty("repository") String repository,
|
||||
@JsonProperty("deadlines") List<Deadline> deadlines,
|
||||
@JsonProperty("executorIds") Set<Integer> executorIds,
|
||||
@JsonProperty("executors") Set<UserDto> executors) {
|
||||
@JsonProperty("executors") Set<UserDto> executors,
|
||||
@JsonProperty("hasAge") boolean hasAge,
|
||||
@JsonProperty("hasDegree") boolean hasDegree) {
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
this.status = status;
|
||||
@ -59,6 +63,8 @@ public class ProjectDto {
|
||||
this.applicationFileName = null;
|
||||
this.executorIds = executorIds;
|
||||
this.executors = executors;
|
||||
this.hasAge = hasAge;
|
||||
this.hasDegree = hasDegree;
|
||||
}
|
||||
|
||||
|
||||
@ -163,6 +169,22 @@ public class ProjectDto {
|
||||
this.executors = executors;
|
||||
}
|
||||
|
||||
public boolean isHasAge() {
|
||||
return hasAge;
|
||||
}
|
||||
|
||||
public void setHasAge(boolean hasAge) {
|
||||
this.hasAge = hasAge;
|
||||
}
|
||||
|
||||
public boolean isHasDegree() {
|
||||
return hasDegree;
|
||||
}
|
||||
|
||||
public void setHasDegree(boolean hasDegree) {
|
||||
this.hasDegree = hasDegree;
|
||||
}
|
||||
|
||||
public String getExecutorsString() {
|
||||
return StringUtils.abbreviate(executors
|
||||
.stream()
|
||||
|
@ -5,10 +5,13 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.thymeleaf.util.StringUtils;
|
||||
import ru.ulstu.deadline.service.DeadlineService;
|
||||
import ru.ulstu.file.service.FileService;
|
||||
import ru.ulstu.grant.model.GrantDto;
|
||||
import ru.ulstu.grant.repository.GrantRepository;
|
||||
import ru.ulstu.project.model.Project;
|
||||
import ru.ulstu.project.model.ProjectDto;
|
||||
import ru.ulstu.project.repository.ProjectRepository;
|
||||
import ru.ulstu.user.model.User;
|
||||
import ru.ulstu.user.service.UserService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
@ -26,15 +29,18 @@ public class ProjectService {
|
||||
private final DeadlineService deadlineService;
|
||||
private final GrantRepository grantRepository;
|
||||
private final FileService fileService;
|
||||
private final UserService userService;
|
||||
|
||||
public ProjectService(ProjectRepository projectRepository,
|
||||
DeadlineService deadlineService,
|
||||
GrantRepository grantRepository,
|
||||
FileService fileService) {
|
||||
FileService fileService,
|
||||
UserService userService) {
|
||||
this.projectRepository = projectRepository;
|
||||
this.deadlineService = deadlineService;
|
||||
this.grantRepository = grantRepository;
|
||||
this.fileService = fileService;
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
public List<Project> findAll() {
|
||||
@ -115,4 +121,9 @@ public class ProjectService {
|
||||
return projectRepository.findOne(id);
|
||||
}
|
||||
|
||||
public List<User> getProjectExecutors(ProjectDto projectDto) {
|
||||
List<User> filteredUsers = userService.filterByAgeAndDegree(projectDto.isHasAge(), projectDto.isHasDegree());
|
||||
return filteredUsers;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -92,8 +92,13 @@
|
||||
</div>
|
||||
<div class="col-12" style="margin-bottom: 15px;"></div>
|
||||
<div class="col-10 div-deadline-executor">
|
||||
<input class="form-control" type="text" placeholder="Исполнитель"
|
||||
th:field="*{deadlines[__${rowStat.index}__].executor}"/>
|
||||
<select class="selectpicker form-control" data-live-search="true"
|
||||
title="-- Выберите исполнителя --" id="executors"
|
||||
th:field="*{deadlines[__${rowStat.index}__].executor}" data-size="5">
|
||||
<option th:each="executor : ${allExecutors}" th:value="${executor.id}"
|
||||
th:text="${executor.lastName}"> Участник
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<input class="form-control div-deadline-done" type="checkbox"
|
||||
|
Loading…
Reference in New Issue
Block a user