Добавил метод на получение списка данных для расписания
This commit is contained in:
@@ -0,0 +1,54 @@
|
|||||||
|
package com.magistr.app.controller;
|
||||||
|
|
||||||
|
import com.magistr.app.model.Department;
|
||||||
|
import com.magistr.app.model.ScheduleData;
|
||||||
|
import com.magistr.app.repository.DepartmentRepository;
|
||||||
|
import com.magistr.app.repository.ScheduleDataRepository;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/scheduledata")
|
||||||
|
public class ScheduleDataController {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(ScheduleDataController.class);
|
||||||
|
|
||||||
|
private final ScheduleDataRepository scheduleDataRepository;
|
||||||
|
|
||||||
|
public ScheduleDataController(ScheduleDataRepository scheduleDataRepository) {
|
||||||
|
this.scheduleDataRepository = scheduleDataRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
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.getSemester(),
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
package com.magistr.app.dto;
|
||||||
|
|
||||||
|
public class CreateScheduleDataRequest {
|
||||||
|
private Long id;
|
||||||
|
private Long departmentId;
|
||||||
|
private Long semester;
|
||||||
|
private Long groupId;
|
||||||
|
private Long subjectsId;
|
||||||
|
private Long lessonTypeId;
|
||||||
|
private Long numberOfHours;
|
||||||
|
private Boolean isDivision;
|
||||||
|
private Long teacherId;
|
||||||
|
private String 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 getSemester() {
|
||||||
|
return semester;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSemester(Long semester) {
|
||||||
|
this.semester = semester;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 isDivision;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDivision(Boolean division) {
|
||||||
|
isDivision = division;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getTeacherId() {
|
||||||
|
return teacherId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTeacherId(Long teacherId) {
|
||||||
|
this.teacherId = teacherId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSemesterType() {
|
||||||
|
return semesterType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSemesterType(String semesterType) {
|
||||||
|
this.semesterType = semesterType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPeriod() {
|
||||||
|
return period;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPeriod(String period) {
|
||||||
|
this.period = period;
|
||||||
|
}
|
||||||
|
}
|
||||||
120
backend/src/main/java/com/magistr/app/dto/ScheduleResponse.java
Normal file
120
backend/src/main/java/com/magistr/app/dto/ScheduleResponse.java
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
package com.magistr.app.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
public class ScheduleResponse {
|
||||||
|
private Long id;
|
||||||
|
private Long departmentId;
|
||||||
|
private Long semester;
|
||||||
|
private Long groupId;
|
||||||
|
private Long subjectsId;
|
||||||
|
private Long lessonTypeId;
|
||||||
|
private Long numberOfHours;
|
||||||
|
private Boolean isDivision;
|
||||||
|
private Long teacherId;
|
||||||
|
private String semesterType;
|
||||||
|
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) {
|
||||||
|
this.id = id;
|
||||||
|
this.departmentId = departmentId;
|
||||||
|
this.semester = semester;
|
||||||
|
this.groupId = groupId;
|
||||||
|
this.subjectsId = subjectsId;
|
||||||
|
this.lessonTypeId = lessonTypeId;
|
||||||
|
this.numberOfHours = numberOfHours;
|
||||||
|
this.isDivision = isDivision;
|
||||||
|
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 getSemester() {
|
||||||
|
return semester;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSemester(Long semester) {
|
||||||
|
this.semester = semester;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 isDivision;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDivision(Boolean division) {
|
||||||
|
isDivision = division;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getTeacherId() {
|
||||||
|
return teacherId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTeacherId(Long teacherId) {
|
||||||
|
this.teacherId = teacherId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSemesterType() {
|
||||||
|
return semesterType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSemesterType(String semesterType) {
|
||||||
|
this.semesterType = semesterType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPeriod() {
|
||||||
|
return period;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPeriod(String period) {
|
||||||
|
this.period = period;
|
||||||
|
}
|
||||||
|
}
|
||||||
146
backend/src/main/java/com/magistr/app/model/ScheduleData.java
Normal file
146
backend/src/main/java/com/magistr/app/model/ScheduleData.java
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
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="semester", nullable = false)
|
||||||
|
private Long semester;
|
||||||
|
|
||||||
|
@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 isDivision;
|
||||||
|
|
||||||
|
@Column(name="teacher_id", nullable = false)
|
||||||
|
private Long teacherId;
|
||||||
|
|
||||||
|
@Column(name="semester_type", nullable = false)
|
||||||
|
private String semesterType;
|
||||||
|
|
||||||
|
@Column(name="period", nullable = false)
|
||||||
|
private String period;
|
||||||
|
|
||||||
|
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) {
|
||||||
|
this.id = id;
|
||||||
|
this.departmentId = departmentId;
|
||||||
|
this.semester = semester;
|
||||||
|
this.groupId = groupId;
|
||||||
|
this.subjectsId = subjectsId;
|
||||||
|
this.lessonTypeId = lessonTypeId;
|
||||||
|
this.numberOfHours = numberOfHours;
|
||||||
|
this.isDivision = isDivision;
|
||||||
|
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 getSemester() {
|
||||||
|
return semester;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSemester(Long semester) {
|
||||||
|
this.semester = semester;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 isDivision;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDivision(Boolean division) {
|
||||||
|
isDivision = division;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getTeacherId() {
|
||||||
|
return teacherId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTeacherId(Long teacherId) {
|
||||||
|
this.teacherId = teacherId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSemesterType() {
|
||||||
|
return semesterType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSemesterType(String semesterType) {
|
||||||
|
this.semesterType = semesterType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPeriod() {
|
||||||
|
return period;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPeriod(String period) {
|
||||||
|
this.period = period;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.magistr.app.repository;
|
||||||
|
|
||||||
|
import com.magistr.app.model.ScheduleData;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
public interface ScheduleDataRepository extends JpaRepository<ScheduleData, Long> {
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user