Class ProjectController
java.lang.Object
callofproject.dev.project.controller.ProjectController
@RestController
@RequestMapping("api/project/project")
public class ProjectController
extends Object
This class represents a controller for managing project-related operations.
It handles HTTP requests related to projects and interacts with the ProjectService.
-
Constructor Summary
ConstructorsConstructorDescriptionProjectController
(IProjectService projectService, com.fasterxml.jackson.databind.ObjectMapper objectMapper) Constructs a new ProjectController with the provided dependencies. -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<Object>
addProjectJoinRequest
(UUID projectId, UUID userId) Handles the HTTP POST request to send a project participant request.org.springframework.http.ResponseEntity<Object>
findAllOwnerProjectsByUserId
(UUID userId, int page) Handles the HTTP GET request to find all projects owned by a user, paginated by page number.org.springframework.http.ResponseEntity<Object>
findAllOwnerProjectsByUsername
(String username, int page) Handles the HTTP GET request to find all projects owned by a user with the given username, paginated by page number.org.springframework.http.ResponseEntity<Object>
findAllParticipantProjectByUserId
(String userId, int page) Handles the HTTP POST request to find all projects in which a user is a participant, paginated by page number.org.springframework.http.ResponseEntity<Object>
findAllProjectDiscoveryView
(int page) Handles the HTTP GET request to find all projects in a discovery view, paginated by page number.org.springframework.http.ResponseEntity<Object>
findProjectDetail
(UUID projectId) Handles the HTTP GET request to retrieve detailed information about a specific project.org.springframework.http.ResponseEntity<Object>
findProjectDetailIfHasPermission
(UUID projectId, UUID userId) Handles the HTTP GET request to find detailed information about a specific project if the user has permission.org.springframework.http.ResponseEntity<Object>
findProjectOverview
(UUID projectId) Handles the HTTP GET request to find an overview of a project by its unique identifier (UUID).org.springframework.http.ResponseEntity<Object>
findProjectOwnerView
(UUID userId, UUID projectId) Handles the HTTP GET request to find a project from the owner's perspective by user and project IDs.org.springframework.http.ResponseEntity<Object>
save
(@Valid ProjectSaveDTO saveDTO) Handles the HTTP POST request to save a new project.org.springframework.http.ResponseEntity<Object>
Handles the HTTP POST request to save a new project using a different version (V2) with a file attachment.org.springframework.http.ResponseEntity<Object>
updateProject
(@Valid ProjectUpdateDTO dto) Handles the HTTP PUT request to update an existing project.org.springframework.http.ResponseEntity<Object>
updateProjectV2
(String projectUpdateDTO, org.springframework.web.multipart.MultipartFile file) Handles the HTTP POST request to update an existing project using a different version (V2) with a file attachment.
-
Constructor Details
-
ProjectController
public ProjectController(IProjectService projectService, com.fasterxml.jackson.databind.ObjectMapper objectMapper) Constructs a new ProjectController with the provided dependencies.- Parameters:
projectService
- The IProjectService instance used for handling project-related operations.objectMapper
- The ObjectMapper instance used for JSON serialization and deserialization.
-
-
Method Details
-
save
@PostMapping("/create") public org.springframework.http.ResponseEntity<Object> save(@RequestBody @Valid @Valid ProjectSaveDTO saveDTO) Handles the HTTP POST request to save a new project.- Parameters:
saveDTO
- The ProjectSaveDTO containing project details to be saved.- Returns:
- ResponseEntity with the result of the save operation as ProjectDTO, or an error message in case of failure.
-
saveV2
@PostMapping("/create/v2") public org.springframework.http.ResponseEntity<Object> saveV2(@RequestParam("projectSaveDTO") String projectSaveDTOJson, @RequestParam("file") org.springframework.web.multipart.MultipartFile file) Handles the HTTP POST request to save a new project using a different version (V2) with a file attachment.- Parameters:
projectSaveDTOJson
- The JSON representation of the ProjectSaveDTO containing project details.file
- The file attachment, if any.- Returns:
- ResponseEntity with the result of the save operation as ProjectDTO, or an error message in case of failure.
-
updateProject
@PutMapping("/update") public org.springframework.http.ResponseEntity<Object> updateProject(@RequestBody @Valid @Valid ProjectUpdateDTO dto) Handles the HTTP PUT request to update an existing project.- Parameters:
dto
- The ProjectUpdateDTO containing project details to be updated.- Returns:
- ResponseEntity with the result of the update operation as ProjectDTO, or an error message in case of failure.
-
updateProjectV2
@PostMapping("/update/v2") public org.springframework.http.ResponseEntity<Object> updateProjectV2(@RequestParam("projectUpdateDTO") String projectUpdateDTO, @RequestParam(value="file",required=false) org.springframework.web.multipart.MultipartFile file) Handles the HTTP POST request to update an existing project using a different version (V2) with a file attachment.- Parameters:
projectUpdateDTO
- The JSON representation of the ProjectUpdateDTO containing updated project details.file
- The file attachment, if any.- Returns:
- ResponseEntity with the result of the update operation as ProjectDTO, or an error message in case of failure.
-
findAllParticipantProjectByUserId
@PostMapping("/participant/user-id") public org.springframework.http.ResponseEntity<Object> findAllParticipantProjectByUserId(@RequestParam("uid") String userId, @RequestParam("p") int page) Handles the HTTP POST request to find all projects in which a user is a participant, paginated by page number.- Parameters:
userId
- The unique identifier (UUID) of the user.page
- The page number for paginated results.- Returns:
- ResponseEntity containing ProjectDTO if successful, or an error message in case of failure.
-
findAllOwnerProjectsByUserId
@GetMapping("find/all/owner-id") public org.springframework.http.ResponseEntity<Object> findAllOwnerProjectsByUserId(@RequestParam("uid") UUID userId, @RequestParam("p") int page) Handles the HTTP GET request to find all projects owned by a user, paginated by page number.- Parameters:
userId
- The unique identifier (UUID) of the user.page
- The page number for paginated results.- Returns:
- ResponseEntity containing ProjectDTO if successful, or an error message in case of failure.
-
findAllOwnerProjectsByUsername
@GetMapping("find/all/owner-username") public org.springframework.http.ResponseEntity<Object> findAllOwnerProjectsByUsername(String username, int page) Handles the HTTP GET request to find all projects owned by a user with the given username, paginated by page number.- Parameters:
username
- The username of the user.page
- The page number for paginated results.- Returns:
- ResponseEntity containing ProjectDTO if successful, or an error message in case of failure.
-
findProjectOverview
@GetMapping("find/overview") public org.springframework.http.ResponseEntity<Object> findProjectOverview(@RequestParam("pid") UUID projectId) Handles the HTTP GET request to find an overview of a project by its unique identifier (UUID).- Parameters:
projectId
- The unique identifier (UUID) of the project.- Returns:
- ResponseEntity containing ProjectDTO if successful, or an error message in case of failure.
-
findProjectOwnerView
@GetMapping("find/detail/owner") public org.springframework.http.ResponseEntity<Object> findProjectOwnerView(@RequestParam("uid") UUID userId, @RequestParam("pid") UUID projectId) Handles the HTTP GET request to find a project from the owner's perspective by user and project IDs.- Parameters:
userId
- The unique identifier (UUID) of the user.projectId
- The unique identifier (UUID) of the project.- Returns:
- ResponseEntity containing ProjectDetailDTO if successful, or an error message in case of failure.
-
findAllProjectDiscoveryView
@GetMapping("discovery/all") public org.springframework.http.ResponseEntity<Object> findAllProjectDiscoveryView(@RequestParam("p") int page) Handles the HTTP GET request to find all projects in a discovery view, paginated by page number.- Parameters:
page
- The page number for paginated results.- Returns:
- ResponseEntity containing ProjectsDiscoveryDTO if successful, or an error message in case of failure.
-
addProjectJoinRequest
@PostMapping("/participant/request") public org.springframework.http.ResponseEntity<Object> addProjectJoinRequest(@RequestParam("pid") UUID projectId, @RequestParam("uid") UUID userId) Handles the HTTP POST request to send a project participant request.- Parameters:
projectId
- The unique identifier (UUID) of the project.userId
- The unique identifier (UUID) of the user sending the request.- Returns:
- ResponseEntity containing ProjectDTO if successful, or an error message in case of failure.
-
findProjectDetail
@GetMapping("/find/detail") public org.springframework.http.ResponseEntity<Object> findProjectDetail(@RequestParam("pid") UUID projectId) Handles the HTTP GET request to retrieve detailed information about a specific project.- Parameters:
projectId
- The unique identifier (UUID) of the project for which details are requested.- Returns:
- ResponseEntity containing detailed project information if successful, or an error message in case of failure.
-
findProjectDetailIfHasPermission
@GetMapping("/find/project-detail") public org.springframework.http.ResponseEntity<Object> findProjectDetailIfHasPermission(@RequestParam("pid") UUID projectId, @RequestParam("uid") UUID userId) Handles the HTTP GET request to find detailed information about a specific project if the user has permission.- Parameters:
projectId
- The unique identifier (UUID) of the project for which details are requested.userId
- The unique identifier (UUID) of the user making the request.- Returns:
- ResponseEntity containing detailed project information if the user has permission, or an error message in case of failure or lack of permission.
-