From ca3e87a8c54b7d13ac9bb78b067a6238520bb3c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=B0=D1=81=D0=B8=D0=BD=20=D0=90=D0=BD=D1=82=D0=BE?= =?UTF-8?q?=D0=BD?= Date: Wed, 17 Apr 2019 13:50:22 +0300 Subject: [PATCH] #96 edit project blank page --- .../project/controller/ProjectController.java | 10 +++++ .../java/ru/ulstu/project/model/Project.java | 5 +-- .../ru/ulstu/project/model/ProjectDto.java | 1 - .../ulstu/project/service/ProjectService.java | 5 +++ .../fragments/projectNavigationFragment.html | 4 +- .../resources/templates/projects/project.html | 45 +++++++++++++++++++ 6 files changed, 63 insertions(+), 7 deletions(-) create mode 100644 src/main/resources/templates/projects/project.html diff --git a/src/main/java/ru/ulstu/project/controller/ProjectController.java b/src/main/java/ru/ulstu/project/controller/ProjectController.java index 5b5eb4a..b71fc1d 100644 --- a/src/main/java/ru/ulstu/project/controller/ProjectController.java +++ b/src/main/java/ru/ulstu/project/controller/ProjectController.java @@ -5,6 +5,7 @@ import org.springframework.ui.ModelMap; import org.springframework.validation.Errors; import org.springframework.web.bind.annotation.*; import ru.ulstu.deadline.model.Deadline; +import ru.ulstu.grant.model.GrantDto; import ru.ulstu.project.model.Project; import ru.ulstu.project.model.ProjectDto; import ru.ulstu.project.service.ProjectService; @@ -36,4 +37,13 @@ public class ProjectController { public void getProjects(ModelMap modelMap) { modelMap.put("projects", projectService.findAllDto()); } + + @GetMapping("/project") + public void getProject(ModelMap modelMap, @RequestParam(value = "id") Integer id) { + if (id != null && id > 0) { + modelMap.put("projectDto", projectService.findOneDto(id)); + } else { + modelMap.put("projectDto", new ProjectDto()); + } + } } diff --git a/src/main/java/ru/ulstu/project/model/Project.java b/src/main/java/ru/ulstu/project/model/Project.java index 06722a1..07a8108 100644 --- a/src/main/java/ru/ulstu/project/model/Project.java +++ b/src/main/java/ru/ulstu/project/model/Project.java @@ -4,10 +4,7 @@ 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 javax.persistence.*; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/ru/ulstu/project/model/ProjectDto.java b/src/main/java/ru/ulstu/project/model/ProjectDto.java index db7fc75..8549994 100644 --- a/src/main/java/ru/ulstu/project/model/ProjectDto.java +++ b/src/main/java/ru/ulstu/project/model/ProjectDto.java @@ -13,7 +13,6 @@ public class ProjectDto { @NotEmpty private String title; - private List deadlines = new ArrayList<>(); public ProjectDto() { diff --git a/src/main/java/ru/ulstu/project/service/ProjectService.java b/src/main/java/ru/ulstu/project/service/ProjectService.java index 78a9d3c..bdf5f33 100644 --- a/src/main/java/ru/ulstu/project/service/ProjectService.java +++ b/src/main/java/ru/ulstu/project/service/ProjectService.java @@ -8,6 +8,7 @@ import ru.ulstu.project.model.Project; import ru.ulstu.project.model.ProjectDto; import ru.ulstu.project.repository.ProjectRepository; +import java.util.Arrays; import java.util.List; import static org.springframework.util.ObjectUtils.isEmpty; @@ -36,6 +37,10 @@ public class ProjectService { return projects; } + public ProjectDto findOneDto(Integer id) { + return new ProjectDto(projectRepository.findOne(id)); + } + @Transactional public Project create(ProjectDto projectDto) { Project newProject = copyFromDto(new Project(), projectDto); diff --git a/src/main/resources/templates/projects/fragments/projectNavigationFragment.html b/src/main/resources/templates/projects/fragments/projectNavigationFragment.html index c26d8b8..75dfff6 100644 --- a/src/main/resources/templates/projects/fragments/projectNavigationFragment.html +++ b/src/main/resources/templates/projects/fragments/projectNavigationFragment.html @@ -16,8 +16,8 @@ diff --git a/src/main/resources/templates/projects/project.html b/src/main/resources/templates/projects/project.html new file mode 100644 index 0000000..c8c88d4 --- /dev/null +++ b/src/main/resources/templates/projects/project.html @@ -0,0 +1,45 @@ + + + + + + + +
+ +
+
+
+
+

Редактирование проекта

+
+
+
+
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+
+
+ +