Skip to content
Snippets Groups Projects
Commit c263cff9 authored by Jan Tymel's avatar Jan Tymel
Browse files

Revert "Remove trainingDefinitionId parameter from LevelOperationsController"

This reverts commit 44680688.
parent 44680688
No related branches found
No related tags found
No related merge requests found
...@@ -18,10 +18,10 @@ import org.springframework.web.bind.annotation.RequestMethod; ...@@ -18,10 +18,10 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@RequestMapping("/levels") @RequestMapping("/{definitionId}/levels")
@CrossOrigin(origins = "*", allowCredentials = "true", allowedHeaders = "*", @CrossOrigin(origins = "*", allowCredentials = "true", allowedHeaders = "*",
methods = {RequestMethod.GET, RequestMethod.POST, RequestMethod.DELETE, RequestMethod.PUT}) methods = {RequestMethod.GET, RequestMethod.POST, RequestMethod.DELETE, RequestMethod.PUT})
@Api(value = "/levels", tags = {"Level operations"}) @Api(value = "/{definitionId}/levels", tags = {"Level operations"})
public class LevelOperationsController { public class LevelOperationsController {
private final LevelOperationsService levelOperationsService; private final LevelOperationsService levelOperationsService;
...@@ -36,10 +36,12 @@ public class LevelOperationsController { ...@@ -36,10 +36,12 @@ public class LevelOperationsController {
@ApiResponses(value = {@ApiResponse(code = 200, message = "Level orders changed"), @ApiResponses(value = {@ApiResponse(code = 200, message = "Level orders changed"),
@ApiResponse(code = 500, message = "Unexpected application error")}) @ApiResponse(code = 500, message = "Unexpected application error")})
public void createInfoLevel( public void createInfoLevel(
@ApiParam(value = "Training definition ID", required = true) @PathVariable(name = "definitionId")
Long definitionId,
@ApiParam(value = "Level ID - from", required = true) @PathVariable(name = "levelIdFrom") Long levelIdFrom, @ApiParam(value = "Level ID - from", required = true) @PathVariable(name = "levelIdFrom") Long levelIdFrom,
@ApiParam(value = "Level ID - to", required = true) @PathVariable(name = "levelIdTo") Long levelIdTo) { @ApiParam(value = "Level ID - to", required = true) @PathVariable(name = "levelIdTo") Long levelIdTo) {
levelOperationsService.swapLevelsOrder(levelIdFrom, levelIdTo); levelOperationsService.swapLevelsOrder(definitionId, levelIdFrom, levelIdTo);
} }
@DeleteMapping(value = "/{levelId}", produces = MediaType.APPLICATION_JSON_VALUE) @DeleteMapping(value = "/{levelId}", produces = MediaType.APPLICATION_JSON_VALUE)
...@@ -47,7 +49,9 @@ public class LevelOperationsController { ...@@ -47,7 +49,9 @@ public class LevelOperationsController {
@ApiResponses(value = {@ApiResponse(code = 200, message = "Level deleted"), @ApiResponses(value = {@ApiResponse(code = 200, message = "Level deleted"),
@ApiResponse(code = 500, message = "Unexpected application error")}) @ApiResponse(code = 500, message = "Unexpected application error")})
public void deleteLevel( public void deleteLevel(
@ApiParam(value = "Training definition ID", required = true) @PathVariable(name = "definitionId")
Long definitionId,
@ApiParam(value = "Level ID - from", required = true) @PathVariable(name = "levelId") Long levelId) { @ApiParam(value = "Level ID - from", required = true) @PathVariable(name = "levelId") Long levelId) {
levelOperationsService.deleteLevel(levelId); levelOperationsService.deleteLevel(definitionId, levelId);
} }
} }
...@@ -13,7 +13,7 @@ public class LevelOperationsService { ...@@ -13,7 +13,7 @@ public class LevelOperationsService {
@Autowired @Autowired
private BaseLevelRepository baseLevelRepository; private BaseLevelRepository baseLevelRepository;
public void swapLevelsOrder(Long levelIdFrom, Long levelIdTo) { public void swapLevelsOrder(Long trainingDefinitionId, Long levelIdFrom, Long levelIdTo) {
Optional<BaseLevel> levelFrom = baseLevelRepository.findById(levelIdFrom); Optional<BaseLevel> levelFrom = baseLevelRepository.findById(levelIdFrom);
Optional<BaseLevel> levelTo = baseLevelRepository.findById(levelIdTo); Optional<BaseLevel> levelTo = baseLevelRepository.findById(levelIdTo);
...@@ -32,7 +32,7 @@ public class LevelOperationsService { ...@@ -32,7 +32,7 @@ public class LevelOperationsService {
baseLevelRepository.save(levelTo.get()); baseLevelRepository.save(levelTo.get());
} }
public void deleteLevel(Long levelId) { public void deleteLevel(Long trainingDefinitionId, Long levelId) {
Optional<BaseLevel> levelEntity = baseLevelRepository.findById(levelId); Optional<BaseLevel> levelEntity = baseLevelRepository.findById(levelId);
if (levelEntity.isEmpty()) { if (levelEntity.isEmpty()) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment