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