From 27f60ab933d179c3fcebb4c2ca982b6aad59741c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=BE=D0=BB=D0=B0=D0=B9?= Date: Mon, 10 Apr 2023 20:36:57 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=BE=D0=B4=D0=B3=D0=BE=D1=82=D0=BE?= =?UTF-8?q?=D0=B2=D0=BA=D0=B0=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B4=20=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=B9=D0=BA=D0=BE?= =?UTF-8?q?=D0=B9=20=D1=81=D0=B5=D1=80=D0=B2=D0=B8=D1=81=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/MangaStore/service/CreatorService.java | 3 --- .../app/MangaStore/service/MangaService.java | 13 ------------- .../app/MangaStore/service/ReaderService.java | 1 - .../service/Repository/MangaRepository.java | 2 ++ 4 files changed, 2 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/LabWork/app/MangaStore/service/CreatorService.java b/src/main/java/com/LabWork/app/MangaStore/service/CreatorService.java index 1d67e4a..cd12b5f 100644 --- a/src/main/java/com/LabWork/app/MangaStore/service/CreatorService.java +++ b/src/main/java/com/LabWork/app/MangaStore/service/CreatorService.java @@ -38,7 +38,6 @@ public class CreatorService { @Transactional(readOnly = true) public List 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 listManga = currentCreator.getMangas(); - for (Manga manga : listManga){ for (final Reader reader :mangaService.getReader(manga.getId())){ reader.getMangas().remove(manga); diff --git a/src/main/java/com/LabWork/app/MangaStore/service/MangaService.java b/src/main/java/com/LabWork/app/MangaStore/service/MangaService.java index 1df858b..f538ea1 100644 --- a/src/main/java/com/LabWork/app/MangaStore/service/MangaService.java +++ b/src/main/java/com/LabWork/app/MangaStore/service/MangaService.java @@ -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(); diff --git a/src/main/java/com/LabWork/app/MangaStore/service/ReaderService.java b/src/main/java/com/LabWork/app/MangaStore/service/ReaderService.java index aeee239..6211057 100644 --- a/src/main/java/com/LabWork/app/MangaStore/service/ReaderService.java +++ b/src/main/java/com/LabWork/app/MangaStore/service/ReaderService.java @@ -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); diff --git a/src/main/java/com/LabWork/app/MangaStore/service/Repository/MangaRepository.java b/src/main/java/com/LabWork/app/MangaStore/service/Repository/MangaRepository.java index bab5f03..a9d4854 100644 --- a/src/main/java/com/LabWork/app/MangaStore/service/Repository/MangaRepository.java +++ b/src/main/java/com/LabWork/app/MangaStore/service/Repository/MangaRepository.java @@ -12,3 +12,5 @@ public interface MangaRepository extends JpaRepository { @Query("select r from Reader r where :manga MEMBER OF r.mangas") List getReaders(Manga manga); } + +