From 13c1c40aa5461a2c6ca0cec5c9c22ac4e2ec63fc 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: Fri, 7 Apr 2023 19:39:29 +0400 Subject: [PATCH] Dto fix --- data.mv.db | Bin 45056 -> 49152 bytes .../controller/CreatorController.java | 28 ++++++------ .../controller/MangaController.java | 26 ++++++------ .../controller/ReaderController.java | 40 +++++++++--------- .../app/MangaStore/model/Default/Manga.java | 2 + .../{CreatorDto.java => CreatorMangaDto.java} | 10 ++--- .../{MangaDto.java => MangaReaderDto.java} | 22 +++------- .../{ReaderDto.java => ReaderMangaDto.java} | 16 +++---- .../model/Dto/SupportDto/MangaDto.java | 38 +++++++++++++++++ .../model/Dto/SupportDto/ReaderDto.java | 27 ++++++++++++ 10 files changed, 133 insertions(+), 76 deletions(-) rename src/main/java/com/LabWork/app/MangaStore/model/Dto/{CreatorDto.java => CreatorMangaDto.java} (84%) rename src/main/java/com/LabWork/app/MangaStore/model/Dto/{MangaDto.java => MangaReaderDto.java} (61%) rename src/main/java/com/LabWork/app/MangaStore/model/Dto/{ReaderDto.java => ReaderMangaDto.java} (68%) create mode 100644 src/main/java/com/LabWork/app/MangaStore/model/Dto/SupportDto/MangaDto.java create mode 100644 src/main/java/com/LabWork/app/MangaStore/model/Dto/SupportDto/ReaderDto.java diff --git a/data.mv.db b/data.mv.db index c494343b7532e43669f91e8cdf2ccdc0981c1ad8..b203c2e07aec22367dac97fd0b9aec333f83fdf9 100644 GIT binary patch literal 49152 zcmeHQS!^6fdhR($wkT1Qe8?-t596_AiEC=oRecYzfQIDouy|=^sN;#~quLfkacGLP zt-M58m|rTumSRSb@eel zJqKx$qOwH^(_P)w)qj0eUDfsf-~abg70=k)ZRb(d4z|sQzeK7?lB5~u!-JhiuxrjZ z+r-+bq8Vq8So_4SB10pZY01QKXT0{_V{0Eu`IziIdDw<*aDlf?_MH#OUe%E;9Z8lo zF7Q8&07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iaX6)u1+r2R%KAeBst9E&LYazC#zGRwcv>n#*%5KhMD!qt!!~;KpuCDu zrXrN}1n%Qurc{KoI5zQspo=3!?@|%U(!Dmg@80>N-)B!Ba{bcf+$bT}Fa24*FXZ~A zHz$q{xqfMHvNz=VB|6m|a{bcZ7P>>Of9+c@sgUcRLdf-)2wPEm{$RBCrE`gL(UIm+_l~}ImozcY0bJ>;lSk(^p4}-@6dURprCsk zrE2OO5NTEQf0nAspcCQoktk0QisD47CgCblssa;S2NtkkyI9nOD33A`hDQ7vIL3pq zXdF9EBoGO4AQL)-J&zOobIg0>q%?mvgX%^Z)sjk%lLK4ab2rJo#Hl18I2j ze>hpVa8*U613=VAA)pXY2q**;0tx|zfI>haFct(j|3A&YPeyt;dH){-pY!$bQ+xj( zM4T5RT91vzL^ORq>WasQEZDhxtvHse07QK3PzF2as{p+8DgX%B4Wm`V8DsE5;Q#0T zE8EtzS5vbBo%sPQrv<3oQS$>;kxvUThX26U>|FLuXT8xVj`@&6V7U-ADH|G&Ktp1jA( z5?;6^jD3ZI;{PlDKOG3c*iCKh0^>K7EB-&cR9*4^k9|YA9RDZd?_{V%lJUQ-+kxeN I3giF(2N;I>t^fc4 diff --git a/src/main/java/com/LabWork/app/MangaStore/controller/CreatorController.java b/src/main/java/com/LabWork/app/MangaStore/controller/CreatorController.java index 2f6ed4b..5b99465 100644 --- a/src/main/java/com/LabWork/app/MangaStore/controller/CreatorController.java +++ b/src/main/java/com/LabWork/app/MangaStore/controller/CreatorController.java @@ -1,6 +1,6 @@ package com.LabWork.app.MangaStore.controller; -import com.LabWork.app.MangaStore.model.Dto.CreatorDto; +import com.LabWork.app.MangaStore.model.Dto.CreatorMangaDto; import com.LabWork.app.MangaStore.service.CreatorService; import org.springframework.web.bind.annotation.*; @@ -16,34 +16,34 @@ public class CreatorController { } @GetMapping("/{id}") - public CreatorDto getCreator(@PathVariable Long id) { - return new CreatorDto(creatorService.findCreator(id)); + public CreatorMangaDto getCreator(@PathVariable Long id) { + return new CreatorMangaDto(creatorService.findCreator(id)); } @GetMapping - public List getCreators() { + public List getCreators() { return creatorService.findAllCreators().stream() - .map(CreatorDto::new) + .map(CreatorMangaDto::new) .toList(); } @PostMapping - public CreatorDto createCreator(@RequestParam("creatorName") String creatorName, - @RequestParam("password") String password) { - return new CreatorDto(creatorService.addCreator(creatorName, password)); + public CreatorMangaDto createCreator(@RequestParam("creatorName") String creatorName, + @RequestParam("password") String password) { + return new CreatorMangaDto(creatorService.addCreator(creatorName, password)); } @PutMapping("/{id}") - public CreatorDto updateCreator(@PathVariable Long id, - @RequestParam("creatorName") String creatorName, - @RequestParam("password") String password) { - return new CreatorDto(creatorService.updateCreator(id, creatorName, password)); + public CreatorMangaDto updateCreator(@PathVariable Long id, + @RequestParam("creatorName") String creatorName, + @RequestParam("password") String password) { + return new CreatorMangaDto(creatorService.updateCreator(id, creatorName, password)); } @DeleteMapping("/{id}") - public CreatorDto deleteCreator(@PathVariable Long id) { + public CreatorMangaDto deleteCreator(@PathVariable Long id) { //creatorService.deleteAllCreators(); - return new CreatorDto(creatorService.deleteCreator(id)); + return new CreatorMangaDto(creatorService.deleteCreator(id)); } @DeleteMapping diff --git a/src/main/java/com/LabWork/app/MangaStore/controller/MangaController.java b/src/main/java/com/LabWork/app/MangaStore/controller/MangaController.java index 1f909b5..4f6aa9c 100644 --- a/src/main/java/com/LabWork/app/MangaStore/controller/MangaController.java +++ b/src/main/java/com/LabWork/app/MangaStore/controller/MangaController.java @@ -1,8 +1,8 @@ package com.LabWork.app.MangaStore.controller; -import com.LabWork.app.MangaStore.model.Default.Creator; -import com.LabWork.app.MangaStore.model.Dto.MangaDto; +import com.LabWork.app.MangaStore.model.Dto.MangaReaderDto; +import com.LabWork.app.MangaStore.model.Dto.SupportDto.MangaDto; import com.LabWork.app.MangaStore.service.MangaService; import org.springframework.web.bind.annotation.*; @@ -18,28 +18,28 @@ public class MangaController { } @GetMapping("/{id}") - public MangaDto getManga(@PathVariable Long id) { - return new MangaDto(mangaService.findManga(id), mangaService.getReader(id)); + public MangaReaderDto getManga(@PathVariable Long id) { + return new MangaReaderDto(mangaService.findManga(id), mangaService.getReader(id)); } @GetMapping - public List getMangas() { + public List getMangas() { return mangaService.findAllMangas().stream() - .map(x -> new MangaDto(x, mangaService.getReader(x.getId()))) + .map(x -> new MangaReaderDto(x, mangaService.getReader(x.getId()))) .toList(); } @PostMapping - public MangaDto createManga(@RequestParam("creatorId") Long creatorId, - @RequestParam("chapterCount") Integer chapterCount, - @RequestParam("mangaName") String mangaName) { - return new MangaDto(mangaService.addManga(creatorId, chapterCount, mangaName), mangaService.getReader(creatorId)); + public MangaReaderDto createManga(@RequestParam("creatorId") Long creatorId, + @RequestParam("chapterCount") Integer chapterCount, + @RequestParam("mangaName") String mangaName) { + return new MangaReaderDto(mangaService.addManga(creatorId, chapterCount, mangaName), mangaService.getReader(creatorId)); } @PutMapping("/{id}") - public MangaDto updateManga(@PathVariable Long id, - @RequestParam("chapterCount") Integer chapterCount) { - return new MangaDto(mangaService.updateManga(id, chapterCount), mangaService.getReader(id)); + public MangaReaderDto updateManga(@PathVariable Long id, + @RequestParam("chapterCount") Integer chapterCount) { + return new MangaReaderDto(mangaService.updateManga(id, chapterCount), mangaService.getReader(id)); } @DeleteMapping("/{id}") diff --git a/src/main/java/com/LabWork/app/MangaStore/controller/ReaderController.java b/src/main/java/com/LabWork/app/MangaStore/controller/ReaderController.java index 5b7a76f..e9b44d9 100644 --- a/src/main/java/com/LabWork/app/MangaStore/controller/ReaderController.java +++ b/src/main/java/com/LabWork/app/MangaStore/controller/ReaderController.java @@ -1,7 +1,7 @@ package com.LabWork.app.MangaStore.controller; -import com.LabWork.app.MangaStore.model.Dto.ReaderDto; +import com.LabWork.app.MangaStore.model.Dto.ReaderMangaDto; import com.LabWork.app.MangaStore.service.ReaderService; import org.springframework.web.bind.annotation.*; @@ -17,44 +17,44 @@ public class ReaderController { } @GetMapping("/{id}") - public ReaderDto getReader(@PathVariable Long id) { - return new ReaderDto(readerService.findReader(id)); + public ReaderMangaDto getReader(@PathVariable Long id) { + return new ReaderMangaDto(readerService.findReader(id)); } @GetMapping - public List getReaders() { + public List getReaders() { return readerService.findAllReaders().stream() - .map(ReaderDto::new) + .map(ReaderMangaDto::new) .toList(); } @PostMapping - public ReaderDto createReader(@RequestParam("readerName") String readerName, - @RequestParam("password") String password) { - return new ReaderDto(readerService.addReader(readerName, password)); + public ReaderMangaDto createReader(@RequestParam("readerName") String readerName, + @RequestParam("password") String password) { + return new ReaderMangaDto(readerService.addReader(readerName, password)); } @PutMapping("/{id}") - public ReaderDto updateReader(@PathVariable Long id, - @RequestParam("readerName") String readerName, - @RequestParam("password") String password) { - return new ReaderDto(readerService.updateReader(id, readerName, password)); + public ReaderMangaDto updateReader(@PathVariable Long id, + @RequestParam("readerName") String readerName, + @RequestParam("password") String password) { + return new ReaderMangaDto(readerService.updateReader(id, readerName, password)); } @PutMapping("/{id}/addManga") - public ReaderDto addManga(@PathVariable Long id, - @RequestParam("mangaId") Long mangaId) { - return new ReaderDto(readerService.addManga(mangaId, id)); + public ReaderMangaDto addManga(@PathVariable Long id, + @RequestParam("mangaId") Long mangaId) { + return new ReaderMangaDto(readerService.addManga(mangaId, id)); } @PutMapping("/{id}/removeManga") - public ReaderDto removeManga(@PathVariable Long id, - @RequestParam("mangaId") Long mangaId) { - return new ReaderDto(readerService.removeManga(mangaId, id)); + public ReaderMangaDto removeManga(@PathVariable Long id, + @RequestParam("mangaId") Long mangaId) { + return new ReaderMangaDto(readerService.removeManga(mangaId, id)); } @DeleteMapping("/{id}") - public ReaderDto deleteReader(@PathVariable Long id) { - return new ReaderDto(readerService.deleteReader(id)); + public ReaderMangaDto deleteReader(@PathVariable Long id) { + return new ReaderMangaDto(readerService.deleteReader(id)); } } diff --git a/src/main/java/com/LabWork/app/MangaStore/model/Default/Manga.java b/src/main/java/com/LabWork/app/MangaStore/model/Default/Manga.java index 6d06411..8900735 100644 --- a/src/main/java/com/LabWork/app/MangaStore/model/Default/Manga.java +++ b/src/main/java/com/LabWork/app/MangaStore/model/Default/Manga.java @@ -1,5 +1,7 @@ package com.LabWork.app.MangaStore.model.Default; +import com.LabWork.app.MangaStore.service.CreatorService; +import com.LabWork.app.MangaStore.service.MangaService; import jakarta.persistence.*; import java.util.ArrayList; diff --git a/src/main/java/com/LabWork/app/MangaStore/model/Dto/CreatorDto.java b/src/main/java/com/LabWork/app/MangaStore/model/Dto/CreatorMangaDto.java similarity index 84% rename from src/main/java/com/LabWork/app/MangaStore/model/Dto/CreatorDto.java rename to src/main/java/com/LabWork/app/MangaStore/model/Dto/CreatorMangaDto.java index c311f4b..4c8bf5a 100644 --- a/src/main/java/com/LabWork/app/MangaStore/model/Dto/CreatorDto.java +++ b/src/main/java/com/LabWork/app/MangaStore/model/Dto/CreatorMangaDto.java @@ -1,17 +1,17 @@ package com.LabWork.app.MangaStore.model.Dto; import com.LabWork.app.MangaStore.model.Default.Creator; -import com.LabWork.app.MangaStore.model.Default.Manga; -import java.util.List; -import java.util.Objects; +import com.LabWork.app.MangaStore.model.Dto.SupportDto.MangaDto; -public class CreatorDto { +import java.util.List; + +public class CreatorMangaDto { private final long id; private final String creatorName; private final String hashedPassword; private final List mangas; - public CreatorDto(Creator creator) { + public CreatorMangaDto(Creator creator) { this.id = creator.getId(); this.creatorName = creator.getCreatorName(); this.hashedPassword = creator.getHashedPassword(); diff --git a/src/main/java/com/LabWork/app/MangaStore/model/Dto/MangaDto.java b/src/main/java/com/LabWork/app/MangaStore/model/Dto/MangaReaderDto.java similarity index 61% rename from src/main/java/com/LabWork/app/MangaStore/model/Dto/MangaDto.java rename to src/main/java/com/LabWork/app/MangaStore/model/Dto/MangaReaderDto.java index 27369fc..0f3ba4b 100644 --- a/src/main/java/com/LabWork/app/MangaStore/model/Dto/MangaDto.java +++ b/src/main/java/com/LabWork/app/MangaStore/model/Dto/MangaReaderDto.java @@ -3,39 +3,29 @@ package com.LabWork.app.MangaStore.model.Dto; import com.LabWork.app.MangaStore.model.Default.Creator; import com.LabWork.app.MangaStore.model.Default.Manga; import com.LabWork.app.MangaStore.model.Default.Reader; -import com.LabWork.app.MangaStore.service.MangaService; +import com.LabWork.app.MangaStore.model.Dto.SupportDto.ReaderDto; -import java.util.ArrayList; import java.util.List; -import java.util.Objects; -public class MangaDto { +public class MangaReaderDto { private final Long id; private final Long creatorId; private final String mangaName; private final Integer chapterCount; - private final List readers; + private final List readers; - public MangaDto(Manga manga, List listReader) { + public MangaReaderDto(Manga manga, List listReader) { this.id = manga.getId(); this.creatorId = manga.getCreator().getId(); this.mangaName = manga.getMangaName(); this.chapterCount = manga.getChapterCount(); this.readers = listReader.stream() - .map(y -> new String(y.getReaderName())) + .map(y -> new ReaderDto(y)) .toList(); } - public MangaDto(Manga manga) { - this.id = manga.getId(); - this.creatorId = manga.getCreator().getId(); - this.mangaName = manga.getMangaName(); - this.chapterCount = manga.getChapterCount(); - this.readers = null; - } - public Long getId() { return id; } @@ -44,7 +34,7 @@ public class MangaDto { return mangaName; } - public List getReaders() { + public List getReaders() { return readers; } diff --git a/src/main/java/com/LabWork/app/MangaStore/model/Dto/ReaderDto.java b/src/main/java/com/LabWork/app/MangaStore/model/Dto/ReaderMangaDto.java similarity index 68% rename from src/main/java/com/LabWork/app/MangaStore/model/Dto/ReaderDto.java rename to src/main/java/com/LabWork/app/MangaStore/model/Dto/ReaderMangaDto.java index a343a50..f1adc6c 100644 --- a/src/main/java/com/LabWork/app/MangaStore/model/Dto/ReaderDto.java +++ b/src/main/java/com/LabWork/app/MangaStore/model/Dto/ReaderMangaDto.java @@ -1,25 +1,25 @@ package com.LabWork.app.MangaStore.model.Dto; -import com.LabWork.app.MangaStore.model.Default.Manga; import com.LabWork.app.MangaStore.model.Default.Reader; -import java.util.List; -import java.util.Objects; +import com.LabWork.app.MangaStore.model.Dto.SupportDto.MangaDto; -public class ReaderDto { +import java.util.List; + +public class ReaderMangaDto { private Long id; private String readerName; private String hashedPassword; - private List mangas; + private List mangas; - public ReaderDto(Reader reader) { + public ReaderMangaDto(Reader reader) { this.id = reader.getId(); this.readerName = reader.getReaderName(); this.hashedPassword = reader.getHashedPassword(); this.mangas = reader.getMangas().stream() - .map(y -> new String(y.getMangaName())) + .map(y -> new MangaDto(y)) .toList(); } @@ -31,6 +31,6 @@ public class ReaderDto { public String getHashedPassword() { return hashedPassword; } - public List getMangas() { return mangas; } + public List getMangas() { return mangas; } } diff --git a/src/main/java/com/LabWork/app/MangaStore/model/Dto/SupportDto/MangaDto.java b/src/main/java/com/LabWork/app/MangaStore/model/Dto/SupportDto/MangaDto.java new file mode 100644 index 0000000..5ed9887 --- /dev/null +++ b/src/main/java/com/LabWork/app/MangaStore/model/Dto/SupportDto/MangaDto.java @@ -0,0 +1,38 @@ +package com.LabWork.app.MangaStore.model.Dto.SupportDto; + +import com.LabWork.app.MangaStore.model.Default.Manga; +import com.LabWork.app.MangaStore.model.Default.Reader; + +import java.util.List; + +public class MangaDto { + private final Long id; + + private final Long creatorId; + private final String mangaName; + private final Integer chapterCount; + + public MangaDto(Manga manga) { + this.id = manga.getId(); + this.creatorId = manga.getCreator().getId(); + this.mangaName = manga.getMangaName(); + this.chapterCount = manga.getChapterCount(); + } + + public Long getId() { + return id; + } + + public String getMangaName() { + return mangaName; + } + + public Integer getChapterCount() { + return chapterCount; + } + + public Long getCreatorId() { + return creatorId; + } + +} diff --git a/src/main/java/com/LabWork/app/MangaStore/model/Dto/SupportDto/ReaderDto.java b/src/main/java/com/LabWork/app/MangaStore/model/Dto/SupportDto/ReaderDto.java new file mode 100644 index 0000000..1e9539e --- /dev/null +++ b/src/main/java/com/LabWork/app/MangaStore/model/Dto/SupportDto/ReaderDto.java @@ -0,0 +1,27 @@ +package com.LabWork.app.MangaStore.model.Dto.SupportDto; + +import com.LabWork.app.MangaStore.model.Default.Reader; + +import java.util.List; + +public class ReaderDto { + private Long id; + + private String readerName; + + private String hashedPassword; + + public ReaderDto(Reader reader) { + this.id = reader.getId(); + this.readerName = reader.getReaderName(); + this.hashedPassword = reader.getHashedPassword(); + } + + public Long getId() { + return id; + } + + public String getReaderName() { return readerName; } + + public String getHashedPassword() { return hashedPassword; } +}