diff --git a/.DS_Store b/.DS_Store index 802b73a..9f092fd 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/AplicacionWEB/backend/asociationPlatform/src/main/java/com/urjc/asociationPlatform/controller/restController/AssoRestController.java b/AplicacionWEB/backend/asociationPlatform/src/main/java/com/urjc/asociationPlatform/controller/restController/AssoRestController.java index 38cbbf1..490e660 100644 --- a/AplicacionWEB/backend/asociationPlatform/src/main/java/com/urjc/asociationPlatform/controller/restController/AssoRestController.java +++ b/AplicacionWEB/backend/asociationPlatform/src/main/java/com/urjc/asociationPlatform/controller/restController/AssoRestController.java @@ -18,6 +18,13 @@ import com.urjc.asociationPlatform.model.User; import com.urjc.asociationPlatform.service.AsociationService; import com.urjc.asociationPlatform.service.UserService; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -47,6 +54,14 @@ private User getUser(HttpServletRequest request) { return null; } + + @Operation(summary = "Get personal Association") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Association obtained sucessfully",content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Asociation.class))}), + @ApiResponse(responseCode = "404", description = "comment not found", content = @Content) + + }) @GetMapping("/miAsociacion") public ResponseEntity getMyAsso(HttpServletRequest request) { User currentUser = checkAdminOrAsso("ASO", request); @@ -61,6 +76,13 @@ public ResponseEntity getMyAsso(HttpServletRequest request) { return new ResponseEntity<>(asso.get(), HttpStatus.OK); } + @Operation(summary = "Get Association by id") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Association obtained sucessfully",content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Asociation.class))}), + @ApiResponse(responseCode = "404", description = "Association not found", content = @Content) + + }) @GetMapping("/{id}") public ResponseEntity getById(@PathVariable long id) { Optional asso = assoService.findById(id); @@ -70,21 +92,53 @@ public ResponseEntity getById(@PathVariable long id) { return new ResponseEntity<>(asso.get(), HttpStatus.OK); } + @Operation(summary = "Get Association list") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Association list obtained sucessfully",content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Asociation.class))}) + + }) @GetMapping("/asociationsList") public ResponseEntity> ListAsso() { return new ResponseEntity<>(assoService.findAll(), HttpStatus.OK); } + @Operation(summary = "Edit personal association") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Association edited sucessfully",content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Asociation.class))}), + @ApiResponse(responseCode = "401", description = "current user doesn´t have the required permissions", content = @Content), + @ApiResponse(responseCode = "403", description = "these changes can´t be made", content = @Content), + @ApiResponse(responseCode = "404", description = "Asociation not found", content = @Content) + + }) @PutMapping("/miAsociacion") public ResponseEntity editMyAsso(@RequestBody Asociation asso, HttpServletRequest request) { return edditAssoAux("ASO", request, asso, null); } + @Operation(summary = "Edit association") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Association edited sucessfully",content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Asociation.class))}), + @ApiResponse(responseCode = "401", description = "current user doesn´t have the required permissions", content = @Content), + @ApiResponse(responseCode = "403", description = "these changes can´t be made", content = @Content), + @ApiResponse(responseCode = "404", description = "Asociation not found", content = @Content) + + }) @PutMapping("/{id}") public ResponseEntity editAsso(@RequestBody Asociation asso,@PathVariable long id, HttpServletRequest request) { return edditAssoAux("ADMIN", request, asso, id); } + @Operation(summary = "Delete Association") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Association deleted sucessfully",content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = Asociation.class))}), + @ApiResponse(responseCode = "401", description = "current user doesn´t have the required permissions", content = @Content), + @ApiResponse(responseCode = "404", description = "Association not found", content = @Content) + + }) @DeleteMapping("/{id}") public ResponseEntity deleteAsso(@PathVariable long id, HttpServletRequest request) { if (checkAdminOrAsso("ADMIN", request) == null)