Tours endpoint
This commit is contained in:
@ -10,6 +10,7 @@ import com.plannaplan.App;
|
||||
import com.plannaplan.entities.User;
|
||||
import com.plannaplan.models.ConfigData;
|
||||
import com.plannaplan.models.TourData;
|
||||
import com.plannaplan.responses.models.ConfigTourResponse;
|
||||
import com.plannaplan.security.cas.CasUserIdentity;
|
||||
import com.plannaplan.security.cas.CasValidationExcepiton;
|
||||
import com.plannaplan.security.cas.CasValidator;
|
||||
@ -34,6 +35,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
/**
|
||||
* Rest controller to Config related endpoints. More detailed api docs is
|
||||
@ -167,4 +169,16 @@ public class ConfigController {
|
||||
return new ResponseEntity<>("Internal Server Error", HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return api response entity
|
||||
*/
|
||||
@GetMapping(path = "/admin/tour")
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
@ApiOperation("It will return what tour is currently on. You need to provide admin token.")
|
||||
public ResponseEntity<ConfigTourResponse> getTourDate() {
|
||||
final ConfigTourResponse response = new ConfigTourResponse(this.contrl.getCurrentConfig().getCurrentState());
|
||||
return new ResponseEntity<>(response, HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.plannaplan.responses.models;
|
||||
|
||||
import com.plannaplan.types.AppState;
|
||||
|
||||
/**
|
||||
* Api response for config tours entpoint
|
||||
*/
|
||||
public class ConfigTourResponse {
|
||||
|
||||
private String currentTour;
|
||||
|
||||
/**
|
||||
* @param appState to send as a response
|
||||
*/
|
||||
public ConfigTourResponse(AppState appState) {
|
||||
this.currentTour = appState.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return current app state as string
|
||||
*/
|
||||
public String getCurrentTour() {
|
||||
return currentTour;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user