подготовка перед перестройкой сервисов

This commit is contained in:
Николай 2023-04-10 20:36:57 +04:00
parent 5e9c107b87
commit 27f60ab933
4 changed files with 2 additions and 17 deletions

View File

@ -38,7 +38,6 @@ public class CreatorService {
@Transactional(readOnly = true)
public List<Creator> findAllCreators() { return creatorRepository.findAll(); }
@Transactional
public Creator addCreator(String creatorName, String password) {
final Creator creator = new Creator(creatorName, password);
@ -55,12 +54,10 @@ public class CreatorService {
return creatorRepository.save(currentCreator);
}
@Transactional
public Creator deleteCreator(Long id) {
final Creator currentCreator = findCreator(id);
List<Manga> listManga = currentCreator.getMangas();
for (Manga manga : listManga){
for (final Reader reader :mangaService.getReader(manga.getId())){
reader.getMangas().remove(manga);

View File

@ -1,5 +1,4 @@
package com.LabWork.app.MangaStore.service;
import com.LabWork.app.MangaStore.model.Default.Creator;
import com.LabWork.app.MangaStore.model.Default.Manga;
import com.LabWork.app.MangaStore.model.Default.Reader;
@ -12,8 +11,6 @@ import com.LabWork.app.MangaStore.service.Repository.ReaderRepository;
import com.LabWork.app.MangaStore.util.validation.ValidatorUtil;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
@ -104,16 +101,6 @@ public class MangaService {
return currentManga;
}
/* @Transactional
public Manga addManga(Long mangaId, Long readerId) {
final Manga manga = findManga(mangaId);
readerService.addManga(readerId, List.of(manga));
return manga;
}*/
@Transactional
public void deleteAllMangas() {
mangaRepository.deleteAll();

View File

@ -91,7 +91,6 @@ public class ReaderService {
@Transactional
public Manga removeManga(Long mangaId, Long readerId) {
//em.createNativeQuery("delete from Mangas_Readers where MANGA_FK = " + manga.getId() + " AND READER_FK = "+ readerId).executeUpdate();
final Reader currentReader = findReader(readerId);
final Manga currentManga = findManga(mangaId);
currentReader.getMangas().remove(currentManga);

View File

@ -12,3 +12,5 @@ public interface MangaRepository extends JpaRepository<Manga, Long> {
@Query("select r from Reader r where :manga MEMBER OF r.mangas")
List<Reader> getReaders(Manga manga);
}