54 lines
1.8 KiB
Java
Executable File
54 lines
1.8 KiB
Java
Executable File
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;
|
|
import com.plannaplan.services.ExchangeService;
|
|
|
|
/**
|
|
* 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;
|
|
|
|
@Autowired
|
|
private ExchangeService exchangeService;
|
|
|
|
/**
|
|
* @return if accept algoythm was perfomed
|
|
*/
|
|
@PreAuthorize("hasRole('ROLE_DEVELOPER')")
|
|
@PostMapping(path = "/algorythm/accept")
|
|
public ResponseEntity<String> performAcceptAlgorythm() {
|
|
this.assignmentService.callAcceptAlgorythm();
|
|
return new ResponseEntity<>("Success", HttpStatus.OK);
|
|
}
|
|
|
|
/**
|
|
* @return if accept algoythm was perfomed
|
|
*/
|
|
@PreAuthorize("hasRole('ROLE_DEVELOPER')")
|
|
@PostMapping(path = "/algorythm/exchange")
|
|
public ResponseEntity<String> performExchangeAlgorythm() {
|
|
this.exchangeService.performExchange();
|
|
return new ResponseEntity<>("Success", HttpStatus.OK);
|
|
}
|
|
}
|