| 1 | package com.edtech.controller; | |
| 2 | ||
| 3 | import com.edtech.dto.ProjectMemberRequestDto; | |
| 4 | import com.edtech.dto.ProjectRequestDto; | |
| 5 | import com.edtech.dto.ProjectResponseDto; | |
| 6 | import com.edtech.model.User; | |
| 7 | import com.edtech.service.ProjectService; | |
| 8 | import java.util.List; | |
| 9 | import java.util.UUID; | |
| 10 | import org.springframework.http.HttpStatus; | |
| 11 | import org.springframework.http.ResponseEntity; | |
| 12 | import org.springframework.security.core.Authentication; | |
| 13 | import org.springframework.web.bind.annotation.GetMapping; | |
| 14 | import org.springframework.web.bind.annotation.PathVariable; | |
| 15 | import org.springframework.web.bind.annotation.PostMapping; | |
| 16 | import org.springframework.web.bind.annotation.RequestBody; | |
| 17 | import org.springframework.web.bind.annotation.RequestMapping; | |
| 18 | import org.springframework.web.bind.annotation.RestController; | |
| 19 | ||
| 20 | /** Documentação para ProjectController. */ | |
| 21 | @RestController | |
| 22 | @RequestMapping("/api/projects") | |
| 23 | public class ProjectController { | |
| 24 | ||
| 25 | private final ProjectService projectService; | |
| 26 | ||
| 27 | /** Documentação para o método ProjectController. */ | |
| 28 | public ProjectController(ProjectService projectService) { | |
| 29 | this.projectService = projectService; | |
| 30 | } | |
| 31 | ||
| 32 | /** Documentação. */ | |
| 33 | @PostMapping | |
| 34 | public ResponseEntity<ProjectResponseDto> createProject( | |
| 35 | @RequestBody ProjectRequestDto dto, Authentication authentication) { | |
| 36 | User user = (User) authentication.getPrincipal(); | |
| 37 |
1
1. createProject : replaced return value with null for com/edtech/controller/ProjectController::createProject → KILLED |
return ResponseEntity.status(HttpStatus.CREATED) |
| 38 | .body(projectService.createProject(dto, user.getId())); | |
| 39 | } | |
| 40 | ||
| 41 | @GetMapping | |
| 42 | public ResponseEntity<List<ProjectResponseDto>> listProjects(Authentication authentication) { | |
| 43 | User user = (User) authentication.getPrincipal(); | |
| 44 |
1
1. listProjects : replaced return value with null for com/edtech/controller/ProjectController::listProjects → KILLED |
return ResponseEntity.ok(projectService.listProjectsByUser(user.getId())); |
| 45 | } | |
| 46 | ||
| 47 | /** Documentação. */ | |
| 48 | @PostMapping("/{projectId}/members") | |
| 49 | public ResponseEntity<Void> addMember( | |
| 50 | @PathVariable UUID projectId, | |
| 51 | @RequestBody(required = false) ProjectMemberRequestDto dto, | |
| 52 | Authentication authentication) { | |
| 53 | User authenticatedUser = (User) authentication.getPrincipal(); | |
| 54 |
1
1. addMember : removed call to com/edtech/service/ProjectService::addMember → NO_COVERAGE |
projectService.addMember(projectId, dto, authenticatedUser); |
| 55 |
1
1. addMember : replaced return value with null for com/edtech/controller/ProjectController::addMember → NO_COVERAGE |
return ResponseEntity.status(HttpStatus.CREATED).build(); |
| 56 | } | |
| 57 | } | |
Mutations | ||
| 37 |
1.1 |
|
| 44 |
1.1 |
|
| 54 |
1.1 |
|
| 55 |
1.1 |