endpointsd refactore
This commit is contained in:
parent
7c457ce232
commit
dfe534a835
@ -29,7 +29,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@CrossOrigin
|
||||
@RequestMapping("/api/" + App.API_VERSION + "/assignments")
|
||||
@Api(tags = {
|
||||
"Assignments" }, value = "Assignments", description = "Assignment is representation of student willing to join given group (lecture or calss)")
|
||||
"Assignments" }, value = "Assignments", description = "Assignment is representation of student willing to join given group (lecture or calss). This comtroller is depreaceted. Use commission instead")
|
||||
@Deprecated
|
||||
public class AssignmentsController extends TokenBasedController {
|
||||
|
||||
@Autowired
|
||||
@ -40,6 +41,7 @@ public class AssignmentsController extends TokenBasedController {
|
||||
|
||||
@GetMapping("/user")
|
||||
@ApiOperation(value = "Return user current assignemts (from newest commision). STUDENT Token needs to be provided.")
|
||||
@Deprecated
|
||||
public ResponseEntity<List<AssignmentResponse>> getCurrentAssignments() throws Exception {
|
||||
User user = this.getCurrentUser().orElseThrow(() -> new NullPointerException("User not found"));
|
||||
Optional<Commision> com = this.commisionService.getNewestCommision(user);
|
||||
|
@ -35,6 +35,11 @@ import org.springframework.util.Assert;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.plannaplan.responses.mappers.AssignmentResponseMappers;
|
||||
import com.plannaplan.responses.models.AssignmentResponse;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping("/api/" + App.API_VERSION + "/commisions")
|
||||
@ -114,6 +119,20 @@ public class CommisionController extends TokenBasedController {
|
||||
return new ResponseEntity<>(result, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/user/shedule")
|
||||
@ApiOperation(value = "Return user current assignemts (from newest commision). STUDENT Token needs to be provided.")
|
||||
public ResponseEntity<List<AssignmentResponse>> getCurrentAssignments() throws Exception {
|
||||
User user = this.getCurrentUser().orElseThrow(() -> new NullPointerException("User not found"));
|
||||
Optional<Commision> com = this.commisionService.getNewestCommision(user);
|
||||
|
||||
if (com.isPresent()) {
|
||||
List<Assignment> respone = this.assignmentService.getCommisionAssignments(com.get());
|
||||
return new ResponseEntity<>(AssignmentResponseMappers.mapToResponse(respone), HttpStatus.OK);
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(new ArrayList<>(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@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")
|
||||
@ -133,4 +152,20 @@ public class CommisionController extends TokenBasedController {
|
||||
return new ResponseEntity<>(result, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasRole('ROLE_DEANERY')")
|
||||
@GetMapping("/user/{id}/shedule")
|
||||
@ApiOperation(value = "Return given user current assignemts (from newest commision). DEANERY Token needs to be provided.")
|
||||
public ResponseEntity<List<AssignmentResponse>> getCurrentAssignmentsDeanery(
|
||||
@PathVariable(name = "id") Long userId) throws Exception {
|
||||
User user = this.userService.getById(userId).orElseThrow(() -> new NullPointerException());
|
||||
Optional<Commision> com = this.commisionService.getNewestCommision(user);
|
||||
|
||||
if (com.isPresent()) {
|
||||
List<Assignment> respone = this.assignmentService.getCommisionAssignments(com.get());
|
||||
return new ResponseEntity<>(AssignmentResponseMappers.mapToResponse(respone), HttpStatus.OK);
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(new ArrayList<>(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user