changes.
This commit is contained in:
parent
bdb6e2680f
commit
c6343207c2
@ -14,7 +14,6 @@ import ru.mskobaro.tdms.integration.controller.payload.DefenseDTO;
|
||||
import ru.mskobaro.tdms.integration.controller.payload.GroupDTO;
|
||||
import ru.mskobaro.tdms.integration.database.*;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -49,6 +49,12 @@ public class ParticipantService {
|
||||
private EntityManager entityManager;
|
||||
@Autowired
|
||||
private EmailService emailService;
|
||||
@Autowired
|
||||
private TaskService taskService;
|
||||
@Autowired
|
||||
private DefenseRepository defenseRepository;
|
||||
@Autowired
|
||||
private DefenseService defenseService;
|
||||
|
||||
public ParticipantService(ParticipantRepository participantRepository) {
|
||||
this.participantRepository = participantRepository;
|
||||
@ -90,7 +96,7 @@ public class ParticipantService {
|
||||
|
||||
List<Role> roles = persistRoles(participantSaveDTO, existingParticipant, editMode, callerUser, participant);
|
||||
boolean credentialsChanged = persistUserData(participantSaveDTO, existingParticipant, editMode, participant);
|
||||
persistStudentData(participantSaveDTO, existingParticipant, editMode, roles, participant);
|
||||
StudentData studentData = persistStudentData(participantSaveDTO, existingParticipant, editMode, roles, participant);
|
||||
persistTeacherData(participantSaveDTO, existingParticipant, editMode, roles, participant);
|
||||
persistCommissionData(participantSaveDTO, existingParticipant, editMode, roles, participant);
|
||||
|
||||
@ -108,6 +114,19 @@ public class ParticipantService {
|
||||
|
||||
С уважением, администрация.
|
||||
""".formatted(participant.getFullName(), participant.getUser().getUsername(), participantSaveDTO.getUserData().getPassword()));
|
||||
|
||||
if (studentData != null && studentData.getGroup() != null) {
|
||||
List<Defense> defenses = entityManager.createQuery("select distinct d from Defense d inner join fetch d.groups g where g.id = :id", Defense.class)
|
||||
.setParameter("id", studentData.getGroup().getId())
|
||||
.getResultList();
|
||||
Defense defense = null;
|
||||
if (defenses != null && !defenses.isEmpty()) {
|
||||
defense = defenses.get(0);
|
||||
}
|
||||
if (defense != null) {
|
||||
taskService.checkAndCreateTopicChoosingTasksAndSendEmail(Collections.singletonList(studentData), defense);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (credentialsChanged) {
|
||||
@ -200,11 +219,11 @@ public class ParticipantService {
|
||||
teacherData.setParticipant(participant);
|
||||
}
|
||||
|
||||
private void persistStudentData(ParticipantSaveDTO participantSaveDTO, Participant existingParticipant, boolean editMode, List<Role> roles, Participant participant) {
|
||||
private StudentData persistStudentData(ParticipantSaveDTO participantSaveDTO, Participant existingParticipant, boolean editMode, List<Role> roles, Participant participant) {
|
||||
boolean shouldPersistStudentData = participantSaveDTO.getStudentData() != null && roles != null
|
||||
&& CollectionUtils.containsAny(roles, roleService.getRoleByAuthority(RoleService.Authority.STUDENT));
|
||||
if (!shouldPersistStudentData) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
boolean alreadyExists = editMode && studentDataRepository.existsByParticipant_IdAndParticipant_DeletedFalse(existingParticipant.getId());
|
||||
@ -251,6 +270,7 @@ public class ParticipantService {
|
||||
|
||||
studentData = studentDataRepository.save(studentData);
|
||||
studentData.setParticipant(participant);
|
||||
return studentData;
|
||||
}
|
||||
|
||||
private void persistCommissionData(ParticipantSaveDTO participantSaveDTO, Participant existingParticipant, boolean editMode, List<Role> roles, Participant participant) {
|
||||
|
||||
@ -57,7 +57,7 @@ INSERT INTO public.commission_member_data (id, partic_id, work_place, work_posit
|
||||
INSERT INTO public.commission_member_data (id, partic_id, work_place, work_position, created_at, updated_at) VALUES (5, 23, 'БГТУ', 'доц.,ктн.,зав.кав.', '2025-06-23 03:42:42.288583', '2025-06-23 03:42:42.288590');
|
||||
INSERT INTO public.commission_member_data (id, partic_id, work_place, work_position, created_at, updated_at) VALUES (4, 22, 'БГТУ', 'доц.,ктн.', '2025-06-23 03:42:37.300773', '2025-06-23 03:42:37.300777');
|
||||
|
||||
INSERT INTO public.defense (id, defense_date, status, direction_of_preparation_id, responsible_for_antiplagiarism_id, responsible_for_normcontrol_id, created_at, updated_at) VALUES (1, '2025-06-26', 'TOPIC_PREPARATION', 1, 22, 22, '2025-06-23 04:09:15.118953', '2025-06-23 04:09:15.118975');
|
||||
INSERT INTO public.defense (id, defense_date, status, direction_of_preparation_id, responsible_for_antiplagiarism_id, responsible_for_normcontrol_id, created_at, updated_at) VALUES (1, '2025-06-26', 'DEFENSE_PREPARATION', 1, 22, 22, '2025-06-23 04:09:15.118953', '2025-06-23 04:09:15.118975');
|
||||
|
||||
INSERT INTO public."group" (id, name, defense_id, direction_of_preparation_id, created_at, updated_at) VALUES (1, 'О-21-ИВТ-1-по-Б', 1, 1, '2025-06-23 03:50:49.095829', '2025-06-23 03:50:49.095835');
|
||||
INSERT INTO public."group" (id, name, defense_id, direction_of_preparation_id, created_at, updated_at) VALUES (2, 'О-21-ИВТ-2-по-Б', 1, 1, '2025-06-23 03:50:49.096295', '2025-06-23 03:50:49.096299');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user