diff --git a/backend/src/main/java/com/magistr/app/controller/GroupController.java b/backend/src/main/java/com/magistr/app/controller/GroupController.java index b8f7795..0365aea 100755 --- a/backend/src/main/java/com/magistr/app/controller/GroupController.java +++ b/backend/src/main/java/com/magistr/app/controller/GroupController.java @@ -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())); } diff --git a/backend/src/main/java/com/magistr/app/dto/CreateGroupRequest.java b/backend/src/main/java/com/magistr/app/dto/CreateGroupRequest.java index 43e604a..dfbe5a0 100755 --- a/backend/src/main/java/com/magistr/app/dto/CreateGroupRequest.java +++ b/backend/src/main/java/com/magistr/app/dto/CreateGroupRequest.java @@ -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; } diff --git a/backend/src/main/java/com/magistr/app/dto/GroupResponse.java b/backend/src/main/java/com/magistr/app/dto/GroupResponse.java index 63becb8..7dd7c58 100755 --- a/backend/src/main/java/com/magistr/app/dto/GroupResponse.java +++ b/backend/src/main/java/com/magistr/app/dto/GroupResponse.java @@ -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; } diff --git a/backend/src/main/java/com/magistr/app/model/StudentGroup.java b/backend/src/main/java/com/magistr/app/model/StudentGroup.java index 3ad914a..9deee86 100755 --- a/backend/src/main/java/com/magistr/app/model/StudentGroup.java +++ b/backend/src/main/java/com/magistr/app/model/StudentGroup.java @@ -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; } diff --git a/db/init/init.sql b/db/init/init.sql index d55142b..3c3339b 100755 --- a/db/init/init.sql +++ b/db/init/init.sql @@ -43,14 +43,16 @@ ON CONFLICT (name) DO NOTHING; CREATE TABLE IF NOT EXISTS student_groups ( id BIGSERIAL PRIMARY KEY, name VARCHAR(100) UNIQUE NOT NULL, + group_size BIGINT NOT NULL, education_form_id BIGINT NOT NULL REFERENCES education_forms(id), course INT CHECK (course BETWEEN 1 AND 6), created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); -- Тестовая базовая группа для работы -INSERT INTO student_groups (name, education_form_id, course) -VALUES ('ИВТ-21-1', 1, 3) +INSERT INTO student_groups (name, group_size, education_form_id, course) +VALUES ('ИВТ-21-1', 25, 1, 3), + ('ИБ-41м', 15, 2, 2) ON CONFLICT (name) DO NOTHING; -- ========================================== diff --git a/frontend/admin/js/views/groups.js b/frontend/admin/js/views/groups.js index 1a2b1d6..17301b5 100755 --- a/frontend/admin/js/views/groups.js +++ b/frontend/admin/js/views/groups.js @@ -68,6 +68,7 @@ export async function initGroups() {