Добавил для групп поле численности.
В модалку на UI добавил отображение численности групп и вместимости аудиторий, проверку на доступность и вместимость.
This commit is contained in:
@@ -32,6 +32,7 @@ public class GroupController {
|
||||
.map(g -> new GroupResponse(
|
||||
g.getId(),
|
||||
g.getName(),
|
||||
g.getGroupSize(),
|
||||
g.getEducationForm().getId(),
|
||||
g.getEducationForm().getName()))
|
||||
.toList();
|
||||
@@ -45,6 +46,9 @@ public class GroupController {
|
||||
if (groupRepository.findByName(request.getName().trim()).isPresent()) {
|
||||
return ResponseEntity.badRequest().body(Map.of("message", "Группа с таким названием уже существует"));
|
||||
}
|
||||
if (request.getGroupSize() == null) {
|
||||
return ResponseEntity.badRequest().body(Map.of("message", "Численность группы обязательна"));
|
||||
}
|
||||
if (request.getEducationFormId() == null) {
|
||||
return ResponseEntity.badRequest().body(Map.of("message", "Форма обучения обязательна"));
|
||||
}
|
||||
@@ -56,12 +60,14 @@ public class GroupController {
|
||||
|
||||
StudentGroup group = new StudentGroup();
|
||||
group.setName(request.getName().trim());
|
||||
group.setGroupSize(request.getGroupSize());
|
||||
group.setEducationForm(efOpt.get());
|
||||
groupRepository.save(group);
|
||||
|
||||
return ResponseEntity.ok(new GroupResponse(
|
||||
group.getId(),
|
||||
group.getName(),
|
||||
group.getGroupSize(),
|
||||
group.getEducationForm().getId(),
|
||||
group.getEducationForm().getName()));
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.magistr.app.dto;
|
||||
public class CreateGroupRequest {
|
||||
|
||||
private String name;
|
||||
private Long groupSize;
|
||||
private Long educationFormId;
|
||||
|
||||
public String getName() {
|
||||
@@ -13,6 +14,14 @@ public class CreateGroupRequest {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Long getGroupSize() {
|
||||
return groupSize;
|
||||
}
|
||||
|
||||
public void setGroupSize(Long groupSize) {
|
||||
this.groupSize = groupSize;
|
||||
}
|
||||
|
||||
public Long getEducationFormId() {
|
||||
return educationFormId;
|
||||
}
|
||||
|
||||
@@ -4,12 +4,14 @@ public class GroupResponse {
|
||||
|
||||
private Long id;
|
||||
private String name;
|
||||
private Long groupSize;
|
||||
private Long educationFormId;
|
||||
private String educationFormName;
|
||||
|
||||
public GroupResponse(Long id, String name, Long educationFormId, String educationFormName) {
|
||||
public GroupResponse(Long id, String name, Long groupSize, Long educationFormId, String educationFormName) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.groupSize = groupSize;
|
||||
this.educationFormId = educationFormId;
|
||||
this.educationFormName = educationFormName;
|
||||
}
|
||||
@@ -22,6 +24,10 @@ public class GroupResponse {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Long getGroupSize() {
|
||||
return groupSize;
|
||||
}
|
||||
|
||||
public Long getEducationFormId() {
|
||||
return educationFormId;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,9 @@ public class StudentGroup {
|
||||
@Column(unique = true, nullable = false, length = 100)
|
||||
private String name;
|
||||
|
||||
@Column(name = "group_size", nullable = false)
|
||||
private Long groupSize;
|
||||
|
||||
@ManyToOne(optional = false)
|
||||
@JoinColumn(name = "education_form_id", nullable = false)
|
||||
private EducationForm educationForm;
|
||||
@@ -36,6 +39,14 @@ public class StudentGroup {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Long getGroupSize() {
|
||||
return groupSize;
|
||||
}
|
||||
|
||||
public void setGroupSize(Long groupSize) {
|
||||
this.groupSize = groupSize;
|
||||
}
|
||||
|
||||
public EducationForm getEducationForm() {
|
||||
return educationForm;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user