Changeset 3692f0d
- Timestamp:
- 09/22/22 18:11:04 (2 years ago)
- Branches:
- master
- Children:
- 6791e89
- Parents:
- e5de1b0
- Location:
- src/main
- Files:
-
- 3 added
- 1 deleted
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/mk/ukim/finki/db/library/config/DataInitializer.java
re5de1b0 r3692f0d 6 6 7 7 import javax.annotation.PostConstruct; 8 import java.util.Collections; 8 9 import java.util.List; 9 10 … … 36 37 public void initData(){ 37 38 Person member = this.userService.register("MemberName", "MemberSurname", 38 "MemberAddres ", "MemberTown", "071/111/222", "memberemail@hotmail.com", "baza123!");39 "MemberAddress", "MemberTown", "071/111/222", "memberemail@hotmail.com", "baza123!"); 39 40 40 41 //LIBRARIES 41 42 Library library = this.libraryService.create(1L,"Grigor Prlicev", "Ohrid"); 42 this.libraryService.create(2L, "Braka Miladinovci", "Struga");43 this.libraryService.create(3L, "Braka Miladinovci", "Skopje");43 // this.libraryService.create(2L, "Braka Miladinovci", "Struga"); 44 // this.libraryService.create(3L, "Braka Miladinovci", "Skopje"); 44 45 45 46 //GENRES … … 63 64 this.bookService.create(1113L, "No time for goodbye",0, false, 30, 50); 64 65 65 if("thriller".equals(genreService.findById(1L).toString()) && "Inferno".equals(bookService.findById(1L).getBookName())){ 66 Genre genre1 = genreService.findById(1L); 67 Writer writer1 = writerService.findById(1L); 68 this.bookService.update(1111L, "Inferno",3, true, 30, 50, List.of(genre1.getId()), List.of(writer1.getId()), 1L); 69 } 66 // this.bookService.createB(1114L,"Seat 7A", 5, true, 30, 50, Collections.singletonList(((Long) bookService.findById(2L).getGenre().getId())), 67 // List.of(3L), 1L); 70 68 71 69 //SCHOOLTYPES … … 84 82 this.priceListService.create(3L, 300); //yearly - other 85 83 this.priceListService.create(5L, 150); //yearly - primary school 86 this.priceListService.create(6L, 250); //yearly - high school84 this.priceListService.create(6L, 300); //yearly - high school 87 85 88 86 //ROOMS -
src/main/java/mk/ukim/finki/db/library/model/Library.java
re5de1b0 r3692f0d 33 33 private List<Book> books; 34 34 35 public String getLibraryName() { 36 return libraryName; 37 } 38 35 39 public void addBook(Book book) { 36 40 this.books.add(book); -
src/main/java/mk/ukim/finki/db/library/model/Room.java
re5de1b0 r3692f0d 55 55 this.freePlaces = freePlaces; 56 56 } 57 58 public String getName() { 59 return name; 60 } 57 61 } -
src/main/java/mk/ukim/finki/db/library/repository/BookRepository.java
re5de1b0 r3692f0d 5 5 import org.springframework.stereotype.Repository; 6 6 7 import java.util.List; 8 7 9 @Repository 8 10 public interface BookRepository extends JpaRepository<Book, Long> { 9 11 10 //TODO: listBooksByName , listBooksByNameAndGenre, listBooksByNameAndGenreAndWriter, listBooksByNameAndWriter12 //TODO: listBooksByNameAndGenre, listBooksByNameAndGenreAndWriter, listBooksByNameAndWriter 11 13 //TODO: listBooksByGenre, listBooksByWriter 14 15 List<Book> findByBookName(String bookName); 12 16 } -
src/main/java/mk/ukim/finki/db/library/repository/RoomRepository.java
re5de1b0 r3692f0d 1 1 package mk.ukim.finki.db.library.repository; 2 2 3 import mk.ukim.finki.db.library.model.Book; 3 4 import mk.ukim.finki.db.library.model.Room; 4 5 import org.springframework.data.jpa.repository.JpaRepository; 5 6 import org.springframework.stereotype.Repository; 6 7 8 import java.util.List; 9 7 10 @Repository 8 11 public interface RoomRepository extends JpaRepository<Room, Long> { 12 13 List<Room> findByName(String name); 9 14 } -
src/main/java/mk/ukim/finki/db/library/service/BookService.java
re5de1b0 r3692f0d 20 20 Book createB(Long id, String bookName, int bookNumber, boolean isFree, int bookPrice, int bookPriceLate, List<Long> genreIds, List<Long> writerIds, Long libraryId); //, List<Long> genreIds, List<Long> writerIds 21 21 22 List<Book> findByBookName(String bookName); 22 23 } -
src/main/java/mk/ukim/finki/db/library/service/RoomService.java
re5de1b0 r3692f0d 12 12 13 13 Room create(Long id, String name, int places, int freePlaces); 14 15 List<Room> findByName(String name); 14 16 } -
src/main/java/mk/ukim/finki/db/library/service/impl/BookServiceImpl.java
re5de1b0 r3692f0d 2 2 3 3 import mk.ukim.finki.db.library.model.*; 4 import mk.ukim.finki.db.library.model.exception.InvalidArgumentsException; 4 5 import mk.ukim.finki.db.library.model.exception.InvalidBookIdException; 5 6 import mk.ukim.finki.db.library.model.exception.LibraryNotFoundException; … … 94 95 } 95 96 97 @Override 98 public List<Book> findByBookName(String bookName) { 99 if(bookName == null || bookName.isEmpty()){ 100 throw new InvalidArgumentsException(); 101 } 102 103 return this.bookRepository.findByBookName(bookName); 104 } 105 96 106 //in bookRepository 97 //TODO: listBooksByName , listBooksByNameAndGenre, listBooksByNameAndGenreAndWriter, listBooksByNameAndWriter107 //TODO: listBooksByNameAndGenre, listBooksByNameAndGenreAndWriter, listBooksByNameAndWriter 98 108 //TODO: listBooksByGenre, listBooksByWriter 99 109 } -
src/main/java/mk/ukim/finki/db/library/service/impl/RoomServiceImpl.java
re5de1b0 r3692f0d 1 1 package mk.ukim.finki.db.library.service.impl; 2 2 3 import mk.ukim.finki.db.library.model.Book; 3 4 import mk.ukim.finki.db.library.model.Room; 5 import mk.ukim.finki.db.library.model.exception.InvalidArgumentsException; 4 6 import mk.ukim.finki.db.library.model.exception.InvalidRoomIdException; 5 7 import mk.ukim.finki.db.library.repository.RoomRepository; … … 33 35 return this.roomRepository.save(room); 34 36 } 37 38 @Override 39 public List<Room> findByName(String name) { 40 if(name == null || name.isEmpty()){ 41 throw new InvalidArgumentsException(); 42 } 43 44 return this.roomRepository.findByName(name); 45 } 35 46 } -
src/main/java/mk/ukim/finki/db/library/web/BookController.java
re5de1b0 r3692f0d 1 1 package mk.ukim.finki.db.library.web; 2 2 3 import mk.ukim.finki.db.library.model.Book; 4 import mk.ukim.finki.db.library.model.Genre; 5 import mk.ukim.finki.db.library.model.Library; 6 import mk.ukim.finki.db.library.model.Writer; 3 7 import mk.ukim.finki.db.library.service.BookService; 8 import mk.ukim.finki.db.library.service.GenreService; 9 import mk.ukim.finki.db.library.service.LibraryService; 10 import mk.ukim.finki.db.library.service.WriterService; 4 11 import org.springframework.stereotype.Controller; 12 import org.springframework.ui.Model; 13 import org.springframework.web.bind.annotation.GetMapping; 5 14 import org.springframework.web.bind.annotation.RequestMapping; 15 import org.springframework.web.bind.annotation.RequestParam; 16 17 import java.util.List; 6 18 7 19 @Controller … … 10 22 11 23 private final BookService bookService; 24 private final WriterService writerService; 25 private final GenreService genreService; 26 private final LibraryService libraryService; 12 27 13 public BookController(BookService bookService ) {28 public BookController(BookService bookService, WriterService writerService, GenreService genreService, LibraryService libraryService) { 14 29 this.bookService = bookService; 30 this.writerService = writerService; 31 this.genreService = genreService; 32 this.libraryService = libraryService; 15 33 } 16 34 35 //List<Long> genreIds, List<Long> writerIds, Long libraryId 36 //will show all books that are available in a library 37 @GetMapping 38 public String showBooks(@RequestParam(required = false) String bookName, 39 Model model){ 17 40 41 List<Book> books; 42 //List<Writer> writers; 43 //List<Genre> genres; 44 //List<Library> libraries; 18 45 46 if(bookName == null){ 47 books = this.bookService.listAllBooks(); 48 // writers = this.writerService.listAll(); 49 // genres = this.genreService.listAll(); 50 51 } else { 52 books = this.bookService.findByBookName(bookName); 53 // writers = this.writerService.listAll(); 54 // genres = this.genreService.listAll(); 55 } 56 57 model.addAttribute("books", books); 58 // model.addAttribute("writers", writers); 59 // model.addAttribute("genres", genres); 60 //model.addAttribute("libraries", libraries); 61 62 return "book.html"; 63 } 19 64 } -
src/main/java/mk/ukim/finki/db/library/web/LoginController.java
re5de1b0 r3692f0d 35 35 request.getParameter("password")); 36 36 request.getSession().setAttribute("username", member); 37 return "redirect:/book s";37 return "redirect:/book"; 38 38 } 39 39 catch (InvalidUserCredentialsException exception) { -
src/main/java/mk/ukim/finki/db/library/web/ReservationBookController.java
re5de1b0 r3692f0d 5 5 6 6 @Controller 7 @RequestMapping("/res ervationBook")7 @RequestMapping("/resBook") 8 8 public class ReservationBookController { 9 10 9 11 } -
src/main/resources/templates/book.html
re5de1b0 r3692f0d 25 25 </li> 26 26 <li class="nav-item m-auto"> 27 <a class="nav-link active" href="/ info">ИНФОРМАЦИИ</a>27 <a class="nav-link active" href="/book">КНИГИ</a> 28 28 </li> 29 29 <li class="nav-item m-auto"> 30 <a class="nav-link active" href="/guide">УПАТСТВО</a> 31 </li> 32 <li class="nav-item m-auto"> 33 <a class="nav-link active" href="/book">КНИГИ</a> 30 <a class="nav-link active" href="/room">ПРОСТОРИИ</a> 34 31 </li> 35 32 </ul> … … 47 44 <div class="container"> 48 45 <section class="jumbotron text-center"> 49 <h2 class="jumbotron-heading"> Достапни книги</h2>46 <h2 class="jumbotron-heading"><b>Достапни книги</b></h2> 50 47 </section> 51 48 … … 60 57 <table class="table table-striped"> 61 58 <thead> 62 <th scope="col">Book Name</th> 63 <th scope="col">Price</th> 64 <th scope="col">Price Late</th> 65 <th scope="col">Genre</th> 66 <th scope="col">Library</th> 59 <th scope="col">Име на книга</th> 60 <th scope="col">Број на книга</th> 61 <th scope="col">Цена</th> 62 <th scope="col">Цена со задоцнување</th> 63 <th scope="col">Автор</th> 64 <th scope="col">Жанр</th> 65 <th scope="col"></th> 67 66 </thead> 68 67 <tbody> 69 <tr> 70 <td></td> 68 <tr th:each="book : ${books}" class="book"> 69 <td th:text="${book.getBookName()}"></td> 70 <td th:text="${book.getBookNumber()}"></td> 71 <td th:text="${book.getBookPrice()}"></td> 72 <td th:text="${book.getBookPriceLate()}"></td> 73 <td th:each="writer : ${writers}" th:if="${book.getWriters().contains(writer)}" th:text="${writer.getWriterName()}"></td> 74 <td th:each="genre : ${genres}" th:if="${book.getGenre().contains(genre)}" th:text="${genre.getGenreName()}"></td> 75 <td><a class="btn btn-primary btn-sm ml-3" href="/resBook">Резервација</a> 76 <a class="btn btn-primary btn-sm ml-3" href="/online">Симнување</a></td> 71 77 </tr> 72 78 </tbody> … … 76 82 </div> 77 83 </div> 78 </div>79 80 <div>81 <table>82 83 <!-- For each news you should have one <tr> like below -->84 <tr class="item" th:each="book:${book}">85 <td th:text="${book.bookName}">[book.bookName]</td>86 <td th:text="${book.bookPrice}">[book.bookPrice]</td>87 <td th:text="${book.bookPriceLate}">[book.bookPriceLate]</td>88 <td th:text="${book.getGenreOfBook()}">[book.genreOfBook]</td>89 <td th:text="${book.getLibraryOfBook()}">[book.libraryOfBook]</td>\90 91 </tr>92 </table>93 84 </div> 94 85 -
src/main/resources/templates/register.html
re5de1b0 r3692f0d 25 25 </li> 26 26 <li class="nav-item m-auto"> 27 <a class="nav-link active" href=" info.html">ИНФОРМАЦИИ</a>27 <a class="nav-link active" href="/info">ИНФОРМАЦИИ</a> 28 28 </li> 29 29 <li class="nav-item m-auto"> 30 <a class="nav-link active" href=" guide.html">УПАТСТВО</a>30 <a class="nav-link active" href="/guide">УПАТСТВО</a> 31 31 </li> 32 32 </ul>
Note:
See TracChangeset
for help on using the changeset viewer.