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