Миллион изменений, создание вкладки "Расписание занятий"
This commit is contained in:
@@ -92,7 +92,62 @@ public class DepartmentController {
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/id")
|
||||
@PutMapping("/{id}")
|
||||
public ResponseEntity<?> updateDepartment(@PathVariable Long id, @RequestBody CreateDepartmentRequest request) {
|
||||
logger.info("Получен запрос на обновление кафедры с ID: {}", id);
|
||||
|
||||
Department department = departmentRepository.findById(id).orElse(null);
|
||||
if (department == null) {
|
||||
logger.info("Кафедра с ID - {} не найдена", id);
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
|
||||
try {
|
||||
if (request.getDepartmentName() == null || request.getDepartmentName().isBlank()) {
|
||||
String errorMessage = "Название кафедры обязательно";
|
||||
logger.error("Ошибка валидации: {}", errorMessage);
|
||||
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
||||
}
|
||||
if (request.getDepartmentCode() == null || request.getDepartmentCode() == 0) {
|
||||
String errorMessage = "Код кафедры обязателен";
|
||||
logger.error("Ошибка валидации: {}", errorMessage);
|
||||
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
||||
}
|
||||
|
||||
String departmentName = request.getDepartmentName().trim();
|
||||
if (departmentRepository.findByDepartmentName(departmentName)
|
||||
.filter(existing -> !existing.getId().equals(id))
|
||||
.isPresent()) {
|
||||
String errorMessage = "Кафедра с таким названием уже существует";
|
||||
logger.error("Ошибка валидации: {}", errorMessage);
|
||||
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
||||
}
|
||||
if (departmentRepository.findByDepartmentCode(request.getDepartmentCode())
|
||||
.filter(existing -> !existing.getId().equals(id))
|
||||
.isPresent()) {
|
||||
String errorMessage = "Кафедра с таким кодом уже существует";
|
||||
logger.error("Ошибка валидации: {}", errorMessage);
|
||||
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
||||
}
|
||||
|
||||
department.setDepartmentName(departmentName);
|
||||
department.setDepartmentCode(request.getDepartmentCode());
|
||||
departmentRepository.save(department);
|
||||
|
||||
logger.info("Кафедра с ID - {} успешно обновлена", id);
|
||||
return ResponseEntity.ok(new DepartmentResponse(
|
||||
department.getId(),
|
||||
department.getDepartmentName(),
|
||||
department.getDepartmentCode()
|
||||
));
|
||||
} catch (Exception e) {
|
||||
logger.error("Ошибка при обновлении кафедры с ID - {}: {}", id, e.getMessage(), e);
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body(Map.of("message", "Произошла ошибка при обновлении кафедры " + e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<?> deleteDepartment(@PathVariable Long id) {
|
||||
logger.info("Получен запрос на удаление кафедры с ID: {}", id);
|
||||
if (!departmentRepository.existsById(id)) {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.magistr.app.controller;
|
||||
|
||||
import com.magistr.app.dto.LessonTypeResponse;
|
||||
import com.magistr.app.model.LessonType;
|
||||
import com.magistr.app.repository.LessonTypesRepository;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/lesson-types")
|
||||
public class LessonTypeController {
|
||||
|
||||
private final LessonTypesRepository lessonTypesRepository;
|
||||
|
||||
public LessonTypeController(LessonTypesRepository lessonTypesRepository) {
|
||||
this.lessonTypesRepository = lessonTypesRepository;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public List<LessonTypeResponse> getAllLessonTypes() {
|
||||
return lessonTypesRepository.findAll().stream()
|
||||
.sorted(Comparator.comparing(LessonType::getLessonType))
|
||||
.map(lessonType -> new LessonTypeResponse(lessonType.getId(), lessonType.getLessonType()))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
@@ -1,509 +0,0 @@
|
||||
package com.magistr.app.controller;
|
||||
|
||||
import com.magistr.app.dto.CreateLessonRequest;
|
||||
import com.magistr.app.dto.LessonResponse;
|
||||
import com.magistr.app.model.*;
|
||||
import com.magistr.app.repository.*;
|
||||
import com.magistr.app.utils.DayAndWeekValidator;
|
||||
import com.magistr.app.utils.TypeAndFormatLessonValidator;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/users/lessons")
|
||||
public class LessonsController {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(LessonsController.class);
|
||||
|
||||
private final LessonRepository lessonRepository;
|
||||
private final UserRepository teacherRepository;
|
||||
private final GroupRepository groupRepository;
|
||||
private final SubjectRepository subjectRepository;
|
||||
private final EducationFormRepository educationFormRepository;
|
||||
private final ClassroomRepository classroomRepository;
|
||||
|
||||
public LessonsController(LessonRepository lessonRepository, UserRepository teacherRepository, GroupRepository groupRepository, SubjectRepository subjectRepository, EducationFormRepository educationForm, ClassroomRepository classroomRepository) {
|
||||
this.lessonRepository = lessonRepository;
|
||||
this.teacherRepository = teacherRepository;
|
||||
this.groupRepository = groupRepository;
|
||||
this.subjectRepository = subjectRepository;
|
||||
this.educationFormRepository = educationForm;
|
||||
this.classroomRepository = classroomRepository;
|
||||
}
|
||||
|
||||
//Создание нового занятия
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createLesson(@RequestBody CreateLessonRequest request) {
|
||||
//Полное логирование входящего запроса
|
||||
logger.info("Получен запрос на создание занятия: teacherId={}, groupId={}, subjectId={}, day={}, week={}, time={}",
|
||||
request.getTeacherId(), request.getGroupId(), request.getSubjectId(), request.getDay(), request.getWeek(), request.getTime());
|
||||
|
||||
//Проверка teacherId
|
||||
if (request.getTeacherId() == null || request.getTeacherId() == 0) {
|
||||
String errorMessage = "ID преподавателя обязателен";
|
||||
logger.info("Ошибка валидации: {}", errorMessage);
|
||||
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
||||
}
|
||||
|
||||
//Проверка groupId
|
||||
if (request.getGroupId() == null || request.getGroupId() == 0) {
|
||||
String errorMessage = "ID группы обязателен";
|
||||
logger.info("Ошибка валидации: {}", errorMessage);
|
||||
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
||||
}
|
||||
|
||||
//Проверка subjectId
|
||||
if (request.getSubjectId() == null || request.getSubjectId() == 0) {
|
||||
String errorMessage = "ID предмета обязателен";
|
||||
logger.info("Ошибка валидации: {}", errorMessage);
|
||||
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
||||
}
|
||||
|
||||
//Проверка lessonFormat
|
||||
if (request.getLessonFormat() == null || request.getLessonFormat().isBlank()) {
|
||||
String errorMessage = "Выбор формата занятия обязателен";
|
||||
logger.info("Ошибка валидации: {}", errorMessage);
|
||||
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
||||
} else if(!TypeAndFormatLessonValidator.isValidFormat(request.getLessonFormat())){
|
||||
String errorMessage = "Некорректный формат занятий. " + TypeAndFormatLessonValidator.getValidFormatsMessage();
|
||||
logger.info("Ошибка валидации формата: '{}' - {}", request.getLessonFormat(), errorMessage);
|
||||
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
||||
}
|
||||
|
||||
//Проверка typeLesson
|
||||
if (request.getTypeLesson() == null || request.getTypeLesson().isBlank()) {
|
||||
String errorMessage = "Выбор типа занятия обязателен";
|
||||
logger.info("Ошибка валидации: {}", errorMessage);
|
||||
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
||||
} else if(!TypeAndFormatLessonValidator.isValidType(request.getTypeLesson())){
|
||||
String errorMessage = "Некорректный тип занятия. " + TypeAndFormatLessonValidator.getValidTypesMessage();
|
||||
logger.info("Ошибка валидации типа: '{}' - {}", request.getTypeLesson(), errorMessage);
|
||||
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
||||
}
|
||||
|
||||
//Проверка classroomId
|
||||
if (request.getClassroomId() == null || request.getClassroomId() == 0) {
|
||||
String errorMessage = "ID аудитории обязателен";
|
||||
logger.info("Ошибка валидации: {}", errorMessage);
|
||||
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
||||
}
|
||||
|
||||
//Проверка day
|
||||
if (request.getDay() == null || request.getDay().isBlank()) {
|
||||
String errorMessage = "Выбор дня обязателен";
|
||||
logger.info("Ошибка валидации: {}", errorMessage);
|
||||
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
||||
} else if(!DayAndWeekValidator.isValidDay(request.getDay())){
|
||||
String errorMessage = "Некорректный день недели. " + DayAndWeekValidator.getValidDaysMessage();
|
||||
logger.info("Ошибка валидации дня: '{}' - {}", request.getDay(), errorMessage);
|
||||
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
||||
}
|
||||
|
||||
//Проверка week
|
||||
if (request.getWeek() == null || request.getWeek().isBlank()) {
|
||||
String errorMessage = "Выбор недели обязателен";
|
||||
logger.info("Ошибка валидации: {}", errorMessage);
|
||||
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
||||
} else if(!DayAndWeekValidator.isValidWeek(request.getWeek())){
|
||||
String errorMessage = "Некорректная неделя. " + DayAndWeekValidator.getValidWeekMessage();
|
||||
logger.info("Ошибка валидации недели: '{}' - {}", request.getWeek(), errorMessage);
|
||||
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
||||
}
|
||||
|
||||
//Проверка time
|
||||
if (request.getTime() == null || request.getTime().isBlank()) {
|
||||
String errorMessage = "Время обязательно";
|
||||
logger.info("Ошибка валидации: {}", errorMessage);
|
||||
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
||||
}
|
||||
|
||||
//Сохранение полученных данных и формирование ответа клиенту
|
||||
try {
|
||||
Lesson lesson = new Lesson();
|
||||
lesson.setTeacherId(request.getTeacherId());
|
||||
lesson.setSubjectId(request.getSubjectId());
|
||||
lesson.setGroupId(request.getGroupId());
|
||||
lesson.setLessonFormat(request.getLessonFormat());
|
||||
lesson.setTypeLesson(request.getTypeLesson());
|
||||
lesson.setClassroomId(request.getClassroomId());
|
||||
lesson.setDay(request.getDay());
|
||||
lesson.setWeek(request.getWeek());
|
||||
lesson.setTime(request.getTime());
|
||||
|
||||
Lesson savedLesson = lessonRepository.save(lesson);
|
||||
|
||||
Map<String, Object> response = new LinkedHashMap<>();
|
||||
response.put("id", savedLesson.getId());
|
||||
response.put("teacherId", savedLesson.getTeacherId());
|
||||
response.put("groupId", savedLesson.getGroupId());
|
||||
response.put("subjectId", savedLesson.getSubjectId());
|
||||
response.put("formatLesson", savedLesson.getLessonFormat());
|
||||
response.put("typeLesson", savedLesson.getTypeLesson());
|
||||
response.put("classroomId", savedLesson.getClassroomId());
|
||||
response.put("day", savedLesson.getDay());
|
||||
response.put("week", savedLesson.getWeek());
|
||||
response.put("time", savedLesson.getTime());
|
||||
|
||||
logger.info("Занятие успешно создано с ID: {}", savedLesson.getId());
|
||||
|
||||
return ResponseEntity.ok(response);
|
||||
} catch (Exception e) {
|
||||
logger.error("Ошибка при сохранении занятия: {}", e.getMessage(),e);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body(Map.of("message", "Произошла ошибка при создании занятия: " + e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
//Запрос для получения всего списка занятий
|
||||
@Deprecated
|
||||
@GetMapping
|
||||
public List<LessonResponse> getAllLessons() {
|
||||
logger.info("Запрос на получение всех занятий");
|
||||
|
||||
try {
|
||||
List<Lesson> lessons = lessonRepository.findAll();
|
||||
|
||||
List<LessonResponse> response = lessons.stream()
|
||||
.map(lesson -> {
|
||||
String teacherName = teacherRepository.findById(lesson.getTeacherId())
|
||||
.map(User::getUsername)
|
||||
.orElse("Неизвестно");
|
||||
|
||||
StudentGroup group = groupRepository.findById(lesson.getGroupId()).orElse(null);
|
||||
String groupName = groupRepository.findById(lesson.getGroupId())
|
||||
.map(StudentGroup::getName)
|
||||
.orElse("Неизвестно");
|
||||
|
||||
String educationFormName = "Неизвестно";
|
||||
if(group != null && group.getEducationForm() != null) {
|
||||
Long educationFormId = group.getEducationForm().getId();
|
||||
educationFormName = educationFormRepository.findById(educationFormId)
|
||||
.map(EducationForm::getName)
|
||||
.orElse("Неизвестно");
|
||||
}
|
||||
|
||||
String subjectName = subjectRepository.findById(lesson.getSubjectId())
|
||||
.map(Subject::getName)
|
||||
.orElse("Неизвестно");
|
||||
|
||||
String classroomName = classroomRepository.findById(lesson.getClassroomId())
|
||||
.map(Classroom::getName)
|
||||
.orElse("Неизвестно");
|
||||
|
||||
return new LessonResponse(
|
||||
lesson.getId(),
|
||||
teacherName,
|
||||
groupName,
|
||||
classroomName,
|
||||
educationFormName,
|
||||
subjectName,
|
||||
lesson.getTypeLesson(),
|
||||
lesson.getLessonFormat(),
|
||||
lesson.getDay(),
|
||||
lesson.getWeek(),
|
||||
lesson.getTime()
|
||||
);
|
||||
})
|
||||
.toList();
|
||||
|
||||
logger.info("Получено {} занятий", lessons.size());
|
||||
return response;
|
||||
} catch (Exception e) {
|
||||
logger.error("Ошибка при получении списка всех занятий: {}", e.getMessage(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
//Запрос на получение всех занятий для конкретного преподавателя
|
||||
@Deprecated
|
||||
@GetMapping("/{teacherId}")
|
||||
public ResponseEntity<?> getLessonsById(@PathVariable Long teacherId) {
|
||||
logger.info("Запрос на получение занятий для преподавателя с ID: {}", teacherId);
|
||||
try {
|
||||
List<Lesson> lessons = lessonRepository.findByTeacherId(teacherId);
|
||||
|
||||
if(lessons.isEmpty()) {
|
||||
logger.info("У преподавателя с ID {} нет занятий", teacherId);
|
||||
return ResponseEntity.ok(Map.of(
|
||||
"message", "У преподавателя с ID " + teacherId +" нет занятий.",
|
||||
"lessons", Collections.emptyList()
|
||||
));
|
||||
}
|
||||
|
||||
List<LessonResponse> lessonResponses = lessons.stream()
|
||||
.map(lesson -> {
|
||||
String teacherName = teacherRepository.findById(lesson.getTeacherId())
|
||||
.map(User::getUsername)
|
||||
.orElse("Неизвестно");
|
||||
|
||||
StudentGroup group = groupRepository.findById(lesson.getGroupId()).orElse(null);
|
||||
String groupName = groupRepository.findById(lesson.getGroupId())
|
||||
.map(StudentGroup::getName)
|
||||
.orElse("Неизвестно");
|
||||
|
||||
String educationFormName = "Неизвестно";
|
||||
if(group != null && group.getEducationForm() != null) {
|
||||
Long educationFormId = group.getEducationForm().getId();
|
||||
educationFormName = educationFormRepository.findById(educationFormId)
|
||||
.map(EducationForm::getName)
|
||||
.orElse("Неизвестно");
|
||||
}
|
||||
|
||||
String subjectName = subjectRepository.findById(lesson.getSubjectId())
|
||||
.map(Subject::getName)
|
||||
.orElse("Неизвестно");
|
||||
|
||||
String classroomName = classroomRepository.findById(lesson.getClassroomId())
|
||||
.map(Classroom::getName)
|
||||
.orElse("Неизвестно");
|
||||
|
||||
return new LessonResponse(
|
||||
lesson.getId(),
|
||||
teacherName,
|
||||
groupName,
|
||||
classroomName,
|
||||
educationFormName,
|
||||
subjectName,
|
||||
lesson.getTypeLesson(),
|
||||
lesson.getLessonFormat(),
|
||||
lesson.getDay(),
|
||||
lesson.getWeek(),
|
||||
lesson.getTime()
|
||||
);
|
||||
})
|
||||
.toList();
|
||||
|
||||
logger.info("Найдено {} занятий для преподавателя с ID: {}", lessonResponses.size(), teacherId);
|
||||
return ResponseEntity.ok(lessonResponses);
|
||||
} catch (Exception e ){
|
||||
logger.error("Ошибка при получении занятий для преподавателя с ID {}: {}", teacherId, e.getMessage(), e);
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body(Map.of("message", "Ошибка при поиске занятий: " + e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
//Тестовый запрос на проверку доступности контроллера
|
||||
@GetMapping("/ping")
|
||||
public String ping() {
|
||||
logger.debug("Получен ping запрос");
|
||||
String response = "pong";
|
||||
logger.debug("Ответ на ping: {}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
//Удаление занятия по его ID
|
||||
@DeleteMapping("/delete/{lessonId}")
|
||||
public ResponseEntity<?> deleteLessonById(@PathVariable Long lessonId){
|
||||
logger.info("Запрос на удаление занятия по ID: {}", lessonId);
|
||||
if(!lessonRepository.existsById(lessonId)) {
|
||||
return ResponseEntity.badRequest().body(Map.of("message", "Занятие не найдено"));
|
||||
}
|
||||
lessonRepository.deleteById(lessonId);
|
||||
logger.info("Занятие с ID - {} успешно удалено", lessonId);
|
||||
return ResponseEntity.ok(Map.of("message", "Занятие успешно удалено"));
|
||||
|
||||
}
|
||||
|
||||
//Обновление занятия по его ID
|
||||
@PutMapping("/update/{lessonId}")
|
||||
public ResponseEntity<?> updateLessonById(@PathVariable Long lessonId, @RequestBody CreateLessonRequest request) {
|
||||
logger.info("Получен запрос на обновление занятия с ID - {}", lessonId);
|
||||
logger.info("Данные для обновления: teacherId={}, groupId={}, subjectId={}, lessonFormat={}, typeLesson={}, classroomId={}, day={}, week={}, time={}",
|
||||
request.getTeacherId(), request.getGroupId(), request.getSubjectId(), request.getLessonFormat(), request.getTypeLesson(), request.getClassroomId(),
|
||||
request.getDay(), request.getWeek(), request.getTime());
|
||||
|
||||
try {
|
||||
//Проверка на наличие записи
|
||||
Lesson existingLesson = lessonRepository.findById(lessonId).orElse(null);
|
||||
|
||||
if(existingLesson == null) {
|
||||
String errorMessage = "Занятие с ID " + lessonId + " не найдено";
|
||||
logger.info("Ошибка: {}", errorMessage);
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(Map.of("message", errorMessage));
|
||||
}
|
||||
|
||||
boolean hasChanges = false;
|
||||
Map<String, Object> changes = new LinkedHashMap<>();
|
||||
|
||||
//Проверка и обновление teacherId, если он передан и отличается
|
||||
if(request.getTeacherId() != null) {
|
||||
if(!request.getTeacherId().equals(existingLesson.getTeacherId())) {
|
||||
if(request.getTeacherId() == 0) {
|
||||
return ResponseEntity.badRequest()
|
||||
.body(Map.of("message", "ID преподавателя не может быть равен 0"));
|
||||
}
|
||||
existingLesson.setTeacherId(request.getTeacherId());
|
||||
changes.put("teacherId", request.getTeacherId());
|
||||
hasChanges = true;
|
||||
}
|
||||
}
|
||||
|
||||
//Проверка и обновление groupId, если он передан и отличается
|
||||
if(request.getGroupId() != null) {
|
||||
if(!request.getGroupId().equals(existingLesson.getGroupId())) {
|
||||
if(request.getGroupId() == 0) {
|
||||
return ResponseEntity.badRequest()
|
||||
.body(Map.of("message", "ID группы не может быть равен 0"));
|
||||
}
|
||||
existingLesson.setGroupId(request.getGroupId());
|
||||
changes.put("groupId", request.getGroupId());
|
||||
hasChanges = true;
|
||||
}
|
||||
}
|
||||
|
||||
//Проверка и обновление subjectId, если он передан и отличается
|
||||
if(request.getSubjectId() != null) {
|
||||
if(!request.getSubjectId().equals(existingLesson.getSubjectId())) {
|
||||
if(request.getSubjectId() == 0) {
|
||||
return ResponseEntity.badRequest()
|
||||
.body(Map.of("message", "ID дисциплины не может быть равен 0"));
|
||||
}
|
||||
existingLesson.setSubjectId(request.getSubjectId());
|
||||
changes.put("subjectId", request.getSubjectId());
|
||||
hasChanges = true;
|
||||
}
|
||||
}
|
||||
|
||||
//Проверка и обновление lessonFormat, если он передан и отличается
|
||||
if(request.getLessonFormat() != null) {
|
||||
if(!request.getLessonFormat().equals(existingLesson.getLessonFormat())) {
|
||||
if(request.getLessonFormat().isBlank()) {
|
||||
return ResponseEntity.badRequest()
|
||||
.body(Map.of("message", "Формат занятия не может быть пустым"));
|
||||
}
|
||||
if(!TypeAndFormatLessonValidator.isValidFormat(request.getLessonFormat())) {
|
||||
String errorMessage = "Некорректный формат занятий. " + TypeAndFormatLessonValidator.getValidFormatsMessage();
|
||||
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
||||
}
|
||||
existingLesson.setLessonFormat(request.getLessonFormat());
|
||||
changes.put("lessonFormat", request.getLessonFormat());
|
||||
hasChanges = true;
|
||||
}
|
||||
}
|
||||
|
||||
//Проверка и обновление typeLesson, если он передан и отличается
|
||||
if(request.getTypeLesson() != null) {
|
||||
if(!request.getTypeLesson().equals(existingLesson.getTypeLesson())) {
|
||||
if(request.getTypeLesson().isBlank()) {
|
||||
return ResponseEntity.badRequest()
|
||||
.body(Map.of("message", "Тип занятия не может быть пустым"));
|
||||
}
|
||||
if(!TypeAndFormatLessonValidator.isValidType(request.getTypeLesson())) {
|
||||
String errorMessage = "Некорректный тип занятий. " + TypeAndFormatLessonValidator.getValidTypesMessage();
|
||||
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
||||
}
|
||||
existingLesson.setLessonFormat(request.getTypeLesson());
|
||||
changes.put("typeLesson", request.getTypeLesson());
|
||||
hasChanges = true;
|
||||
}
|
||||
}
|
||||
|
||||
//Проверка и обновление classroomId, если он передан и отличается
|
||||
if(request.getClassroomId() != null) {
|
||||
if(!request.getClassroomId().equals(existingLesson.getClassroomId())) {
|
||||
if(request.getClassroomId() == 0) {
|
||||
return ResponseEntity.badRequest()
|
||||
.body(Map.of("message", "ID аудитории не можеть быть равен 0"));
|
||||
}
|
||||
existingLesson.setClassroomId(request.getClassroomId());
|
||||
changes.put("classroomId", request.getClassroomId());
|
||||
hasChanges = true;
|
||||
}
|
||||
}
|
||||
|
||||
//Проверка и обновление day, если он передан и отличается
|
||||
if(request.getDay() != null){
|
||||
if(!request.getDay().equals(existingLesson.getDay())) {
|
||||
if(request.getDay().isBlank()) {
|
||||
return ResponseEntity.badRequest()
|
||||
.body(Map.of("message", "Поле \"День\" не может быть пустым"));
|
||||
}
|
||||
if(!DayAndWeekValidator.isValidDay(request.getDay())) {
|
||||
String errorMessage = "Некорректный день. " + DayAndWeekValidator.getValidDaysMessage();
|
||||
return ResponseEntity.badRequest()
|
||||
.body(Map.of("message", errorMessage));
|
||||
}
|
||||
existingLesson.setDay(request.getDay());
|
||||
changes.put("day", request.getDay());
|
||||
hasChanges = true;
|
||||
}
|
||||
}
|
||||
|
||||
//Проверка и обновление week, если он передан и отличается
|
||||
if(request.getWeek() != null) {
|
||||
if(!request.getWeek().equals(existingLesson.getWeek())) {
|
||||
if (request.getWeek().isBlank()) {
|
||||
return ResponseEntity.badRequest()
|
||||
.body(Map.of("message", "Поле \"Неделя\" не может быть пустым"));
|
||||
}
|
||||
if (!DayAndWeekValidator.isValidWeek(request.getWeek())) {
|
||||
String errorMessage = "Некорректная неделя. " + DayAndWeekValidator.getValidWeekMessage();
|
||||
return ResponseEntity.badRequest()
|
||||
.body((Map.of("message", errorMessage)));
|
||||
}
|
||||
existingLesson.setWeek(request.getWeek());
|
||||
changes.put("week", request.getWeek());
|
||||
hasChanges = true;
|
||||
}
|
||||
}
|
||||
|
||||
//Проверка и обновление time, если он передан и отличается
|
||||
if(request.getTime() != null) {
|
||||
if(!request.getTime().equals(existingLesson.getTime())) {
|
||||
if(request.getTime().isBlank()){
|
||||
return ResponseEntity.badRequest()
|
||||
.body(Map.of("message", "Поле \"Время\" не может быть пустым"));
|
||||
}
|
||||
existingLesson.setTime(request.getTime());
|
||||
changes.put("time", request.getTime());
|
||||
hasChanges = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!hasChanges) {
|
||||
logger.info("Обновление не требуется - все полня идентичны существующим для занятия с ID: {}", lessonId);
|
||||
|
||||
Map<String, Object> response = buildResponse(existingLesson);
|
||||
response.put("message", "Изменений не обнаружено");
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
|
||||
Lesson updatedLesson = lessonRepository.save(existingLesson);
|
||||
|
||||
Map<String, Object> response = buildResponse(updatedLesson);
|
||||
response.put("updatedFields", changes);
|
||||
response.put("message", "Занятие успешно обновлено");
|
||||
|
||||
logger.info("Занятие с ID - {} успешно обновлено. Изменения: {}", lessonId, changes);
|
||||
|
||||
return ResponseEntity.ok(response);
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Ошибка при обновлении занятия с ID {}: {}", lessonId, e.getMessage(),e);
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body(Map.of("message", "Произошла ошибка при обновлении занятия: " + e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, Object> buildResponse(Lesson lesson) {
|
||||
Map<String, Object> response = new LinkedHashMap<>();
|
||||
response.put("id", lesson.getId());
|
||||
response.put("teacherId", lesson.getTeacherId());
|
||||
response.put("groupId", lesson.getGroupId());
|
||||
response.put("subjectId", lesson.getSubjectId());
|
||||
response.put("LessonFormat", lesson.getLessonFormat());
|
||||
response.put("typeLesson", lesson.getTypeLesson());
|
||||
response.put("classroomId", lesson.getClassroomId());
|
||||
response.put("day", lesson.getDay());
|
||||
response.put("week", lesson.getWeek());
|
||||
response.put("time", lesson.getTime());
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -1,283 +0,0 @@
|
||||
package com.magistr.app.controller;
|
||||
|
||||
import com.magistr.app.dto.CreateScheduleDataRequest;
|
||||
import com.magistr.app.dto.ScheduleResponse;
|
||||
import com.magistr.app.model.*;
|
||||
import com.magistr.app.repository.*;
|
||||
import com.magistr.app.utils.CourseAndSemesterCalculator;
|
||||
import com.magistr.app.utils.SemesterTypeValidator;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/department/schedule")
|
||||
public class ScheduleDataController {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ScheduleDataController.class);
|
||||
|
||||
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, GroupRepository groupRepository, SpecialtiesRepository specialtiesRepository, SubjectRepository subjectRepository, LessonTypesRepository lessonTypesRepository, UserRepository userRepository) {
|
||||
this.scheduleDataRepository = scheduleDataRepository;
|
||||
this.groupRepository = groupRepository;
|
||||
this.specialtiesRepository = specialtiesRepository;
|
||||
this.subjectRepository = subjectRepository;
|
||||
this.lessonTypesRepository = lessonTypesRepository;
|
||||
this.userRepository = userRepository;
|
||||
}
|
||||
|
||||
@GetMapping("/allList")
|
||||
public List<ScheduleData> getAllScheduleDataList() {
|
||||
logger.info("Получен запрос на получение списка данных расписаний");
|
||||
try {
|
||||
List<ScheduleData> scheduleData = scheduleDataRepository.findAll();
|
||||
List<ScheduleData> response = scheduleData.stream()
|
||||
.map(s -> new ScheduleData(
|
||||
s.getId(),
|
||||
s.getDepartmentId(),
|
||||
s.getGroupId(),
|
||||
s.getSubjectsId(),
|
||||
s.getLessonTypeId(),
|
||||
s.getNumberOfHours(),
|
||||
s.getDivision(),
|
||||
s.getTeacherId(),
|
||||
s.getSemesterType(),
|
||||
s.getPeriod()
|
||||
))
|
||||
.toList();
|
||||
logger.info("Получено {} записей", response.size());
|
||||
return response;
|
||||
} catch (Exception e) {
|
||||
logger.error("Ошибка при получении списка данных расписаний: {}", e.getMessage(), 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("Неизвестно");
|
||||
|
||||
int groupSemester = 0;
|
||||
int groupCourse = 0;
|
||||
String specialityCode = "Неизвестно";
|
||||
|
||||
StudentGroup group = groupRepository.findById(s.getGroupId()).orElse(null);
|
||||
|
||||
if (group != null) {
|
||||
groupCourse = CourseAndSemesterCalculator.getFutureCourse(group.getYearStartStudy(), period);
|
||||
}
|
||||
|
||||
if (group != null) {
|
||||
groupSemester = CourseAndSemesterCalculator.getFutureSemester(group.getYearStartStudy(), period, semesterType);
|
||||
}
|
||||
|
||||
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,
|
||||
groupName,
|
||||
groupCourse,
|
||||
groupSemester,
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
// Доделать проверки получаемых полей!!!
|
||||
@PostMapping("/create")
|
||||
public ResponseEntity<?> createScheduleData(@RequestBody CreateScheduleDataRequest request) {
|
||||
logger.info("Получен запрос на создание записи данных для расписаний: departmentId={}, groupId={}, subjectsId={}, lessonTypeId={}, numberOfHours={}, division={}, teacherId={}, semesterType={}, period={}",
|
||||
request.getDepartmentId(), request.getGroupId(), request.getSubjectsId(), request.getLessonTypeId(), request.getNumberOfHours(), request.getDivision(), request.getTeacherId(), request.getSemesterType(), request.getPeriod());
|
||||
try {
|
||||
if (request.getDepartmentId() == null || request.getDepartmentId() == 0) {
|
||||
String errorMessage = "ID кафедры обязателен";
|
||||
logger.info("Ошибка валидации: {}", errorMessage);
|
||||
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
||||
} else if(!scheduleDataRepository.existsById(request.getDepartmentId())) {
|
||||
String errorMessage = "Кафедра не найдена";
|
||||
logger.info("Кафедра не найдена");
|
||||
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
||||
}
|
||||
|
||||
if (request.getGroupId() == null || request.getGroupId() == 0) {
|
||||
String errorMessage = "ID группы обязателен";
|
||||
logger.info("Ошибка валидации: {}", errorMessage);
|
||||
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
||||
}
|
||||
|
||||
if (request.getSubjectsId() == null || request.getSubjectsId() == 0) {
|
||||
String errorMessage = "ID дисциплины обязателен";
|
||||
logger.info("Ошибка валидации: {}", errorMessage);
|
||||
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
||||
}
|
||||
|
||||
if (request.getLessonTypeId() == null || request.getLessonTypeId() == 0) {
|
||||
String errorMessage = "ID типа занятия обязателен";
|
||||
logger.info("Ошибка валидации: {}", errorMessage);
|
||||
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
||||
}
|
||||
|
||||
if (request.getNumberOfHours() == null) {
|
||||
request.setNumberOfHours(0L);
|
||||
}
|
||||
|
||||
if (request.getTeacherId() == null || request.getTeacherId() == 0) {
|
||||
String errorMessage = "ID преподавателя обязателен";
|
||||
logger.info("Ошибка валидации: {}", errorMessage);
|
||||
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
||||
}
|
||||
|
||||
if (request.getSemesterType() == null) {
|
||||
String errorMessage = "Семестр обязателен";
|
||||
logger.info("Ошибка валидации: {}", errorMessage);
|
||||
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
||||
} else if (!SemesterTypeValidator.isValidTypeSemester(request.getSemesterType().toString())) {
|
||||
String errorMessage = "Некорректный формат семестра. Допустимые форматы: " + SemesterTypeValidator.getValidTypes();
|
||||
logger.info("Ошибка валидации: {}", errorMessage);
|
||||
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
||||
}
|
||||
|
||||
if (request.getPeriod() == null || request.getPeriod().isBlank()) {
|
||||
String errorMessage = "Период обязателен";
|
||||
logger.info("Ошибка валидации: {}", errorMessage);
|
||||
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
||||
}
|
||||
|
||||
boolean existsRecord = scheduleDataRepository.existsByDepartmentIdAndGroupIdAndSubjectsIdAndLessonTypeIdAndNumberOfHoursAndDivisionAndTeacherIdAndSemesterTypeAndPeriod(
|
||||
request.getDepartmentId(),
|
||||
request.getGroupId(),
|
||||
request.getSubjectsId(),
|
||||
request.getLessonTypeId(),
|
||||
request.getNumberOfHours(),
|
||||
request.getDivision(),
|
||||
request.getTeacherId(),
|
||||
request.getSemesterType(),
|
||||
request.getPeriod()
|
||||
);
|
||||
|
||||
if(existsRecord) {
|
||||
return ResponseEntity.status(HttpStatus.CONFLICT)
|
||||
.body(Map.of("message", "Такая запись уже существует"));
|
||||
}
|
||||
|
||||
ScheduleData scheduleData = new ScheduleData();
|
||||
scheduleData.setDepartmentId(request.getDepartmentId());
|
||||
scheduleData.setGroupId(request.getGroupId());
|
||||
scheduleData.setSubjectsId(request.getSubjectsId());
|
||||
scheduleData.setLessonTypeId(request.getLessonTypeId());
|
||||
scheduleData.setNumberOfHours(request.getNumberOfHours());
|
||||
scheduleData.setDivision(request.getDivision());
|
||||
scheduleData.setTeacherId(request.getTeacherId());
|
||||
scheduleData.setSemesterType(request.getSemesterType());
|
||||
scheduleData.setPeriod(request.getPeriod());
|
||||
|
||||
ScheduleData savedSchedule = scheduleDataRepository.save(scheduleData);
|
||||
|
||||
Map<String, Object> response = new LinkedHashMap<>();
|
||||
response.put("id", savedSchedule.getId());
|
||||
response.put("departmentId", savedSchedule.getDepartmentId());
|
||||
response.put("groupId", savedSchedule.getGroupId());
|
||||
response.put("subjectId", savedSchedule.getSubjectsId());
|
||||
response.put("lessonTypeId", savedSchedule.getLessonTypeId());
|
||||
response.put("numberOfHours", savedSchedule.getNumberOfHours());
|
||||
response.put("isDivision", savedSchedule.getDivision());
|
||||
response.put("teacherId", savedSchedule.getTeacherId());
|
||||
response.put("semesterType", savedSchedule.getSemesterType());
|
||||
response.put("period", savedSchedule.getPeriod());
|
||||
|
||||
logger.info("Запись успешно создана с ID: {}", savedSchedule.getId());
|
||||
|
||||
return ResponseEntity.ok(response);
|
||||
} catch (org.springframework.dao.DataIntegrityViolationException e) {
|
||||
return ResponseEntity.status(HttpStatus.CONFLICT)
|
||||
.body(Map.of("message", "Такая запись уже существует"));
|
||||
} catch (Exception e) {
|
||||
logger.error("Ошибка при создании записи: {}", e.getMessage(), e);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body(Map.of("message", "Произошла ошибка при создании записи: " + e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<?> deleteById(@PathVariable Long id) {
|
||||
logger.info("Получен запрос на удаление записи с ID: {}", id);
|
||||
if(!scheduleDataRepository.existsById(id)) {
|
||||
logger.info("Запись с ID - {} не найдена", id);
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
scheduleDataRepository.deleteById(id);
|
||||
logger.info("Запись с ID - {} успешно удалена", id);
|
||||
return ResponseEntity.ok(Map.of("message", "Запись удалена"));
|
||||
}
|
||||
}
|
||||
@@ -92,7 +92,63 @@ public class SpecialityController {
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/id")
|
||||
@PutMapping("/{id}")
|
||||
public ResponseEntity<?> updateSpeciality(@PathVariable Long id, @RequestBody CreateSpecialityRequest request) {
|
||||
logger.info("Получен запрос на обновление специальности с ID: {}", id);
|
||||
|
||||
Speciality speciality = specialtiesRepository.findById(id).orElse(null);
|
||||
if (speciality == null) {
|
||||
logger.info("Специальность с ID - {} не найдена", id);
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
|
||||
try {
|
||||
if (request.getSpecialityName() == null || request.getSpecialityName().isBlank()) {
|
||||
String errorMessage = "Название специальности обязательно";
|
||||
logger.error("Ошибка валидации: {}", errorMessage);
|
||||
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
||||
}
|
||||
if (request.getSpecialityCode() == null || request.getSpecialityCode().isBlank()) {
|
||||
String errorMessage = "Код специальности обязателен";
|
||||
logger.error("Ошибка валидации: {}", errorMessage);
|
||||
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
||||
}
|
||||
|
||||
String specialityName = request.getSpecialityName().trim();
|
||||
String specialityCode = request.getSpecialityCode().trim();
|
||||
if (specialtiesRepository.findBySpecialityName(specialityName)
|
||||
.filter(existing -> !existing.getId().equals(id))
|
||||
.isPresent()) {
|
||||
String errorMessage = "Специальность с таким названием уже существует";
|
||||
logger.error("Ошибка валидации: {}", errorMessage);
|
||||
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
||||
}
|
||||
if (specialtiesRepository.findBySpecialityCode(specialityCode)
|
||||
.filter(existing -> !existing.getId().equals(id))
|
||||
.isPresent()) {
|
||||
String errorMessage = "Специальность с таким кодом уже существует";
|
||||
logger.error("Ошибка валидации: {}", errorMessage);
|
||||
return ResponseEntity.badRequest().body(Map.of("message", errorMessage));
|
||||
}
|
||||
|
||||
speciality.setSpecialityName(specialityName);
|
||||
speciality.setSpecialityCode(specialityCode);
|
||||
specialtiesRepository.save(speciality);
|
||||
|
||||
logger.info("Специальность с ID - {} успешно обновлена", id);
|
||||
return ResponseEntity.ok(new SpecialityResponse(
|
||||
speciality.getId(),
|
||||
speciality.getSpecialityName(),
|
||||
speciality.getSpecialityCode()
|
||||
));
|
||||
} catch (Exception e) {
|
||||
logger.error("Ошибка при обновлении специальности с ID - {}: {}", id, e.getMessage(), e);
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body(Map.of("message", "Произошла ошибка при обновлении специальности " + e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<?> deleteSpeciality(@PathVariable Long id) {
|
||||
logger.info("Получен запрос на удаление специальности с ID: {}", id);
|
||||
if (!specialtiesRepository.existsById(id)) {
|
||||
@@ -101,6 +157,6 @@ public class SpecialityController {
|
||||
}
|
||||
specialtiesRepository.deleteById(id);
|
||||
logger.info("Специальность с ID - {} успешно удалена", id);
|
||||
return ResponseEntity.ok(Map.of("message", "Специальнсть удалена"));
|
||||
return ResponseEntity.ok(Map.of("message", "Специальность удалена"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
package com.magistr.app.dto;
|
||||
|
||||
public class CreateLessonRequest {
|
||||
|
||||
private Long teacherId;
|
||||
private Long groupId;
|
||||
private Long subjectId;
|
||||
private String lessonFormat;
|
||||
private String typeLesson;
|
||||
private Long classroomId;
|
||||
private String day;
|
||||
private String week;
|
||||
private String time;
|
||||
|
||||
public CreateLessonRequest() {
|
||||
}
|
||||
|
||||
public Long getTeacherId() {
|
||||
return teacherId;
|
||||
}
|
||||
|
||||
public void setTeacherId(Long teacherId) {
|
||||
this.teacherId = teacherId;
|
||||
}
|
||||
|
||||
public Long getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(Long groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
public Long getSubjectId() {
|
||||
return subjectId;
|
||||
}
|
||||
|
||||
public void setSubjectId(Long subjectId) {
|
||||
this.subjectId = subjectId;
|
||||
}
|
||||
|
||||
public String getLessonFormat() {
|
||||
return lessonFormat;
|
||||
}
|
||||
|
||||
public void setLessonFormat(String lessonFormat) {
|
||||
this.lessonFormat = lessonFormat;
|
||||
}
|
||||
|
||||
public String getTypeLesson() {
|
||||
return typeLesson;
|
||||
}
|
||||
|
||||
public void setTypeLesson(String typeLesson) {
|
||||
this.typeLesson = typeLesson;
|
||||
}
|
||||
|
||||
public Long getClassroomId() {
|
||||
return classroomId;
|
||||
}
|
||||
|
||||
public void setClassroomId(Long classroomId) {
|
||||
this.classroomId = classroomId;
|
||||
}
|
||||
|
||||
public String getDay() {
|
||||
return day;
|
||||
}
|
||||
|
||||
public void setDay(String day) {
|
||||
this.day = day;
|
||||
}
|
||||
|
||||
public String getWeek() {
|
||||
return week;
|
||||
}
|
||||
|
||||
public void setWeek(String week) {
|
||||
this.week = week;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
package com.magistr.app.dto;
|
||||
|
||||
import com.magistr.app.model.SemesterType;
|
||||
|
||||
public class CreateScheduleDataRequest {
|
||||
private Long id;
|
||||
private Long departmentId;
|
||||
private Long groupId;
|
||||
private Long subjectsId;
|
||||
private Long lessonTypeId;
|
||||
private Long numberOfHours;
|
||||
private Boolean division;
|
||||
private Long teacherId;
|
||||
private SemesterType semesterType;
|
||||
private String period;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getDepartmentId() {
|
||||
return departmentId;
|
||||
}
|
||||
|
||||
public void setDepartmentId(Long departmentId) {
|
||||
this.departmentId = departmentId;
|
||||
}
|
||||
|
||||
public Long getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(Long groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
public Long getSubjectsId() {
|
||||
return subjectsId;
|
||||
}
|
||||
|
||||
public void setSubjectsId(Long subjectsId) {
|
||||
this.subjectsId = subjectsId;
|
||||
}
|
||||
|
||||
public Long getLessonTypeId() {
|
||||
return lessonTypeId;
|
||||
}
|
||||
|
||||
public void setLessonTypeId(Long lessonTypeId) {
|
||||
this.lessonTypeId = lessonTypeId;
|
||||
}
|
||||
|
||||
public Long getNumberOfHours() {
|
||||
return numberOfHours;
|
||||
}
|
||||
|
||||
public void setNumberOfHours(Long numberOfHours) {
|
||||
this.numberOfHours = numberOfHours;
|
||||
}
|
||||
|
||||
public Boolean getDivision() {
|
||||
return division;
|
||||
}
|
||||
|
||||
public void setDivision(Boolean division) {
|
||||
this.division = division;
|
||||
}
|
||||
|
||||
public Long getTeacherId() {
|
||||
return teacherId;
|
||||
}
|
||||
|
||||
public void setTeacherId(Long teacherId) {
|
||||
this.teacherId = teacherId;
|
||||
}
|
||||
|
||||
public SemesterType getSemesterType() {
|
||||
return semesterType;
|
||||
}
|
||||
|
||||
public void setSemesterType(SemesterType semesterType) {
|
||||
this.semesterType = semesterType;
|
||||
}
|
||||
|
||||
public String getPeriod() {
|
||||
return period;
|
||||
}
|
||||
|
||||
public void setPeriod(String period) {
|
||||
this.period = period;
|
||||
}
|
||||
}
|
||||
@@ -1,171 +0,0 @@
|
||||
package com.magistr.app.dto;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class LessonResponse {
|
||||
|
||||
private Long id;
|
||||
private Long teacherId;
|
||||
private String teacherName;
|
||||
private Long groupId;
|
||||
private String groupName;
|
||||
private String educationFormName;
|
||||
private Long subjectId;
|
||||
private String subjectName;
|
||||
private String lessonFormat;
|
||||
private String typeLesson;
|
||||
private Long classroomId;
|
||||
private String classroomName;
|
||||
private String day;
|
||||
private String week;
|
||||
private String time;
|
||||
|
||||
public LessonResponse() {
|
||||
}
|
||||
|
||||
public LessonResponse(Long id, Long teacherId, Long groupId, Long subjectId, String day, String week, String time) {
|
||||
this.id = id;
|
||||
this.teacherId = teacherId;
|
||||
this.groupId = groupId;
|
||||
this.subjectId = subjectId;
|
||||
this.day = day;
|
||||
this.week = week;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public LessonResponse(Long id, String teacherName, String groupName, String classroomName, String educationFormName, String subjectName, String typeLesson, String lessonFormat, String day, String week, String time) {
|
||||
this.id = id;
|
||||
this.teacherName = teacherName;
|
||||
this.groupName = groupName;
|
||||
this.classroomName = classroomName;
|
||||
this.educationFormName = educationFormName;
|
||||
this.subjectName = subjectName;
|
||||
this.typeLesson = typeLesson;
|
||||
this.lessonFormat = lessonFormat;
|
||||
this.day = day;
|
||||
this.week = week;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getTeacherId() {
|
||||
return teacherId;
|
||||
}
|
||||
|
||||
public void setTeacherId(Long teacherId) {
|
||||
this.teacherId = teacherId;
|
||||
}
|
||||
|
||||
public String getTeacherName() {
|
||||
return teacherName;
|
||||
}
|
||||
|
||||
public void setTeacherName(String teacherName) {
|
||||
this.teacherName = teacherName;
|
||||
}
|
||||
|
||||
public Long getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(Long groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
public String getGroupName() {
|
||||
return groupName;
|
||||
}
|
||||
|
||||
public void setGroupName(String groupName) {
|
||||
this.groupName = groupName;
|
||||
}
|
||||
|
||||
public String getTypeLesson() {
|
||||
return typeLesson;
|
||||
}
|
||||
|
||||
public void setTypeLesson(String typeLesson) {
|
||||
this.typeLesson = typeLesson;
|
||||
}
|
||||
|
||||
public String getLessonFormat() {
|
||||
return lessonFormat;
|
||||
}
|
||||
|
||||
public void setLessonFormat(String lessonFormat) {
|
||||
this.lessonFormat = lessonFormat;
|
||||
}
|
||||
|
||||
public Long getClassroomId() {
|
||||
return classroomId;
|
||||
}
|
||||
|
||||
public void setClassroomId(Long classroomId) {
|
||||
this.classroomId = classroomId;
|
||||
}
|
||||
|
||||
public String getClassroomName() {
|
||||
return classroomName;
|
||||
}
|
||||
|
||||
public void setClassroomName(String classroomName) {
|
||||
this.classroomName = classroomName;
|
||||
}
|
||||
|
||||
public String getEducationFormName() {
|
||||
return educationFormName;
|
||||
}
|
||||
|
||||
public void setEducationFormName(String educationFormName) {
|
||||
this.educationFormName = educationFormName;
|
||||
}
|
||||
|
||||
public Long getSubjectId() {
|
||||
return subjectId;
|
||||
}
|
||||
|
||||
public void setSubjectId(Long subjectId) {
|
||||
this.subjectId = subjectId;
|
||||
}
|
||||
|
||||
public String getSubjectName() {
|
||||
return subjectName;
|
||||
}
|
||||
|
||||
public void setSubjectName(String subjectName) {
|
||||
this.subjectName = subjectName;
|
||||
}
|
||||
|
||||
public String getDay() {
|
||||
return day;
|
||||
}
|
||||
|
||||
public void setDay(String day) {
|
||||
this.day = day;
|
||||
}
|
||||
|
||||
public String getWeek() {
|
||||
return week;
|
||||
}
|
||||
|
||||
public void setWeek(String week) {
|
||||
this.week = week;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.magistr.app.dto;
|
||||
|
||||
public record LessonTypeResponse(
|
||||
Long id,
|
||||
String name
|
||||
) {
|
||||
}
|
||||
@@ -1,128 +0,0 @@
|
||||
package com.magistr.app.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.magistr.app.model.SemesterType;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ScheduleResponse {
|
||||
private Long id;
|
||||
private String specialityCode;
|
||||
private Long departmentId;
|
||||
private Long groupId;
|
||||
private String groupName;
|
||||
private Integer groupCourse;
|
||||
private Integer groupSemester;
|
||||
private Long subjectsId;
|
||||
private String subjectName;
|
||||
private Long lessonTypeId;
|
||||
private String lessonType;
|
||||
private Long numberOfHours;
|
||||
private Boolean division;
|
||||
private Long teacherId;
|
||||
private String teacherName;
|
||||
private String teacherJobTitle;
|
||||
private SemesterType semesterType;
|
||||
private String period;
|
||||
|
||||
public ScheduleResponse(Long id, Long departmentId, Long groupId, Long subjectsId, Long lessonTypeId, String lessonType, Long numberOfHours, Boolean division, Long teacherId, SemesterType semesterType, String period) {
|
||||
this.id = id;
|
||||
this.departmentId = departmentId;
|
||||
this.groupId = groupId;
|
||||
this.subjectsId = subjectsId;
|
||||
this.lessonTypeId = lessonTypeId;
|
||||
this.numberOfHours = numberOfHours;
|
||||
this.division = division;
|
||||
this.teacherId = teacherId;
|
||||
this.semesterType = semesterType;
|
||||
this.period = period;
|
||||
}
|
||||
|
||||
public ScheduleResponse(Long id, Long departmentId, String specialityCode, String groupName, Integer groupCourse, Integer groupSemester, String subjectName, String lessonType, Long numberOfHours, Boolean division, String teacherName, String teacherJobTitle, SemesterType semesterType, String period) {
|
||||
this.id = id;
|
||||
this.departmentId = departmentId;
|
||||
this.specialityCode = specialityCode;
|
||||
this.groupName = groupName;
|
||||
this.groupCourse = groupCourse;
|
||||
this.groupSemester = groupSemester;
|
||||
this.subjectName = subjectName;
|
||||
this.lessonType = lessonType;
|
||||
this.numberOfHours = numberOfHours;
|
||||
this.division = division;
|
||||
this.teacherName = teacherName;
|
||||
this.teacherJobTitle = teacherJobTitle;
|
||||
this.semesterType = semesterType;
|
||||
this.period = period;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getSpecialityCode() {
|
||||
return specialityCode;
|
||||
}
|
||||
|
||||
public Long getDepartmentId() {
|
||||
return departmentId;
|
||||
}
|
||||
|
||||
public Long getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public String getGroupName() {
|
||||
return groupName;
|
||||
}
|
||||
|
||||
public Integer getGroupCourse() {
|
||||
return groupCourse;
|
||||
}
|
||||
|
||||
public Integer getGroupSemester() {
|
||||
return groupSemester;
|
||||
}
|
||||
|
||||
public Long getSubjectsId() {
|
||||
return subjectsId;
|
||||
}
|
||||
|
||||
public String getSubjectName() {
|
||||
return subjectName;
|
||||
}
|
||||
|
||||
public Long getLessonTypeId() {
|
||||
return lessonTypeId;
|
||||
}
|
||||
|
||||
public String getLessonType() {
|
||||
return lessonType;
|
||||
}
|
||||
|
||||
public Long getNumberOfHours() {
|
||||
return numberOfHours;
|
||||
}
|
||||
|
||||
public Boolean getDivision() {
|
||||
return division;
|
||||
}
|
||||
|
||||
public Long getTeacherId() {
|
||||
return teacherId;
|
||||
}
|
||||
|
||||
public String getTeacherName() {
|
||||
return teacherName;
|
||||
}
|
||||
|
||||
public String getTeacherJobTitle() {
|
||||
return teacherJobTitle;
|
||||
}
|
||||
|
||||
public SemesterType getSemesterType() {
|
||||
return semesterType;
|
||||
}
|
||||
|
||||
public String getPeriod() {
|
||||
return period;
|
||||
}
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
package com.magistr.app.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
|
||||
@Entity
|
||||
@Table(name = "lessons")
|
||||
public class Lesson {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "teacher_id", nullable = false)
|
||||
private Long teacherId;
|
||||
|
||||
@Column(name = "group_id", nullable = false)
|
||||
private Long groupId;
|
||||
|
||||
@Column(name = "subject_id", nullable = false)
|
||||
private Long subjectId;
|
||||
|
||||
@Column(name = "lesson_format", nullable = false, length = 255)
|
||||
private String lessonFormat;
|
||||
|
||||
@Column(name = "type_lesson", nullable = false, length = 255)
|
||||
private String typeLesson;
|
||||
|
||||
@Column(name = "classroom_id", nullable = false)
|
||||
private Long classroomId;
|
||||
|
||||
@Column(name = "day", nullable = false, length = 255)
|
||||
private String day;
|
||||
|
||||
@Column(name = "week", nullable = false, length = 255)
|
||||
private String week;
|
||||
|
||||
@Column(name = "time", nullable = false, length = 255)
|
||||
private String time;
|
||||
|
||||
public Lesson() {
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getTeacherId() {
|
||||
return teacherId;
|
||||
}
|
||||
|
||||
public void setTeacherId(Long teacherId) {
|
||||
this.teacherId = teacherId;
|
||||
}
|
||||
|
||||
public Long getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(Long groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
public Long getSubjectId() {
|
||||
return subjectId;
|
||||
}
|
||||
|
||||
public void setSubjectId(Long subjectId) {
|
||||
this.subjectId = subjectId;
|
||||
}
|
||||
|
||||
public String getLessonFormat() {
|
||||
return lessonFormat;
|
||||
}
|
||||
|
||||
public void setLessonFormat(String lessonFormat) {
|
||||
this.lessonFormat = lessonFormat;
|
||||
}
|
||||
|
||||
public String getTypeLesson() {
|
||||
return typeLesson;
|
||||
}
|
||||
|
||||
public void setTypeLesson(String typeLesson) {
|
||||
this.typeLesson = typeLesson;
|
||||
}
|
||||
|
||||
public Long getClassroomId() {
|
||||
return classroomId;
|
||||
}
|
||||
|
||||
public void setClassroomId(Long classroomId) {
|
||||
this.classroomId = classroomId;
|
||||
}
|
||||
|
||||
public String getDay() {
|
||||
return day;
|
||||
}
|
||||
|
||||
public void setDay(String day) {
|
||||
this.day = day;
|
||||
}
|
||||
|
||||
public String getWeek() {
|
||||
return week;
|
||||
}
|
||||
|
||||
public void setWeek(String week) {
|
||||
this.week = week;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
package com.magistr.app.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
|
||||
@Entity
|
||||
@Table(name="schedule_data")
|
||||
public class ScheduleData {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(name="department_id", nullable = false)
|
||||
private Long departmentId;
|
||||
|
||||
@Column(name="group_id", nullable = false)
|
||||
private Long groupId;
|
||||
|
||||
@Column(name="subjects_id", nullable = false)
|
||||
private Long subjectsId;
|
||||
|
||||
@Column(name="lesson_type_id", nullable = false)
|
||||
private Long lessonTypeId;
|
||||
|
||||
@Column(name="number_of_hours", nullable = false)
|
||||
private Long numberOfHours;
|
||||
|
||||
@Column(name="is_division", nullable = false)
|
||||
private Boolean division;
|
||||
|
||||
@Column(name="teacher_id", nullable = false)
|
||||
private Long teacherId;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name="semester_type", nullable = false)
|
||||
private SemesterType semesterType;
|
||||
|
||||
@Column(name="period", nullable = false)
|
||||
private String period;
|
||||
|
||||
public ScheduleData() {}
|
||||
|
||||
public ScheduleData(Long id, Long departmentId, Long groupId, Long subjectsId, Long lessonTypeId, Long numberOfHours, Boolean division, Long teacherId, SemesterType semesterType, String period) {
|
||||
this.id = id;
|
||||
this.departmentId = departmentId;
|
||||
this.groupId = groupId;
|
||||
this.subjectsId = subjectsId;
|
||||
this.lessonTypeId = lessonTypeId;
|
||||
this.numberOfHours = numberOfHours;
|
||||
this.division = division;
|
||||
this.teacherId = teacherId;
|
||||
this.semesterType = semesterType;
|
||||
this.period = period;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getDepartmentId() {
|
||||
return departmentId;
|
||||
}
|
||||
|
||||
public void setDepartmentId(Long departmentId) {
|
||||
this.departmentId = departmentId;
|
||||
}
|
||||
|
||||
public Long getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(Long groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
public Long getSubjectsId() {
|
||||
return subjectsId;
|
||||
}
|
||||
|
||||
public void setSubjectsId(Long subjectsId) {
|
||||
this.subjectsId = subjectsId;
|
||||
}
|
||||
|
||||
public Long getLessonTypeId() {
|
||||
return lessonTypeId;
|
||||
}
|
||||
|
||||
public void setLessonTypeId(Long lessonTypeId) {
|
||||
this.lessonTypeId = lessonTypeId;
|
||||
}
|
||||
|
||||
public Long getNumberOfHours() {
|
||||
return numberOfHours;
|
||||
}
|
||||
|
||||
public void setNumberOfHours(Long numberOfHours) {
|
||||
this.numberOfHours = numberOfHours;
|
||||
}
|
||||
|
||||
public Boolean getDivision() {
|
||||
return division;
|
||||
}
|
||||
|
||||
public void setDivision(Boolean division) {
|
||||
this.division = division;
|
||||
}
|
||||
|
||||
public Long getTeacherId() {
|
||||
return teacherId;
|
||||
}
|
||||
|
||||
public void setTeacherId(Long teacherId) {
|
||||
this.teacherId = teacherId;
|
||||
}
|
||||
|
||||
public SemesterType getSemesterType() {
|
||||
return semesterType;
|
||||
}
|
||||
|
||||
public void setSemesterType(SemesterType semesterType) {
|
||||
this.semesterType = semesterType;
|
||||
}
|
||||
|
||||
public String getPeriod() {
|
||||
return period;
|
||||
}
|
||||
|
||||
public void setPeriod(String period) {
|
||||
this.period = period;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.magistr.app.repository;
|
||||
|
||||
import com.magistr.app.model.Lesson;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface LessonRepository extends JpaRepository<Lesson, Long> {
|
||||
|
||||
Optional<Lesson> findBySubjectId(Long subjectId);
|
||||
|
||||
List<Lesson> findByTeacherId(Long teacherId);
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.magistr.app.repository;
|
||||
|
||||
import com.magistr.app.model.ScheduleData;
|
||||
import com.magistr.app.model.SemesterType;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ScheduleDataRepository extends JpaRepository<ScheduleData, Long> {
|
||||
|
||||
List<ScheduleData> findByDepartmentIdAndSemesterTypeAndPeriod(Long departmentId, SemesterType semesterType, String period);
|
||||
|
||||
boolean existsByDepartmentIdAndGroupIdAndSubjectsIdAndLessonTypeIdAndNumberOfHoursAndDivisionAndTeacherIdAndSemesterTypeAndPeriod(
|
||||
Long departmentId,
|
||||
Long groupId,
|
||||
Long subjectsId,
|
||||
Long lessonTypeId,
|
||||
Long numberOfHours,
|
||||
Boolean division,
|
||||
Long teacherId,
|
||||
SemesterType semesterType,
|
||||
String period
|
||||
);
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package com.magistr.app.utils;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class DayAndWeekValidator {
|
||||
|
||||
private static final Set<String> VALID_DAYS = Set.of(
|
||||
"Понедельник", "Вторник", "Среда", "Четверг", "Пятница", "Суббота"
|
||||
);
|
||||
|
||||
private static final Set<String> VALID_WEEKS = Set.of(
|
||||
"Верхняя", "Нижняя", "Обе"
|
||||
);
|
||||
|
||||
public static boolean isValidDay(String day) {
|
||||
return day != null && VALID_DAYS.contains(day);
|
||||
}
|
||||
|
||||
public static boolean isValidWeek(String week) {
|
||||
return week != null && VALID_WEEKS.contains(week);
|
||||
}
|
||||
|
||||
public static String getValidDaysMessage() {
|
||||
return "Допустимые дни: " + String.join(", ", VALID_DAYS);
|
||||
}
|
||||
|
||||
public static String getValidWeekMessage() {
|
||||
return "Допустимы для выбора: " + String.join(", ", VALID_WEEKS);
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.magistr.app.utils;
|
||||
|
||||
import com.magistr.app.model.SemesterType;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class SemesterTypeValidator {
|
||||
|
||||
public static boolean isValidTypeSemester(String semesterType) {
|
||||
if (semesterType == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
SemesterType.valueOf(semesterType);
|
||||
return true;
|
||||
} catch (IllegalArgumentException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getValidTypes() {
|
||||
return String.join(", ", Arrays.stream(SemesterType.values())
|
||||
.map(Enum::name)
|
||||
.toArray(String[]::new));
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package com.magistr.app.utils;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class TypeAndFormatLessonValidator {
|
||||
|
||||
private static final Set<String> VALID_TYPES = Set.of(
|
||||
"Лекция", "Лабораторная работа", "Практическая работа"
|
||||
);
|
||||
|
||||
private static final Set<String> VALID_FORMATS = Set.of(
|
||||
"Онлайн", "Очно"
|
||||
);
|
||||
|
||||
public static boolean isValidType(String type) {
|
||||
return type != null && VALID_TYPES.contains(type);
|
||||
}
|
||||
|
||||
public static boolean isValidFormat(String format) {
|
||||
return format != null && VALID_FORMATS.contains(format);
|
||||
}
|
||||
|
||||
public static String getValidTypesMessage() {
|
||||
return "Допустимые типы: " + String.join(", ", VALID_TYPES);
|
||||
}
|
||||
|
||||
public static String getValidFormatsMessage() {
|
||||
return "Допустимые форматы: " + String.join(", ", VALID_FORMATS);
|
||||
}
|
||||
}
|
||||
@@ -429,35 +429,6 @@ JOIN users teacher ON teacher.username = data.teacher_username
|
||||
JOIN classrooms classroom ON classroom.name = data.classroom_name
|
||||
JOIN lesson_types lt ON lt.name = data.lesson_type_name;
|
||||
|
||||
-- ==========================================
|
||||
-- Временные таблицы старой модели. Будут удалены после очистки старого кода.
|
||||
-- ==========================================
|
||||
CREATE TABLE IF NOT EXISTS lessons (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
teacher_id BIGINT NOT NULL REFERENCES users(id),
|
||||
group_id BIGINT NOT NULL REFERENCES student_groups(id),
|
||||
subject_id BIGINT NOT NULL REFERENCES subjects(id),
|
||||
lesson_format VARCHAR(255) NOT NULL,
|
||||
type_lesson VARCHAR(255) NOT NULL,
|
||||
classroom_id BIGINT NOT NULL REFERENCES classrooms(id),
|
||||
day VARCHAR(255) NOT NULL,
|
||||
week VARCHAR(255) NOT NULL,
|
||||
time VARCHAR(255) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS schedule_data (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
department_id BIGINT NOT NULL REFERENCES departments(id),
|
||||
group_id BIGINT NOT NULL REFERENCES student_groups(id),
|
||||
subjects_id BIGINT NOT NULL REFERENCES subjects(id),
|
||||
lesson_type_id BIGINT NOT NULL REFERENCES lesson_types(id),
|
||||
number_of_hours INT NOT NULL,
|
||||
is_division BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
teacher_id BIGINT NOT NULL REFERENCES users(id),
|
||||
semester_type VARCHAR(255) NOT NULL,
|
||||
period VARCHAR(255) NOT NULL
|
||||
);
|
||||
|
||||
-- ==========================================
|
||||
-- Функция обновления timestamp
|
||||
-- ==========================================
|
||||
@@ -478,10 +449,8 @@ CREATE TRIGGER update_users_updated_at
|
||||
-- Комментарии к таблицам и полям (для документации)
|
||||
-- ==========================================
|
||||
COMMENT ON TABLE users IS 'Пользователи системы (студенты, преподаватели, администраторы)';
|
||||
COMMENT ON TABLE lessons IS 'Временная таблица старой модели расписания до удаления старого кода';
|
||||
COMMENT ON TABLE departments IS 'Кафедры';
|
||||
COMMENT ON TABLE specialties IS 'Специальности';
|
||||
COMMENT ON TABLE schedule_data IS 'Временная таблица старой модели плановой нагрузки до удаления старого кода';
|
||||
COMMENT ON TABLE time_slots IS 'Настраиваемая сетка временных слотов занятий';
|
||||
COMMENT ON TABLE academic_years IS 'Учебные годы';
|
||||
COMMENT ON TABLE semesters IS 'Семестры учебного года';
|
||||
@@ -490,15 +459,6 @@ COMMENT ON TABLE academic_calendar_matrix IS 'Матрица учебного г
|
||||
COMMENT ON TABLE schedule_rules IS 'Правила динамической генерации расписания';
|
||||
COMMENT ON TABLE schedule_rule_groups IS 'Привязка правил расписания к учебным группам';
|
||||
COMMENT ON TABLE schedule_rule_slots IS 'Слоты проведения занятий внутри правила расписания';
|
||||
COMMENT ON COLUMN schedule_data.department_id IS 'Идентификатор кафедры';
|
||||
COMMENT ON COLUMN schedule_data.group_id IS 'Идентификатор группы';
|
||||
COMMENT ON COLUMN schedule_data.subjects_id IS 'Идентификатор предмета';
|
||||
COMMENT ON COLUMN schedule_data.lesson_type_id IS 'Идентификатор типа занятия';
|
||||
COMMENT ON COLUMN schedule_data.number_of_hours IS 'Количество часов';
|
||||
COMMENT ON COLUMN schedule_data.is_division IS 'Является ли занятие разделенным';
|
||||
COMMENT ON COLUMN schedule_data.teacher_id IS 'Идентификатор преподавателя';
|
||||
COMMENT ON COLUMN schedule_data.semester_type IS 'Тип семестра (Весенний, Осенний)';
|
||||
COMMENT ON COLUMN schedule_data.period IS 'Период занятий (год/год)';
|
||||
|
||||
COMMENT ON TABLE education_forms IS 'Формы обучения';
|
||||
COMMENT ON TABLE subgroups IS 'Подгруппы';
|
||||
@@ -574,17 +534,6 @@ COMMENT ON COLUMN teacher_subjects.subject_id IS 'ID предмета';
|
||||
COMMENT ON COLUMN teacher_subjects.qualification_level IS 'Уровень квалификации преподавателя';
|
||||
COMMENT ON COLUMN teacher_subjects.experience_years IS 'Опыт преподавания';
|
||||
|
||||
COMMENT ON COLUMN lessons.id IS 'ID урока';
|
||||
COMMENT ON COLUMN lessons.teacher_id IS 'Идентификатор преподавателя, который проводит урок';
|
||||
COMMENT ON COLUMN lessons.group_id IS 'ID группы, в которой проходит урок';
|
||||
COMMENT ON COLUMN lessons.subject_id IS 'ID предмета, который преподается';
|
||||
COMMENT ON COLUMN lessons.lesson_format IS 'Формат урока';
|
||||
COMMENT ON COLUMN lessons.type_lesson IS 'Тип урока';
|
||||
COMMENT ON COLUMN lessons.classroom_id IS 'ID аудитории, в которой проходит урок';
|
||||
COMMENT ON COLUMN lessons.day IS 'День недели, в который проходит урок';
|
||||
COMMENT ON COLUMN lessons.week IS 'Номер недели, в которой проходит урок';
|
||||
COMMENT ON COLUMN lessons.time IS 'Время урока';
|
||||
|
||||
COMMENT ON COLUMN departments.id IS 'ID кафедры';
|
||||
COMMENT ON COLUMN departments.name IS 'Название кафедры';
|
||||
COMMENT ON COLUMN departments.code IS 'Код кафедры';
|
||||
|
||||
Reference in New Issue
Block a user