new endpoint
This commit is contained in:
@ -42,6 +42,7 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.plannaplan.responses.mappers.AssignmentResponseMappers;
|
||||
import com.plannaplan.responses.models.AssignmentDetailedResponse;
|
||||
import com.plannaplan.responses.models.AssignmentResponse;
|
||||
|
||||
/**
|
||||
@ -161,6 +162,28 @@ public class CommisionController extends TokenBasedController {
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(result, HttpStatus.OK);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list of user latests assignmets
|
||||
* @throws UserNotFoundException if user was not found bny token
|
||||
*/
|
||||
@GetMapping("/user/assignments")
|
||||
@ApiOperation("Return list of latest user commision assignments. User is recognized via token")
|
||||
public ResponseEntity<List<AssignmentDetailedResponse>> getAllAssignmets() throws UserNotFoundException {
|
||||
final User user = this.getCurrentUser().orElseThrow(() -> new NullPointerException());
|
||||
|
||||
final Optional<Commision> latestCommision = this.commisionService.getNewestCommision(user);
|
||||
|
||||
if (latestCommision.isEmpty()) {
|
||||
return new ResponseEntity<>(new ArrayList<>(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
final List<AssignmentDetailedResponse> response = AssignmentResponseMappers
|
||||
.mapAssignmetnToDetialedResponse(latestCommision.get().getAssignments());
|
||||
|
||||
return new ResponseEntity<>(response, HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user