controllers docs checkpoint

This commit is contained in:
Filip Izydorczyk
2021-01-16 13:57:58 +01:00
parent e600e84ae2
commit 9372ea5562
7 changed files with 137 additions and 14 deletions

View File

@ -43,6 +43,10 @@ import java.util.HashMap;
import com.plannaplan.responses.mappers.AssignmentResponseMappers;
import com.plannaplan.responses.models.AssignmentResponse;
/**
* Rest controller to Commision and Assignment related endpoints. More detailed
* api docs is available via swagger
*/
@RestController
@CrossOrigin
@RequestMapping("/api/" + App.API_VERSION + "/commisions")
@ -64,6 +68,11 @@ public class CommisionController extends TokenBasedController {
public CommisionController() {
}
/**
* @param groups to make assignmetns
* @param userId user to assign to groups
* @return was operations success
*/
@PostMapping(value = { "/user", "/user/{id}" })
@ApiOperation(value = "Create commision with assignents to given groups. If group doesn't exist error will be thrown")
public ResponseEntity<String> addCommision(
@ -108,6 +117,11 @@ public class CommisionController extends TokenBasedController {
}
}
/**
* @param groups should include groups list in response
* @return list of user all commisions (history of schedules)
* @throws UserNotFoundException if user was found
*/
@GetMapping("/user")
@ApiOperation("Return list of user all commisions (history of schedules)")
public ResponseEntity<List<? extends CommisionResponse>> getAlCommisions(
@ -127,6 +141,11 @@ public class CommisionController extends TokenBasedController {
return new ResponseEntity<>(result, HttpStatus.OK);
}
/**
* @return current schedule of user indenified via token
* @throws Exception if incorrect role was trying to see self schedule (for
* example DEANERY don't have a schedule)
*/
@GetMapping("/user/schedule")
@ApiOperation(value = "Return user current assignemts (from newest commision). STUDENT Token needs to be provided.")
public ResponseEntity<List<AssignmentResponse>> getCurrentAssignments() throws Exception {
@ -144,6 +163,12 @@ public class CommisionController extends TokenBasedController {
return new ResponseEntity<>(new ArrayList<>(), HttpStatus.OK);
}
/**
* @param userId user id in db
* @param groups should commision include assigned groups list
* @return list of commisions for given user
* @throws UserNotFoundException
*/
@PreAuthorize("hasRole('ROLE_DEANERY')")
@GetMapping("/user/{id}")
@ApiOperation("Return list of commisions for given user. To be able to access this data u need to provide DEANERY token")
@ -163,6 +188,11 @@ public class CommisionController extends TokenBasedController {
return new ResponseEntity<>(result, HttpStatus.OK);
}
/**
* @param userId schedule to display owner
* @return user's schedule
* @throws Exception if incorrect access atempt occured
*/
@PreAuthorize("hasRole('ROLE_DEANERY')")
@GetMapping("/user/{id}/schedule")
@ApiOperation(value = "Return given user current assignemts (from newest commision). DEANERY Token needs to be provided.")