diff --git a/src/main/java/ru/redrise/marinesco/BookController.java b/src/main/java/ru/redrise/marinesco/BookController.java new file mode 100644 index 0000000..63d46aa --- /dev/null +++ b/src/main/java/ru/redrise/marinesco/BookController.java @@ -0,0 +1,34 @@ +package ru.redrise.marinesco; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; + +import lombok.extern.slf4j.Slf4j; +import ru.redrise.marinesco.data.InpEntryRepository; +import ru.redrise.marinesco.library.Author; +import ru.redrise.marinesco.library.InpEntry; + +@Slf4j +@Controller +@RequestMapping("/book") +public class BookController { + InpEntryRepository inpEntryRepository; + + public BookController(InpEntryRepository inpEntryRepository){ + this.inpEntryRepository = inpEntryRepository; + } + + @GetMapping("/{bookId}") + public String getPage(@PathVariable("bookId") Long bookId, Model model) { + InpEntry book = inpEntryRepository.findById(bookId).orElse(null); + if (book == null){ + model.addAttribute("Error", "Not found"); + return "book"; + } + model.addAttribute("book", book); + return "book"; + } +} diff --git a/src/main/java/ru/redrise/marinesco/RootController.java b/src/main/java/ru/redrise/marinesco/RootController.java index 21757ce..db3ba4d 100644 --- a/src/main/java/ru/redrise/marinesco/RootController.java +++ b/src/main/java/ru/redrise/marinesco/RootController.java @@ -2,12 +2,20 @@ package ru.redrise.marinesco; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import lombok.extern.slf4j.Slf4j; + +@Slf4j @Controller +@RequestMapping("/") public class RootController { - @GetMapping("/") - public String home(){ + @GetMapping + public String getPage(@ModelAttribute("search") String text) { + // TODO: SEARCH PAGE + CONTROLLER + log.info(text); return "root"; } } diff --git a/src/main/java/ru/redrise/marinesco/library/AthorByIdConverter.java b/src/main/java/ru/redrise/marinesco/library/AthorByIdConverter.java new file mode 100644 index 0000000..abe6f3c --- /dev/null +++ b/src/main/java/ru/redrise/marinesco/library/AthorByIdConverter.java @@ -0,0 +1,21 @@ +package ru.redrise.marinesco.library; + +import org.springframework.core.convert.converter.Converter; +import org.springframework.stereotype.Component; + +import ru.redrise.marinesco.data.AuthorRepository; + +@Component +public class AthorByIdConverter implements Converter{ + + private AuthorRepository authorRepository; + + public AthorByIdConverter(AuthorRepository authorRepository){ + this.authorRepository = authorRepository; + } + + @Override + public Author convert(Long id) { + return authorRepository.findById(id).orElse(null); + } +} \ No newline at end of file diff --git a/src/main/java/ru/redrise/marinesco/library/GenreByIdConverter.java b/src/main/java/ru/redrise/marinesco/library/GenreByIdConverter.java new file mode 100644 index 0000000..1e134c8 --- /dev/null +++ b/src/main/java/ru/redrise/marinesco/library/GenreByIdConverter.java @@ -0,0 +1,21 @@ +package ru.redrise.marinesco.library; + +import org.springframework.core.convert.converter.Converter; +import org.springframework.stereotype.Component; + +import ru.redrise.marinesco.data.GenreRepository; + +@Component +public class GenreByIdConverter implements Converter{ + + private GenreRepository genreRepository; + + public GenreByIdConverter(GenreRepository genreRepository){ + this.genreRepository = genreRepository; + } + + @Override + public Genre convert(String id) { + return genreRepository.findById(id).orElse(null); + } +} \ No newline at end of file diff --git a/src/main/java/ru/redrise/marinesco/library/InpxScanner.java b/src/main/java/ru/redrise/marinesco/library/InpxScanner.java index f2febcf..4b715e6 100644 --- a/src/main/java/ru/redrise/marinesco/library/InpxScanner.java +++ b/src/main/java/ru/redrise/marinesco/library/InpxScanner.java @@ -133,6 +133,9 @@ public class InpxScanner implements Runnable { } private void parseInp(File inpxFile) throws Exception { + log.warn("REMOVE TEMPORARY SOLUTION - BREAKER"); + log.warn("REMOVE TEMPORARY SOLUTION - BREAKER"); + log.warn("REMOVE TEMPORARY SOLUTION - BREAKER"); boolean breaker = false; try (ZipInputStream zipInputStream = new ZipInputStream(new FileInputStream(inpxFile))) { diff --git a/src/main/resources/static/styles/styles.css b/src/main/resources/static/styles/styles.css index 0ebad29..823cccb 100644 --- a/src/main/resources/static/styles/styles.css +++ b/src/main/resources/static/styles/styles.css @@ -8,6 +8,10 @@ src: url('/styles/Arimo-VariableFont_wght.ttf'); } +html{ + line-height: 1.5; +} + body { font-family: Arimo; background-color: #212121; diff --git a/src/main/resources/templates/book.html b/src/main/resources/templates/book.html new file mode 100644 index 0000000..ed58289 --- /dev/null +++ b/src/main/resources/templates/book.html @@ -0,0 +1,40 @@ + + + + + Marinesco + + + + + + +
+
+
+ +
+
+
Authors: +
+ +
+
Genres: +
+ +
+
+
+
+
+
+

+ +

+
+
+
+
+ + + \ No newline at end of file diff --git a/src/main/resources/templates/root.html b/src/main/resources/templates/root.html index d850e53..954dc0c 100644 --- a/src/main/resources/templates/root.html +++ b/src/main/resources/templates/root.html @@ -4,7 +4,7 @@ Marinesco - + @@ -16,7 +16,14 @@
/profile
/manage_users
/settings +
/book/59992766
H2 +
+
+
+ + +