осталось переделать на react
This commit is contained in:
parent
1cfcffa2e9
commit
d3a42cd753
@ -13,8 +13,8 @@
|
||||
<div class="container" id="root-div">
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||
<a class="navbar-brand" href="index.html">Creator</a>
|
||||
<a class="nav-link" href="Mangs.html">Manga</a>
|
||||
<a class="nav-link" href="Readers.html">Reader</a>
|
||||
<a class="navbar-brand" href="Mangs.html">Manga</a>
|
||||
<a class="navbar-brand" href="Readers.html">Reader</a>
|
||||
</nav>
|
||||
<div class="content">
|
||||
<h1>Manga</h1>
|
||||
|
@ -13,8 +13,8 @@
|
||||
<div class="container" id="root-div">
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||
<a class="navbar-brand" href="index.html">Creator</a>
|
||||
<a class="nav-link" href="Mangs.html">Manga</a>
|
||||
<a class="nav-link" href="Readers.html">Reader</a>
|
||||
<a class="navbar-brand" href="Mangs.html">Manga</a>
|
||||
<a class="navbar-brand" href="Readers.html">Reader</a>
|
||||
</nav>
|
||||
<div class="content">
|
||||
<h1>Reader</h1>
|
||||
|
@ -13,8 +13,8 @@
|
||||
<div class="container" id="root-div">
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||
<a class="navbar-brand" href="index.html">Creator</a>
|
||||
<a class="nav-link" href="Mangs.html">Manga</a>
|
||||
<a class="nav-link" href="Readers.html">Reader</a>
|
||||
<a class="navbar-brand" href="Mangs.html">Manga</a>
|
||||
<a class="navbar-brand" href="Readers.html">Reader</a>
|
||||
</nav>
|
||||
<div class="content">
|
||||
<h1>Creator</h1>
|
||||
|
@ -15,18 +15,18 @@ window.addEventListener('DOMContentLoaded', function () {
|
||||
const response = await fetch(host + "/manga");
|
||||
const data = await response.json();
|
||||
console.log(data);
|
||||
data.forEach(Manga => {
|
||||
data.forEach(MangaDto => {
|
||||
let temp = "<select>";
|
||||
Manga.readers.forEach(String => {
|
||||
MangaDto.readers.forEach(String => {
|
||||
temp += `<option>${String}</option>>`
|
||||
})
|
||||
temp += "</select>"
|
||||
table.innerHTML +=
|
||||
`<tr>
|
||||
<th scope="row" id="componentId">${Manga.id}</th>
|
||||
<td>${Manga.mangaName}</td>
|
||||
<td>${Manga.chapterCount}</td>
|
||||
<td>${Manga.creatorId}</td>
|
||||
<th scope="row" id="componentId">${MangaDto.id}</th>
|
||||
<td>${MangaDto.mangaName}</td>
|
||||
<td>${MangaDto.chapterCount}</td>
|
||||
<td>${MangaDto.creatorId}</td>
|
||||
<td>${temp}</td>
|
||||
</tr>`;
|
||||
})
|
||||
|
@ -73,7 +73,7 @@ window.addEventListener('DOMContentLoaded', function () {
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
const response = await fetch(host + `/reader/` + readerIdInput.value, requestParams);
|
||||
const response = await fetch(host + `/reader/${readerIdInput.value}`, requestParams);
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class Reader {
|
||||
|
||||
public List<Manga> getMangas() { return mangas; }
|
||||
|
||||
public void setMangas(List<Manga> mangs) { this.mangas = mangs; }
|
||||
public void setMangas(List<Manga> mangas) { this.mangas = mangas; }
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
@ -44,6 +44,10 @@ public class MangaDto {
|
||||
return mangaName;
|
||||
}
|
||||
|
||||
public List<String> getReaders() {
|
||||
return readers;
|
||||
}
|
||||
|
||||
public Integer getChapterCount() {
|
||||
return chapterCount;
|
||||
}
|
||||
|
@ -63,7 +63,8 @@ public class CreatorService {
|
||||
List<Manga> listManga = currentCreator.getMangas();mangaService.findAllMangas();
|
||||
for (Manga manga : listManga){
|
||||
for (final Reader reader :mangaService.getReader(manga.getId())){
|
||||
readerRepository.delete(reader);
|
||||
reader.getMangas().remove(manga);
|
||||
readerRepository.save(reader);
|
||||
}
|
||||
}
|
||||
creatorRepository.delete(currentCreator);
|
||||
|
@ -85,9 +85,7 @@ public class ReaderService {
|
||||
@Transactional
|
||||
public Reader deleteReader(Long id) {
|
||||
final Reader currentReader = findReader(id);
|
||||
/* for (Manga manga : currentReader.getMangas()){
|
||||
manga.getReaders().remove(currentReader);
|
||||
}*/
|
||||
currentReader.getMangas().clear();
|
||||
readerRepository.delete(currentReader);
|
||||
return currentReader;
|
||||
}
|
||||
|
@ -26,6 +26,28 @@ public class ReMangaTest {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ReMangaTest.class);
|
||||
|
||||
@Test
|
||||
void testReaderRemove2() {
|
||||
readerService.deleteAllReaders();
|
||||
mangaService.deleteAllMangas();
|
||||
creatorService.deleteAllCreators();
|
||||
Creator c1 = creatorService.addCreator("first_C", "1");
|
||||
Manga m1 = mangaService.addManga(c1.getId(), 0, "Vagabond");
|
||||
Manga m2 = mangaService.addManga(c1.getId(), 10, "Berserk");
|
||||
Reader r1 = readerService.addReader("first_R", "1");
|
||||
|
||||
readerService.addManga(m1.getId(), r1.getId());
|
||||
readerService.addManga(m2.getId(), r1.getId());
|
||||
|
||||
Reader r11 = readerService.findReader(r1.getId());
|
||||
readerService.deleteReader(r11.getId());
|
||||
|
||||
log.info(readerService.findAllReaders().toString());
|
||||
mangaService.deleteAllMangas();
|
||||
readerService.deleteAllReaders();
|
||||
creatorService.deleteAllCreators();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAddToMangaReader2() {
|
||||
readerService.deleteAllReaders();
|
||||
@ -370,8 +392,8 @@ public class ReMangaTest {
|
||||
|
||||
Manga m11 = mangaService.findManga(m1.getId());
|
||||
log.info(readerService.findAllReaders().toString());
|
||||
//log.info(m11.getReaders().toString());
|
||||
//Assertions.assertEquals(0, m11.getReaders().size());
|
||||
log.info(mangaService.getReader(m11.getId()).toString());
|
||||
Assertions.assertEquals(0, mangaService.getReader(m11.getId()).size());
|
||||
mangaService.deleteAllMangas();
|
||||
readerService.deleteAllReaders();
|
||||
creatorService.deleteAllCreators();
|
||||
|
Loading…
Reference in New Issue
Block a user