Groups ammounts
This commit is contained in:
@ -0,0 +1,43 @@
|
||||
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.GetMapping;
|
||||
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.responses.models.StatisticCreatedGroupsResponse;
|
||||
import com.plannaplan.services.GroupService;
|
||||
|
||||
/**
|
||||
* Rest controller to enpoint that help deveopler test the app
|
||||
*/
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping("/api/" + App.API_VERSION + "/statistics")
|
||||
@Api(tags = {
|
||||
"StatisticsController" }, value = "StatisticsController", description = "Statistics are meant to be used by deanery only so in every endpoint you need to provide DEANERY token.")
|
||||
|
||||
public class StatisticsController {
|
||||
|
||||
@Autowired
|
||||
private GroupService groupService;
|
||||
|
||||
/**
|
||||
* @return if tour was set
|
||||
*/
|
||||
@PreAuthorize("hasRole('ROLE_DEANERY')")
|
||||
@GetMapping(path = "/groups/created")
|
||||
public ResponseEntity<StatisticCreatedGroupsResponse> getGroupsAmmounts() {
|
||||
final StatisticCreatedGroupsResponse response = new StatisticCreatedGroupsResponse(
|
||||
this.groupService.getGroupsAmmount());
|
||||
return new ResponseEntity<>(response, HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.plannaplan.responses.models;
|
||||
|
||||
/**
|
||||
* Api response for created groups statistics
|
||||
*/
|
||||
public class StatisticCreatedGroupsResponse {
|
||||
private Integer ammount;
|
||||
|
||||
/**
|
||||
* @param ammount created groups
|
||||
*/
|
||||
public StatisticCreatedGroupsResponse(Integer ammount) {
|
||||
this.ammount = ammount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ammount of created groups
|
||||
*/
|
||||
public Integer getAmmount() {
|
||||
return ammount;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user