This commit is contained in:
Viktoria committed 2022-09-01 10:46:56 +02:00
1 parent ff67f31cf3
commit cc068fc3a8
26 files changed
+104 -519

No files matched your search

@@ -1,5 +1,7 @@
package site.easystartup.web.project.controller;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.modelmapper.ModelMapper;
import org.springframework.http.ResponseEntity;
@@ -24,6 +26,7 @@ import java.util.stream.Collectors;
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/project")
@Tag(name = "Проекты", description = "контроллер для работы с проектами")
public class ProjectController {
private final ProjectService projectService;
private final ResponseErrorValidation responseErrorValidation;
@@ -32,6 +35,7 @@ public class ProjectController {
private final ParticipantService participantService;
@PostMapping
@Operation(summary = "Создание проекта")
public ResponseEntity<Object> createProject(@Valid @RequestBody ProjectRequest projectRequest,
BindingResult bindingResult,
Principal principal) {
@@ -43,6 +47,7 @@ public class ProjectController {
}
@PutMapping("/{projectId}")
@Operation(summary = "Изменение проекта")
public ResponseEntity<Object> editProject(@Valid @RequestBody ProjectRequest projectRequest,
@PathVariable("projectId") Long projectId,
BindingResult bindingResult,
@@ -55,6 +60,7 @@ public class ProjectController {
}
@PutMapping("/{projectId}/{partId}/part")
@Operation(summary = "Изменение позиции в проекте: Дизайнер/Ui designer")
public ResponseEntity<Object> editPart(@Valid @RequestBody ParticipantDto participantDto,
@PathVariable("projectId") Long projectId,
@PathVariable("partId") Long partId,
@@ -69,6 +75,7 @@ public class ProjectController {
@DeleteMapping("/{projectId}")
@Operation(summary = "Удаление проекта")
public ResponseEntity<Object> deleteProject(@PathVariable("projectId") Long projectId,
Principal principal) {
projectService.deleteProject(projectId, principal);
@@ -76,12 +83,14 @@ public class ProjectController {
}
@GetMapping("/{projectId}")
@Operation(summary = "получение проекта по id")
public ResponseEntity<ProjectDto> getProject(@PathVariable("projectId") Long projectId) {
return ResponseEntity.ok().body(modelMapper.map(projectService.getProjectById(projectId), ProjectDto.class));
}
//
@GetMapping("/{userId}/all")
@Operation(summary = "Получение всех проектов для пользователя")
public ResponseEntity<List<ProjectDto>> getAllProjectsForUser(@PathVariable("userId") Long userId) {
List<ProjectDto> projects = projectService.getAllProjectsForUser(userId)
.stream().map(project -> modelMapper.map(project, ProjectDto.class)).collect(Collectors.toList());
@@ -89,6 +98,7 @@ public class ProjectController {
}
@GetMapping("/{technology}/tech")
@Operation(summary = "Получение всех проектов с опредлененной технологией")
public ResponseEntity<List<ProjectDto>> getAllProjectsWithTechnology(@PathVariable("technology") String technology) {
List<ProjectDto> projects = projectService.getAllProjectsWithTechnology(technology)
.stream().map(project -> modelMapper.map(project, ProjectDto.class)).collect(Collectors.toList());
@@ -96,6 +106,7 @@ public class ProjectController {
}
@GetMapping("/my")
@Operation(summary = "получение всех проектов для текущего пользователя")
public ResponseEntity<List<ProjectDto>> getAllProjectsForCurrentUser(Principal principal) {
List<ProjectDto> projects = projectService.getAllProjectsForCurrentUser(principal)
.stream().map(project -> modelMapper.map(project, ProjectDto.class)).collect(Collectors.toList());
@@ -104,6 +115,7 @@ public class ProjectController {
@GetMapping("/{nameOfPosition}/positions")
@Operation(summary = "Получение всех проектов с указанной позицией : Дизайнер")
public ResponseEntity<List<ProjectDto>> getAllProjectsWithPosition(@PathVariable("nameOfPosition") String nameOfPosition) {
List<ProjectDto> projects = projectService.getAllProjectsWithPosition(nameOfPosition)
.stream().map(project -> modelMapper.map(project, ProjectDto.class)).collect(Collectors.toList());
@@ -111,6 +123,7 @@ public class ProjectController {
}
@GetMapping("/{commercialStatus}/commercial_status")
@Operation(summary = "получение всех проектов по коммерческому статусу")
public ResponseEntity<List<ProjectDto>> getAllProjectsWithCommercialStatus(@PathVariable("commercialStatus") int commercialStatus) {
List<ProjectDto> projects = projectService.getAllProjectsWithCommercialStatus(commercialStatus)
.stream().map(project -> modelMapper.map(project, ProjectDto.class)).collect(Collectors.toList());
@@ -118,6 +131,7 @@ public class ProjectController {
}
@GetMapping("/requests")
@Operation(summary = "получение всех поданных заявок на проект")
public ResponseEntity<List<ParticipantDto>> getAllRequestsForProject(@RequestBody Long projectId) {
List<ParticipantDto> requests = projectService.getAllRequestsForProject(projectId)
.stream().map(project -> modelMapper.map(project, ParticipantDto.class)).collect(Collectors.toList());
@@ -125,6 +139,7 @@ public class ProjectController {
}
@PostMapping("/apply")
@Operation(summary = "подать заявку на участие в проекте")
public ResponseEntity<ProjectDto> applyOnProject(@RequestBody ParticipantRequest participantRequest,
Principal principal) {
Project project = projectService
@@ -133,6 +148,7 @@ public class ProjectController {
}
@PostMapping("/participant")
@Operation(summary = "утвердить участница на проект")
public ResponseEntity<ProjectDto> confirmParticipant(@RequestBody ParticipantRequest participantRequest,
Principal principal) {
Project project = projectService.confirmParticipant(participantRequest.getProjectId(),