Реализовал метод на получение данных для расписания по нужным критериям. Обновил БД
This commit is contained in:
@@ -46,7 +46,8 @@ public class GroupController {
|
|||||||
g.getEducationForm().getId(),
|
g.getEducationForm().getId(),
|
||||||
g.getEducationForm().getName(),
|
g.getEducationForm().getName(),
|
||||||
g.getDepartmentId(),
|
g.getDepartmentId(),
|
||||||
g.getCourse()
|
g.getCourse(),
|
||||||
|
g.getSpecialityCode()
|
||||||
))
|
))
|
||||||
.toList();
|
.toList();
|
||||||
logger.info("Получено {} групп", response.size());
|
logger.info("Получено {} групп", response.size());
|
||||||
@@ -114,6 +115,11 @@ public class GroupController {
|
|||||||
logger.error("Ошибка валидации: {}", errorMessage);
|
logger.error("Ошибка валидации: {}", errorMessage);
|
||||||
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
||||||
}
|
}
|
||||||
|
if (request.getSpecialityCode() == null || request.getSpecialityCode() == 0) {
|
||||||
|
String errorMessage = "Код специальности обязателен";
|
||||||
|
logger.error("Ошибка валидации: {}", errorMessage);
|
||||||
|
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
||||||
|
}
|
||||||
|
|
||||||
Optional<EducationForm> efOpt = educationFormRepository.findById(request.getEducationFormId());
|
Optional<EducationForm> efOpt = educationFormRepository.findById(request.getEducationFormId());
|
||||||
if (efOpt.isEmpty()) {
|
if (efOpt.isEmpty()) {
|
||||||
@@ -126,6 +132,7 @@ public class GroupController {
|
|||||||
group.setEducationForm(efOpt.get());
|
group.setEducationForm(efOpt.get());
|
||||||
group.setDepartmentId(request.getDepartmentId());
|
group.setDepartmentId(request.getDepartmentId());
|
||||||
group.setCourse(request.getCourse());
|
group.setCourse(request.getCourse());
|
||||||
|
group.setSpecialityCode(request.getSpecialityCode());
|
||||||
groupRepository.save(group);
|
groupRepository.save(group);
|
||||||
|
|
||||||
logger.info("Группа успешно создана с ID - {}", group.getId());
|
logger.info("Группа успешно создана с ID - {}", group.getId());
|
||||||
@@ -137,7 +144,8 @@ public class GroupController {
|
|||||||
group.getEducationForm().getId(),
|
group.getEducationForm().getId(),
|
||||||
group.getEducationForm().getName(),
|
group.getEducationForm().getName(),
|
||||||
group.getDepartmentId(),
|
group.getDepartmentId(),
|
||||||
group.getCourse()));
|
group.getCourse(),
|
||||||
|
group.getSpecialityCode()));
|
||||||
} catch (Exception e ) {
|
} catch (Exception e ) {
|
||||||
logger.error("Ошибка при создании группы: {}", e.getMessage(), e);
|
logger.error("Ошибка при создании группы: {}", e.getMessage(), e);
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||||
|
|||||||
@@ -1,30 +1,43 @@
|
|||||||
package com.magistr.app.controller;
|
package com.magistr.app.controller;
|
||||||
|
|
||||||
import com.magistr.app.model.Department;
|
import com.magistr.app.dto.ScheduleResponse;
|
||||||
import com.magistr.app.model.ScheduleData;
|
import com.magistr.app.model.*;
|
||||||
import com.magistr.app.repository.DepartmentRepository;
|
import com.magistr.app.repository.*;
|
||||||
import com.magistr.app.repository.ScheduleDataRepository;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/scheduledata")
|
@RequestMapping("/api/department/schedule")
|
||||||
public class ScheduleDataController {
|
public class ScheduleDataController {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ScheduleDataController.class);
|
private static final Logger logger = LoggerFactory.getLogger(ScheduleDataController.class);
|
||||||
|
|
||||||
private final ScheduleDataRepository scheduleDataRepository;
|
private final ScheduleDataRepository scheduleDataRepository;
|
||||||
|
private final GroupRepository groupRepository;
|
||||||
|
private final SpecialtiesRepository specialtiesRepository;
|
||||||
|
private final SubjectRepository subjectRepository;
|
||||||
|
private final LessonTypesRepository lessonTypesRepository;
|
||||||
|
private final UserRepository userRepository;
|
||||||
|
|
||||||
public ScheduleDataController(ScheduleDataRepository scheduleDataRepository) {
|
public ScheduleDataController(ScheduleDataRepository scheduleDataRepository, GroupRepository groupRepository, SpecialtiesRepository specialtiesRepository, SubjectRepository subjectRepository, LessonTypesRepository lessonTypesRepository, UserRepository userRepository) {
|
||||||
this.scheduleDataRepository = scheduleDataRepository;
|
this.scheduleDataRepository = scheduleDataRepository;
|
||||||
|
this.groupRepository = groupRepository;
|
||||||
|
this.specialtiesRepository = specialtiesRepository;
|
||||||
|
this.subjectRepository = subjectRepository;
|
||||||
|
this.lessonTypesRepository = lessonTypesRepository;
|
||||||
|
this.userRepository = userRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping("/allList")
|
||||||
public List<ScheduleData> getAllScheduleDataList() {
|
public List<ScheduleData> getAllScheduleDataList() {
|
||||||
logger.info("Получен запрос на получение списка данных расписаний");
|
logger.info("Получен запрос на получение списка данных расписаний");
|
||||||
try {
|
try {
|
||||||
@@ -51,4 +64,83 @@ public class ScheduleDataController {
|
|||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public ResponseEntity<?> getSingleScheduleData(
|
||||||
|
@RequestParam Long departmentId,
|
||||||
|
@RequestParam SemesterType semesterType,
|
||||||
|
@RequestParam String period
|
||||||
|
) {
|
||||||
|
logger.info("Получен запрос на получение списка данных расписания по конкретным данным: departmentId = {}, semester = {}, period = {}",
|
||||||
|
departmentId, semesterType, period);
|
||||||
|
try {
|
||||||
|
List<ScheduleData> scheduleData = scheduleDataRepository.findByDepartmentIdAndSemesterTypeAndPeriod(departmentId, semesterType, period );
|
||||||
|
|
||||||
|
if(scheduleData.isEmpty()){
|
||||||
|
logger.info("По параметрам: departmentId = {}, semester = {}, period = {} не найдено записей", departmentId, semesterType, period);
|
||||||
|
return ResponseEntity.ok(Map.of(
|
||||||
|
"message", "Записей не найдено"
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ScheduleResponse> response = scheduleData.stream()
|
||||||
|
.map( s -> {
|
||||||
|
String groupName = groupRepository.findById(s.getGroupId())
|
||||||
|
.map(StudentGroup::getName)
|
||||||
|
.orElse("Неизвестно");
|
||||||
|
|
||||||
|
Integer groupCourse = groupRepository.findById(s.getGroupId())
|
||||||
|
.map(StudentGroup::getCourse)
|
||||||
|
.orElse(null);
|
||||||
|
|
||||||
|
String specialityCode = "Неизвестно";
|
||||||
|
StudentGroup group = groupRepository.findById(s.getGroupId()).orElse(null);
|
||||||
|
if (group != null) {
|
||||||
|
Long specialityId = group.getSpecialityCode();
|
||||||
|
specialityCode = specialtiesRepository.findById(specialityId).
|
||||||
|
map(Speciality::getSpecialityCode)
|
||||||
|
.orElse("Неизвестно");
|
||||||
|
}
|
||||||
|
|
||||||
|
String subjectName = subjectRepository.findById(s.getSubjectsId())
|
||||||
|
.map(Subject::getName)
|
||||||
|
.orElse("Неизвестно");
|
||||||
|
|
||||||
|
String lessonType = lessonTypesRepository.findById(s.getLessonTypeId())
|
||||||
|
.map(LessonType::getLessonType)
|
||||||
|
.orElse("Неизвестно");
|
||||||
|
|
||||||
|
String teacherName = userRepository.findById(s.getTeacherId())
|
||||||
|
.map(User::getFullName)
|
||||||
|
.orElse("Неизвестно");
|
||||||
|
|
||||||
|
String teacherjobTitle = userRepository.findById(s.getTeacherId())
|
||||||
|
.map(User::getJobTitle)
|
||||||
|
.orElse("Неизвестно");
|
||||||
|
|
||||||
|
return new ScheduleResponse(
|
||||||
|
s.getId(),
|
||||||
|
s.getDepartmentId(),
|
||||||
|
specialityCode,
|
||||||
|
s.getSemester(),
|
||||||
|
groupName,
|
||||||
|
groupCourse,
|
||||||
|
subjectName,
|
||||||
|
lessonType,
|
||||||
|
s.getNumberOfHours(),
|
||||||
|
s.getDivision(),
|
||||||
|
teacherName,
|
||||||
|
teacherjobTitle,
|
||||||
|
s.getSemesterType(),
|
||||||
|
s.getPeriod());
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.toList();
|
||||||
|
logger.info("Получено {} записей для кафедры с ID - {}", response.size(), departmentId);
|
||||||
|
return ResponseEntity.ok(response);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Ошибка при получении списка данных расписаний для кафедры с ID - {}, semester - {}, period - {}: {}", departmentId, semesterType, period, e.getMessage(), e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,7 @@ public class CreateGroupRequest {
|
|||||||
private Long educationFormId;
|
private Long educationFormId;
|
||||||
private Long departmentId;
|
private Long departmentId;
|
||||||
private Integer course;
|
private Integer course;
|
||||||
|
private Long specialityCode;
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
@@ -47,4 +48,12 @@ public class CreateGroupRequest {
|
|||||||
public void setCourse(Integer course) {
|
public void setCourse(Integer course) {
|
||||||
this.course = course;
|
this.course = course;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getSpecialityCode() {
|
||||||
|
return specialityCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpecialityCode(Long specialityCode) {
|
||||||
|
this.specialityCode = specialityCode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.magistr.app.dto;
|
package com.magistr.app.dto;
|
||||||
|
|
||||||
|
import com.magistr.app.model.SemesterType;
|
||||||
|
|
||||||
public class CreateScheduleDataRequest {
|
public class CreateScheduleDataRequest {
|
||||||
private Long id;
|
private Long id;
|
||||||
private Long departmentId;
|
private Long departmentId;
|
||||||
@@ -10,7 +12,7 @@ public class CreateScheduleDataRequest {
|
|||||||
private Long numberOfHours;
|
private Long numberOfHours;
|
||||||
private Boolean isDivision;
|
private Boolean isDivision;
|
||||||
private Long teacherId;
|
private Long teacherId;
|
||||||
private String semesterType;
|
private SemesterType semesterType;
|
||||||
private String period;
|
private String period;
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
@@ -85,11 +87,11 @@ public class CreateScheduleDataRequest {
|
|||||||
this.teacherId = teacherId;
|
this.teacherId = teacherId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSemesterType() {
|
public SemesterType getSemesterType() {
|
||||||
return semesterType;
|
return semesterType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSemesterType(String semesterType) {
|
public void setSemesterType(SemesterType semesterType) {
|
||||||
this.semesterType = semesterType;
|
this.semesterType = semesterType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,9 @@ public class GroupResponse {
|
|||||||
private String educationFormName;
|
private String educationFormName;
|
||||||
private Long departmentId;
|
private Long departmentId;
|
||||||
private Integer course;
|
private Integer course;
|
||||||
|
private Long specialityCode;
|
||||||
|
|
||||||
public GroupResponse(Long id, String name, Long groupSize, Long educationFormId, String educationFormName, Long departmentId, Integer course) {
|
public GroupResponse(Long id, String name, Long groupSize, Long educationFormId, String educationFormName, Long departmentId, Integer course, Long specialityCode) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.groupSize = groupSize;
|
this.groupSize = groupSize;
|
||||||
@@ -18,6 +19,7 @@ public class GroupResponse {
|
|||||||
this.educationFormName = educationFormName;
|
this.educationFormName = educationFormName;
|
||||||
this.departmentId = departmentId;
|
this.departmentId = departmentId;
|
||||||
this.course = course;
|
this.course = course;
|
||||||
|
this.specialityCode = specialityCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
@@ -47,4 +49,8 @@ public class GroupResponse {
|
|||||||
public Integer getCourse() {
|
public Integer getCourse() {
|
||||||
return course;
|
return course;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getSpecialityCode() {
|
||||||
|
return specialityCode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,30 @@
|
|||||||
package com.magistr.app.dto;
|
package com.magistr.app.dto;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.magistr.app.model.SemesterType;
|
||||||
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class ScheduleResponse {
|
public class ScheduleResponse {
|
||||||
private Long id;
|
private Long id;
|
||||||
|
private String specialityCode;
|
||||||
private Long departmentId;
|
private Long departmentId;
|
||||||
private Long semester;
|
private Long semester;
|
||||||
private Long groupId;
|
private Long groupId;
|
||||||
|
private String groupName;
|
||||||
|
private Integer groupCourse;
|
||||||
private Long subjectsId;
|
private Long subjectsId;
|
||||||
|
private String subjectName;
|
||||||
private Long lessonTypeId;
|
private Long lessonTypeId;
|
||||||
|
private String lessonType;
|
||||||
private Long numberOfHours;
|
private Long numberOfHours;
|
||||||
private Boolean isDivision;
|
private Boolean isDivision;
|
||||||
private Long teacherId;
|
private Long teacherId;
|
||||||
private String semesterType;
|
private String teacherName;
|
||||||
|
private String teacherJobTitle;
|
||||||
|
private SemesterType semesterType;
|
||||||
private String period;
|
private String period;
|
||||||
|
|
||||||
public ScheduleResponse(Long id, Long departmentId, Long semester, Long groupId, Long subjectsId, Long lessonTypeId, Long numberOfHours, Boolean isDivision, Long teacherId, String semesterType, String period) {
|
public ScheduleResponse(Long id, Long departmentId, Long semester, Long groupId, Long subjectsId, Long lessonTypeId, String lessonType, Long numberOfHours, Boolean isDivision, Long teacherId, SemesterType semesterType, String period) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.departmentId = departmentId;
|
this.departmentId = departmentId;
|
||||||
this.semester = semester;
|
this.semester = semester;
|
||||||
@@ -30,91 +38,92 @@ public class ScheduleResponse {
|
|||||||
this.period = period;
|
this.period = period;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ScheduleResponse(Long id, Long departmentId, String specialityCode, Long semester, String groupName, Integer groupCourse, String subjectName, String lessonType, Long numberOfHours, Boolean isDivision, String teacherName, String teacherJobTitle, SemesterType semesterType, String period) {
|
||||||
|
this.id = id;
|
||||||
|
this.departmentId = departmentId;
|
||||||
|
this.specialityCode = specialityCode;
|
||||||
|
this.semester = semester;
|
||||||
|
this.groupName = groupName;
|
||||||
|
this.groupCourse = groupCourse;
|
||||||
|
this.subjectName = subjectName;
|
||||||
|
this.lessonType = lessonType;
|
||||||
|
this.numberOfHours = numberOfHours;
|
||||||
|
this.isDivision = isDivision;
|
||||||
|
this.teacherName = teacherName;
|
||||||
|
this.teacherJobTitle = teacherJobTitle;
|
||||||
|
this.semesterType = semesterType;
|
||||||
|
this.period = period;
|
||||||
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(Long id) {
|
public String getSpecialityCode() {
|
||||||
this.id = id;
|
return specialityCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getDepartmentId() {
|
public Long getDepartmentId() {
|
||||||
return departmentId;
|
return departmentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDepartmentId(Long departmentId) {
|
|
||||||
this.departmentId = departmentId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getSemester() {
|
public Long getSemester() {
|
||||||
return semester;
|
return semester;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSemester(Long semester) {
|
|
||||||
this.semester = semester;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getGroupId() {
|
public Long getGroupId() {
|
||||||
return groupId;
|
return groupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGroupId(Long groupId) {
|
public String getGroupName() {
|
||||||
this.groupId = groupId;
|
return groupName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getGroupCourse() {
|
||||||
|
return groupCourse;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getSubjectsId() {
|
public Long getSubjectsId() {
|
||||||
return subjectsId;
|
return subjectsId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSubjectsId(Long subjectsId) {
|
public String getSubjectName() {
|
||||||
this.subjectsId = subjectsId;
|
return subjectName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getLessonTypeId() {
|
public Long getLessonTypeId() {
|
||||||
return lessonTypeId;
|
return lessonTypeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLessonTypeId(Long lessonTypeId) {
|
public String getLessonType() {
|
||||||
this.lessonTypeId = lessonTypeId;
|
return lessonType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getNumberOfHours() {
|
public Long getNumberOfHours() {
|
||||||
return numberOfHours;
|
return numberOfHours;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNumberOfHours(Long numberOfHours) {
|
|
||||||
this.numberOfHours = numberOfHours;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getDivision() {
|
public Boolean getDivision() {
|
||||||
return isDivision;
|
return isDivision;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDivision(Boolean division) {
|
|
||||||
isDivision = division;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getTeacherId() {
|
public Long getTeacherId() {
|
||||||
return teacherId;
|
return teacherId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTeacherId(Long teacherId) {
|
public String getTeacherName() {
|
||||||
this.teacherId = teacherId;
|
return teacherName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSemesterType() {
|
public String getTeacherJobTitle() {
|
||||||
|
return teacherJobTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SemesterType getSemesterType() {
|
||||||
return semesterType;
|
return semesterType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSemesterType(String semesterType) {
|
|
||||||
this.semesterType = semesterType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPeriod() {
|
public String getPeriod() {
|
||||||
return period;
|
return period;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPeriod(String period) {
|
|
||||||
this.period = period;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
31
backend/src/main/java/com/magistr/app/model/LessonType.java
Normal file
31
backend/src/main/java/com/magistr/app/model/LessonType.java
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
package com.magistr.app.model;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name="lesson_types")
|
||||||
|
public class LessonType {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Column(name="name", nullable = false)
|
||||||
|
private String lessonType;
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLessonType() {
|
||||||
|
return lessonType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLessonType(String lessonType) {
|
||||||
|
this.lessonType = lessonType;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -34,15 +34,16 @@ public class ScheduleData {
|
|||||||
@Column(name="teacher_id", nullable = false)
|
@Column(name="teacher_id", nullable = false)
|
||||||
private Long teacherId;
|
private Long teacherId;
|
||||||
|
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
@Column(name="semester_type", nullable = false)
|
@Column(name="semester_type", nullable = false)
|
||||||
private String semesterType;
|
private SemesterType semesterType;
|
||||||
|
|
||||||
@Column(name="period", nullable = false)
|
@Column(name="period", nullable = false)
|
||||||
private String period;
|
private String period;
|
||||||
|
|
||||||
public ScheduleData() {}
|
public ScheduleData() {}
|
||||||
|
|
||||||
public ScheduleData(Long id, Long departmentId, Long semester, Long groupId, Long subjectsId, Long lessonTypeId, Long numberOfHours, Boolean isDivision, Long teacherId, String semesterType, String period) {
|
public ScheduleData(Long id, Long departmentId, Long semester, Long groupId, Long subjectsId, Long lessonTypeId, Long numberOfHours, Boolean isDivision, Long teacherId, SemesterType semesterType, String period) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.departmentId = departmentId;
|
this.departmentId = departmentId;
|
||||||
this.semester = semester;
|
this.semester = semester;
|
||||||
@@ -128,11 +129,11 @@ public class ScheduleData {
|
|||||||
this.teacherId = teacherId;
|
this.teacherId = teacherId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSemesterType() {
|
public SemesterType getSemesterType() {
|
||||||
return semesterType;
|
return semesterType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSemesterType(String semesterType) {
|
public void setSemesterType(SemesterType semesterType) {
|
||||||
this.semesterType = semesterType;
|
this.semesterType = semesterType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package com.magistr.app.model;
|
||||||
|
|
||||||
|
public enum SemesterType {
|
||||||
|
spring,
|
||||||
|
autumn
|
||||||
|
}
|
||||||
@@ -26,6 +26,9 @@ public class StudentGroup {
|
|||||||
@Column(name = "course", nullable = false)
|
@Column(name = "course", nullable = false)
|
||||||
private Integer course;
|
private Integer course;
|
||||||
|
|
||||||
|
@Column(name="specialty_code", nullable = false)
|
||||||
|
private Long specialityCode;
|
||||||
|
|
||||||
public StudentGroup() {
|
public StudentGroup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,4 +79,12 @@ public class StudentGroup {
|
|||||||
public void setCourse(Integer course) {
|
public void setCourse(Integer course) {
|
||||||
this.course = course;
|
this.course = course;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getSpecialityCode() {
|
||||||
|
return specialityCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpecialityCode(Long specialityCode) {
|
||||||
|
this.specialityCode = specialityCode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.magistr.app.repository;
|
||||||
|
|
||||||
|
import com.magistr.app.model.LessonType;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
public interface LessonTypesRepository extends JpaRepository<LessonType, Long> {
|
||||||
|
}
|
||||||
@@ -1,7 +1,12 @@
|
|||||||
package com.magistr.app.repository;
|
package com.magistr.app.repository;
|
||||||
|
|
||||||
import com.magistr.app.model.ScheduleData;
|
import com.magistr.app.model.ScheduleData;
|
||||||
|
import com.magistr.app.model.SemesterType;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface ScheduleDataRepository extends JpaRepository<ScheduleData, Long> {
|
public interface ScheduleDataRepository extends JpaRepository<ScheduleData, Long> {
|
||||||
|
|
||||||
|
List<ScheduleData> findByDepartmentIdAndSemesterTypeAndPeriod(Long departmentId, SemesterType semesterType, String period);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
-- ==========================================
|
||||||
|
-- Редактирование учебных групп
|
||||||
|
-- ==========================================
|
||||||
|
|
||||||
|
ALTER TABLE student_groups
|
||||||
|
ADD COLUMN IF NOT EXISTS specialty_code INT REFERENCES specialties(id);
|
||||||
|
|
||||||
|
UPDATE student_groups
|
||||||
|
SET specialty_code = 1
|
||||||
|
WHERE specialty_code IS NULL;
|
||||||
|
|
||||||
|
ALTER TABLE student_groups
|
||||||
|
ALTER COLUMN specialty_code SET NOT NULL;
|
||||||
|
|
||||||
|
-- ==========================================
|
||||||
|
-- Редактирование данных для расписания
|
||||||
|
-- ==========================================
|
||||||
|
|
||||||
|
INSERT INTO schedule_data (department_id, semester, group_id, subjects_id, lesson_type_id, number_of_hours, is_division, teacher_id, semester_type, period)
|
||||||
|
VALUES (1, 1, 1, 1, 3, 2, true, 1, 'autumn', '2024-2025'),
|
||||||
|
(2, 4, 2, 3, 2, 1, false, 2, 'spring', '2025-2026'),
|
||||||
|
(3, 5, 1, 2, 1, 3, true, 1, 'autumn', '2023-2024'),
|
||||||
|
(2, 4, 2, 3, 2, 1, false, 2, 'spring', '2025-2026'),
|
||||||
|
(2, 4, 2, 3, 2, 1, false, 2, 'spring', '2025-2026'),
|
||||||
|
(2, 4, 2, 3, 2, 1, false, 2, 'spring', '2025-2026'),
|
||||||
|
(1, 1, 1, 1, 1, 2, true, 2, 'autumn', '2024-2025'),
|
||||||
|
(1, 2, 2, 2, 3, 4, false, 2, 'autumn', '2024-2025'),
|
||||||
|
(1, 3, 1, 4, 2, 1, false, 1, 'autumn', '2024-2025'),
|
||||||
|
(1, 4, 2, 5, 1, 7, true, 1, 'autumn', '2024-2025');
|
||||||
@@ -86,8 +86,8 @@ export async function initDepartment() {
|
|||||||
<th>Дисциплина</th>
|
<th>Дисциплина</th>
|
||||||
<th>Вид занятий</th>
|
<th>Вид занятий</th>
|
||||||
<th>Часов в неделю</th>
|
<th>Часов в неделю</th>
|
||||||
<th>Аудитория</th>
|
<th>Деление на подгруппы</th>
|
||||||
<th>Фамилия преподавателя</th>
|
<th>Преподаватель</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -107,14 +107,30 @@ export async function initDepartment() {
|
|||||||
|
|
||||||
return schedule.map(r => `
|
return schedule.map(r => `
|
||||||
<tr>
|
<tr>
|
||||||
<td>${escapeHtml(r.specialty || '-')}</td>
|
<td>${escapeHtml(r.specialityCode || '-')}</td>
|
||||||
<td>${escapeHtml(r.courseSemester || '-')}</td>
|
<td>
|
||||||
|
${(() => {
|
||||||
|
const course = r.groupCourse || '-';
|
||||||
|
const semester = r.semester || '-';
|
||||||
|
if (course === '-' && semester === '-') return '-';
|
||||||
|
return `${course} | ${semester}`;
|
||||||
|
})()}
|
||||||
|
</td>
|
||||||
<td>${escapeHtml(r.groupName || '-')}</td>
|
<td>${escapeHtml(r.groupName || '-')}</td>
|
||||||
<td>${escapeHtml(r.subjectName || '-')}</td>
|
<td>${escapeHtml(r.subjectName || '-')}</td>
|
||||||
<td>${escapeHtml(r.lessonType || '-')}</td>
|
<td>${escapeHtml(r.lessonType || '-')}</td>
|
||||||
<td>${escapeHtml(r.hours || '-')}</td>
|
<td>${escapeHtml(r.numberOfHours || '-')}</td>
|
||||||
<td>${escapeHtml(r.classroom || '-')}</td>
|
<td>
|
||||||
<td>${escapeHtml(r.teacherName || '-')}</td>
|
${r.division === true ? '✓' : (r.division === false ? '' : escapeHtml(''))}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
${(() => {
|
||||||
|
const jobTitle = r.teacherJobTitle || '-';
|
||||||
|
const teacherName = r.teacherName || '-';
|
||||||
|
if (jobTitle === '-' && teacherName === '-') return '-';
|
||||||
|
return `${jobTitle}, ${teacherName}`;
|
||||||
|
})()}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
`).join('');
|
`).join('');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user