Vhevkpoint implemented but stiull some errors
This commit is contained in:
@ -41,10 +41,15 @@ public class GroupController {
|
||||
@RequestParam(name = "capacity", defaultValue = "true") @ApiParam(value = "Boolean if we want to have capacity field in response") Boolean capacity,
|
||||
@RequestParam(name = "takenPlaces", defaultValue = "false") @ApiParam(value = "Boolean if we want to have respoonse with information about taken places by other students") Boolean takenPlaces) {
|
||||
List<Groups> groups = this.groupService.getGroupsByCourse(id);
|
||||
HashMap<Long, Integer> ammounts;
|
||||
|
||||
if (takenPlaces) {
|
||||
ammounts = this.groupService.getTakenPlaces(groups);
|
||||
HashMap<Long, Integer> ammounts = this.groupService.getTakenPlaces(groups);
|
||||
if (capacity) {
|
||||
return new ResponseEntity<>(GroupsMappers.mapToGetCourseGroupsWithCapacityResponse(groups, ammounts),
|
||||
HttpStatus.OK);
|
||||
}
|
||||
return new ResponseEntity<>(GroupsMappers.mapToGetCourseGroupsDefaultResponse(groups, ammounts),
|
||||
HttpStatus.OK);
|
||||
}
|
||||
|
||||
if (capacity) {
|
||||
|
@ -80,20 +80,34 @@ public class GroupsMappers {
|
||||
}
|
||||
|
||||
public static CourseWithGroupsResponse<GroupWithCapacityResponse> mapToGetCourseGroupsWithCapacityResponse(
|
||||
List<Groups> groups) {
|
||||
List<Groups> groups, HashMap<Long, Integer> taken) {
|
||||
|
||||
List<GroupWithCapacityResponse> lectures = new ArrayList<>();
|
||||
List<GroupWithCapacityResponse> classes = new ArrayList<>();
|
||||
|
||||
groups.stream().forEach(group -> {
|
||||
if (group.getType() == GroupType.CLASS) {
|
||||
classes.add(new GroupWithCapacityResponse(group));
|
||||
if (taken != null) {
|
||||
classes.add(new GroupWithCapacityResponse(group, taken.get(group.getId())));
|
||||
} else {
|
||||
classes.add(new GroupWithCapacityResponse(group));
|
||||
}
|
||||
|
||||
} else {
|
||||
lectures.add(new GroupWithCapacityResponse(group));
|
||||
if (taken != null) {
|
||||
lectures.add(new GroupWithCapacityResponse(group, taken.get(group.getId())));
|
||||
} else {
|
||||
lectures.add(new GroupWithCapacityResponse(group));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return new CourseWithGroupsResponse<>(classes, lectures);
|
||||
}
|
||||
|
||||
public static CourseWithGroupsResponse<GroupWithCapacityResponse> mapToGetCourseGroupsWithCapacityResponse(
|
||||
List<Groups> groups) {
|
||||
return GroupsMappers.mapToGetCourseGroupsWithCapacityResponse(groups, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user