Added call perform algorythm enpoint

This commit is contained in:
Filip Izydorczyk
2021-01-19 12:05:31 +01:00
parent 7b9e334328
commit 7f647f9b8a
4 changed files with 106 additions and 4 deletions

View File

@ -0,0 +1,39 @@
package com.plannaplan.controllers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import com.plannaplan.App;
import com.plannaplan.services.AssignmentService;
/**
* Rest controller to enpoint that help deveopler test the app
*/
@RestController
@CrossOrigin
@RequestMapping("/api/" + App.API_VERSION + "/developer")
@Api(tags = {
"DeveloperController" }, value = "DeveloperController", description = "All endpoints to use in development time to help app testing")
public class DeveloperController {
@Autowired
private AssignmentService assignmentService;
/**
* @return if accept algoythm was perfomed
*/
@PreAuthorize("hasRole('ROLE_DEVELOPER')")
@PostMapping(path = "/algoythm/accept")
public ResponseEntity<String> performAcceptAlgorythm() {
this.assignmentService.callAcceptAlgorythm();
return new ResponseEntity<>("Success", HttpStatus.OK);
}
}

View File

@ -10,7 +10,8 @@ import org.springframework.security.core.GrantedAuthority;
* Users Roles for spring app
*/
public enum AuthorityRoles implements GrantedAuthority {
STUDENT("ROLE_STUDENT"), DEANERY("ROLE_DEANERY"), ADMIN("ROLE_ADMIN"), TEST_USER("ROLE_TESTUSER");
STUDENT("ROLE_STUDENT"), DEANERY("ROLE_DEANERY"), ADMIN("ROLE_ADMIN"), TEST_USER("ROLE_TESTUSER"),
DEVELOPER("ROLE_DEVELOPER");
private String role;
@ -39,6 +40,8 @@ public enum AuthorityRoles implements GrantedAuthority {
return Optional.of(AuthorityRoles.STUDENT);
case TEST_USER:
return Optional.of(AuthorityRoles.TEST_USER);
case DEVELOPER:
return Optional.of(AuthorityRoles.DEVELOPER);
default:
return Optional.empty();
}