Students registered satistics

This commit is contained in:
Filip Izydorczyk
2021-01-21 15:41:56 +01:00
parent 7045844653
commit 676070c8c7
6 changed files with 106 additions and 34 deletions

View File

@ -12,8 +12,9 @@ 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.responses.models.StatisticSimpleNumberResponse;
import com.plannaplan.services.GroupService;
import com.plannaplan.services.UserService;
/**
* Rest controller to enpoint that help deveopler test the app
@ -29,15 +30,29 @@ public class StatisticsController {
@Autowired
private GroupService groupService;
@Autowired
private UserService userService;
/**
* @return if tour was set
*/
@PreAuthorize("hasRole('ROLE_DEANERY')")
@GetMapping(path = "/groups/created")
public ResponseEntity<StatisticCreatedGroupsResponse> getGroupsAmmounts() {
final StatisticCreatedGroupsResponse response = new StatisticCreatedGroupsResponse(
public ResponseEntity<StatisticSimpleNumberResponse> getGroupsAmmounts() {
final StatisticSimpleNumberResponse response = new StatisticSimpleNumberResponse(
this.groupService.getGroupsAmmount());
return new ResponseEntity<>(response, HttpStatus.OK);
}
/**
* @return amount of registered to some groups
*/
@PreAuthorize("hasRole('ROLE_DEANERY')")
@GetMapping(path = "/users/registered")
public ResponseEntity<StatisticSimpleNumberResponse> getCommisionsAmmounts() {
final StatisticSimpleNumberResponse response = new StatisticSimpleNumberResponse(
this.userService.getAmmountOfUsersWithAssignedGroups());
return new ResponseEntity<>(response, HttpStatus.OK);
}
}

View File

@ -1,23 +0,0 @@
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;
}
}

View File

@ -0,0 +1,23 @@
package com.plannaplan.responses.models;
/**
* Simple api response for number statistics
*/
public class StatisticSimpleNumberResponse {
private Integer ammount;
/**
* @param ammount to return as api response
*/
public StatisticSimpleNumberResponse(Integer ammount) {
this.ammount = ammount;
}
/**
* @return ammount
*/
public Integer getAmmount() {
return ammount;
}
}