package ru.tubryansk.tdms.service; import jakarta.transaction.Transactional; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import ru.tubryansk.tdms.controller.payload.StudentDTO; import ru.tubryansk.tdms.entity.Student; import ru.tubryansk.tdms.entity.repository.StudentRepository; import java.util.Optional; @Service @Transactional public class StudentService { @Autowired private StudentRepository studentRepository; @Autowired private CallerService callerService; public Optional getCallerStudent() { return studentRepository.findByUser(callerService.getCallerUser().orElse(null)); } public StudentDTO getCallerStudentDTO() { Student callerStudent = getCallerStudent().orElse(null); if (callerStudent == null) { return null; } return StudentDTO.from(callerStudent); } }