/
whitetech
/
tts
Обзор
Документация
Войти
/
whitetech
/
tts
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
ClientContactServiceImpl.java
53 строки
2 KB
whitetech
upload files
06 дек 2024, 11:19
06 дек 2024, 11:19
2dc37a9
Код
Авторство
О чём код?
package com.timesheet.service.impl.client; import com.timesheet.entity.client.ClientContact; import com.timesheet.helper.journal.ClientJournalHelper; import com.timesheet.repository.client.ClientContactRepository; import com.timesheet.service.face.project.ContactService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; @Slf4j @Service @RequiredArgsConstructor public class ClientContactServiceImpl implements ContactService { private final ClientJournalHelper clientJournalHelper; private final ClientContactRepository clientContactRepository; @Override @Transactional public List<ClientContact> addContact(ClientContact contact, Integer employeeId) { clientContactRepository.save(contact); clientJournalHelper.clientContactRecord(contact, employeeId, false); return clientContactRepository.findAllByClientId(contact.getClientId()); } @Override @Transactional public List<ClientContact> removeContact(int contactId, int clientId, Integer employeeId) { ClientContact contact = clientContactRepository.findByContactId(contactId); clientContactRepository.delete(contact); clientJournalHelper.clientContactRecord(contact, employeeId, true); return clientContactRepository.findAllByClientId(clientId); } @Override @Transactional public List<ClientContact> editContact(ClientContact contact, Integer employeeId) { ClientContact oldContact = clientContactRepository.findByContactId(contact.getContactId()); clientContactRepository.save(contact); clientJournalHelper.editClientContactRecord(oldContact, contact, employeeId); return clientContactRepository.findAllByClientId(contact.getClientId()); } @Override @Transactional public List<ClientContact> getContacts(int clientId) { return clientContactRepository.findAllByClientId(clientId); } }