Package com.plannaplan.controllers

# Class CommisionController

java.lang.Object
com.plannaplan.controllers.TokenBasedController
com.plannaplan.controllers.CommisionController

    @RestController
    @CrossOrigin
    @RequestMapping("/api/v1/commisions")
    public class CommisionController
    extends TokenBasedController

Rest controller to Commision and Assignment related endpoints. More detailed api docs is available via swagger

## Field Summary

### Fields inherited from class com.plannaplan.controllers.TokenBasedController

`userService`

## Constructor Summary

Constructors
Constructor | Description
--- | ---
`CommisionController()` |

## Method Summary

Modifier and Type | Method | Description
--- | --- | ---
`org.springframework.http.ResponseEntity<java.lang.String>` | `addCommision​(java.util.List<java.lang.Long> groups, java.lang.Long userId)` |
`org.springframework.http.ResponseEntity<java.util.List<? extends CommisionResponse>>` | `getAlCommisions​(java.lang.Boolean groups, java.lang.Boolean extraInfo)` |
`org.springframework.http.ResponseEntity<java.util.List<AssignmentDetailedResponse>>` | `getAllAssignmets()` |
`org.springframework.http.ResponseEntity<java.util.List<? extends CommisionResponse>>` | `getCommision​(java.lang.Long userId, java.lang.Boolean groups)` |
`org.springframework.http.ResponseEntity<java.util.List<AssignmentResponse>>` | `getCurrentAssignments()` |
`org.springframework.http.ResponseEntity<java.util.List<AssignmentResponse>>` | `getCurrentAssignmentsDeanery​(java.lang.Long userId)` |
`void` | `getFile​(javax.servlet.http.HttpServletResponse response)` |

### Methods inherited from class com.plannaplan.controllers.TokenBasedController

`getCurrentUser`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### CommisionController

public CommisionController()

## Method Details

### addCommision

@PostMapping({"/user","/user/{id}"}) public org.springframework.http.ResponseEntity<java.lang.String> addCommision​(@RequestBody java.util.List<java.lang.Long> groups, @PathVariable(name="id",required=false) java.lang.Long userId)

Parameters:
  `groups` - to make assignmetns
  `userId` - user to assign to groups
Returns:
  was operations success

### getAlCommisions

@GetMapping("/user") public org.springframework.http.ResponseEntity<java.util.List<? extends CommisionResponse>> getAlCommisions​(@RequestParam(name="groups",defaultValue="false") java.lang.Boolean groups, @RequestParam(name="extraInfo",defaultValue="false") java.lang.Boolean extraInfo) throws com.plannaplan.exceptions.UserNotFoundException

Parameters:
  `groups` - should include groups list in response
Returns:
  list of user all commisions (history of schedules)
Throws:
  `com.plannaplan.exceptions.UserNotFoundException` - if user was found

### getAllAssignmets

@GetMapping("/user/assignments") public org.springframework.http.ResponseEntity<java.util.List<AssignmentDetailedResponse>> getAllAssignmets() throws com.plannaplan.exceptions.UserNotFoundException

Returns:
  list of user latests assignmets
Throws:
  `com.plannaplan.exceptions.UserNotFoundException` - if user was not found bny token

### getCurrentAssignments

@GetMapping("/user/schedule") public org.springframework.http.ResponseEntity<java.util.List<AssignmentResponse>> getCurrentAssignments() throws java.lang.Exception

Returns:
  current schedule of user indenified via token
Throws:
  `java.lang.Exception` - if incorrect role was trying to see self schedule (for example DEANERY don't have a schedule)

### getCommision

@PreAuthorize("hasRole(\'ROLE_DEANERY\')") @GetMapping("/user/{id}") public org.springframework.http.ResponseEntity<java.util.List<? extends CommisionResponse>> getCommision​(@PathVariable(name="id") java.lang.Long userId, @RequestParam(name="groups",defaultValue="false") java.lang.Boolean groups) throws com.plannaplan.exceptions.UserNotFoundException

Parameters:
  `userId` - user id in db
  `groups` - should commision include assigned groups list
Returns:
  list of commisions for given user
Throws:
  `com.plannaplan.exceptions.UserNotFoundException`

### getCurrentAssignmentsDeanery

@PreAuthorize("hasRole(\'ROLE_DEANERY\')") @GetMapping("/user/{id}/schedule") public org.springframework.http.ResponseEntity<java.util.List<AssignmentResponse>> getCurrentAssignmentsDeanery​(@PathVariable(name="id") java.lang.Long userId) throws java.lang.Exception

Parameters:
  `userId` - schedule to display owner
Returns:
  user's schedule
Throws:
  `java.lang.Exception` - if incorrect access atempt occured

### getFile

@GetMapping("/export/csv") @PreAuthorize("hasRole(\'ROLE_ADMIN\')") public void getFile​(javax.servlet.http.HttpServletResponse response)

Parameters:
  `response` - spring response to set headers