- Timestamp:
- 09/22/22 15:35:07 (2 years ago)
- Branches:
- master
- Children:
- 3692f0d
- Parents:
- 5506b50
- Location:
- src/main
- Files:
-
- 41 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/mk/ukim/finki/db/library/config/DataInitializer.java
r5506b50 re5de1b0 1 //package mk.ukim.finki.db.library.config; 2 // 3 //import mk.ukim.finki.db.library.model.Book; 4 //import mk.ukim.finki.db.library.model.Person; 5 //import mk.ukim.finki.db.library.model.Writer; 6 //import mk.ukim.finki.db.library.service.BookService; 7 //import mk.ukim.finki.db.library.service.LibraryService; 8 //import mk.ukim.finki.db.library.service.UserService; 9 //import mk.ukim.finki.db.library.service.WriterService; 10 //import org.springframework.stereotype.Component; 11 // 12 //import javax.annotation.PostConstruct; 13 //import java.util.Calendar; 14 //import java.util.Date; 15 // 16 //@Component 17 //public class DataInitializer { 18 // 19 // private final UserService userService; 20 // private final BookService bookService; 21 // private final WriterService writerService; 22 // private final LibraryService libraryService; 23 // 24 // public DataInitializer(UserService userService, BookService bookService, WriterService writerService, LibraryService libraryService) { 25 // this.userService = userService; 26 // this.bookService = bookService; 27 // this.writerService = writerService; 28 // this.libraryService = libraryService; 29 // } 30 // 31 // @PostConstruct 32 // public void initData(){ 33 // Person member = this.userService.register("MemberName", "MemberSurname", new Date(2010, Calendar.JANUARY,1), 34 // "MemberAddres","MemeberTowen", "071/654 521", "memberemail@hotmail.com", "baza123!"); 35 // 36 // Writer writer = this.writerService.create("Dan Brown"); 37 // 38 // Book book = this.bookService.create("Inferno", 10, true, 30, 50); 39 // 40 // 41 // } 42 //} 1 package mk.ukim.finki.db.library.config; 2 3 import mk.ukim.finki.db.library.model.*; 4 import mk.ukim.finki.db.library.service.*; 5 import org.springframework.stereotype.Component; 6 7 import javax.annotation.PostConstruct; 8 import java.util.List; 9 10 @Component 11 public class DataInitializer { 12 13 private final UserService userService; 14 private final BookService bookService; 15 private final WriterService writerService; 16 private final GenreService genreService; 17 private final LibraryService libraryService; 18 private final SchoolTypeService schoolTypeService; 19 private final MembershipTypeService membershipTypeService; 20 private final RoomService roomService; 21 private final PriceListService priceListService; 22 23 public DataInitializer(UserService userService, BookService bookService, WriterService writerService, LibraryService libraryService, GenreService genreService, LibraryService libraryService1, SchoolTypeService schoolTypeService, MembershipTypeService membershipTypeService, RoomService roomService, PriceListService priceListService) { 24 this.userService = userService; 25 this.bookService = bookService; 26 this.writerService = writerService; 27 this.genreService = genreService; 28 this.libraryService = libraryService1; 29 this.schoolTypeService = schoolTypeService; 30 this.membershipTypeService = membershipTypeService; 31 this.roomService = roomService; 32 this.priceListService = priceListService; 33 } 34 35 @PostConstruct 36 public void initData(){ 37 Person member = this.userService.register("MemberName", "MemberSurname", 38 "MemberAddres", "MemberTown", "071/111/222", "memberemail@hotmail.com", "baza123!"); 39 40 //LIBRARIES 41 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"); 44 45 //GENRES 46 Genre genre = this.genreService.create(11L, "thriller"); 47 this.genreService.create(12L, "comedy"); 48 this.genreService.create(13L, "action"); 49 this.genreService.create(14L, "romance"); 50 this.genreService.create(15L, "history"); 51 this.genreService.create(16L, "teenage"); 52 53 //WRITERS 54 Writer writer = this.writerService.create(111L, "Dan Brown"); 55 this.writerService.create(112L, "Linwood Barclay"); 56 this.writerService.create(113L, "Sebastian Fizek"); 57 this.writerService.create(114L, "Julie James"); 58 59 //BOOKS 60 //this.bookService.createB(1112L,"Seat 7A", 5, true, 30, 50, List.of(1L), List.of(3L), 1L); 61 this.bookService.create(1111L, "Inferno",3, true, 30, 50); 62 this.bookService.create(1112L, "Seat 7A",2, true, 30, 50); 63 this.bookService.create(1113L, "No time for goodbye",0, false, 30, 50); 64 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 } 70 71 //SCHOOLTYPES 72 this.schoolTypeService.create(1L,"PRIMARY SCHOOL"); 73 this.schoolTypeService.create(2L,"HIGH SCHOOL"); 74 this.schoolTypeService.create(3L,"OTHER"); 75 76 //MEMBERSHIPTYPES 77 this.membershipTypeService.create(1L, "WEEKLY"); 78 this.membershipTypeService.create(2L, "MONTHLY"); 79 this.membershipTypeService.create(3L, "YEARLY"); 80 81 //PRICELIST 82 this.priceListService.create(1L, 70); //weekly - other 83 this.priceListService.create(2L, 100); //monthy - other 84 this.priceListService.create(3L, 300); //yearly - other 85 this.priceListService.create(5L, 150); //yearly - primary school 86 this.priceListService.create(6L, 250); //yearly - high school 87 88 //ROOMS 89 this.roomService.create(1L, "Room 1", 30, 8); 90 this.roomService.create(2L, "Room 2", 20, 5); 91 this.roomService.create(3L, "Room 3", 60, 60); 92 93 } 94 95 } -
src/main/java/mk/ukim/finki/db/library/model/Book.java
r5506b50 re5de1b0 3 3 import javax.persistence.*; 4 4 import java.util.List; 5 import java.util.Optional; 5 6 6 7 @Entity … … 9 10 public Book(){} 10 11 11 // public Book(String bookName, int bookNumber, boolean isFree, int bookPrice, int bookPriceLate) { 12 // this.bookName = bookName; 13 // this.bookNumber = bookNumber; 14 // this.isFree = isFree; 15 // this.bookPrice = bookPrice; 16 // this.bookPriceLate = bookPriceLate; 17 // } 12 public Book(String bookName, int bookNumber, boolean isFree, int bookPrice, int bookPriceLate, List<Long> genreIds, List<Long> writerIds, Long libraryId){} 18 13 19 // public Book(String bookName, int bookNumber, boolean isFree, int bookPrice, int bookPriceLate, List<Genre> genres, List<Writer> writers 20 // , BookGenre bookGenre, LibrariesEnum librariesEnum) { 21 // this.bookName = bookName; 22 // this.bookNumber = bookNumber; 23 // this.isFree = isFree; 24 // this.bookPrice = bookPrice; 25 // this.bookPriceLate = bookPriceLate; 26 // this.genre = (Genre) genres; 27 // this.writers = writers; 28 // this.bookGenre = bookGenre; 29 // this.librariesEnum = librariesEnum; 30 // } 31 // 32 // public Book(String bookName, int bookNumber, boolean isFree, int bookPrice, int bookPriceLate, List<Writer> writers 33 // , BookGenre bookGenre, LibrariesEnum librariesEnum) { 34 // this.bookName = bookName; 35 // this.bookNumber = bookNumber; 36 // this.isFree = isFree; 37 // this.bookPrice = bookPrice; 38 // this.bookPriceLate = bookPriceLate; 39 // this.writers = writers; 40 // this.bookGenre = bookGenre; 41 // this.librariesEnum = librariesEnum; 42 // } 43 44 public Book(String bookName, int bookNumber, boolean isFree, int bookPrice, int bookPriceLate, BookGenre bookGenre, LibrariesEnum librariesEnum) { 14 public Book(Long id, String bookName, int bookNumber, boolean isFree, int bookPrice, int bookPriceLate) { 45 15 this.bookName = bookName; 46 16 this.bookNumber = bookNumber; … … 48 18 this.bookPrice = bookPrice; 49 19 this.bookPriceLate = bookPriceLate; 50 this.bookGenre = bookGenre; 51 this.librariesEnum = librariesEnum; 20 } 21 22 public Book(String bookName, int bookNumber, boolean isFree, int bookPrice, int bookPriceLate, List<Genre> genres, List<Writer> writers) { 23 this.bookName = bookName; 24 this.bookNumber = bookNumber; 25 this.isFree = isFree; 26 this.bookPrice = bookPrice; 27 this.bookPriceLate = bookPriceLate; 28 this.genre = (Genre) genres; 29 this.writers = writers; 30 } 31 32 public Book(Long id,String bookName, int bookNumber, boolean isFree, int bookPrice, int bookPriceLate, List<Genre> genres, List<Writer> writers, Library library) { 33 this.id = id; 34 this.bookName = bookName; 35 this.bookNumber = bookNumber; 36 this.isFree = isFree; 37 this.bookPrice = bookPrice; 38 this.bookPriceLate = bookPriceLate; 39 this.genre = (Genre) genres; 40 this.writers = writers; 41 this.library = library; 42 } 43 44 public Book(String bookName, int bookNumber, boolean isFree, int bookPrice, int bookPriceLate, Library library) { 45 this.bookName = bookName; 46 this.bookNumber = bookNumber; 47 this.isFree = isFree; 48 this.bookPrice = bookPrice; 49 this.bookPriceLate = bookPriceLate; 50 this.library = library; 52 51 } 53 52 … … 66 65 private int bookPriceLate; 67 66 68 @Enumerated69 private BookGenre bookGenre;70 71 @Enumerated72 private LibrariesEnum librariesEnum;73 74 67 @ManyToOne 75 68 private Library library; … … 83 76 public Library getLibrary() { 84 77 return library; 78 } 79 80 public void setId(Long id) { 81 this.id = id; 85 82 } 86 83 … … 117 114 } 118 115 119 public String getGenreOfBook(){return bookGenre.toString();}120 121 public String getLibraryOfBook(){return librariesEnum.toString();}122 123 116 public void setBookNumber(int bookNumber) { 124 117 bookNumber = bookNumber; -
src/main/java/mk/ukim/finki/db/library/model/Genre.java
r5506b50 re5de1b0 3 3 import javax.persistence.Entity; 4 4 import javax.persistence.GeneratedValue; 5 import javax.persistence.GenerationType; 5 6 import javax.persistence.Id; 6 7 … … 10 11 public Genre(){} 11 12 12 public Genre(String genreName) { 13 public Genre(Long id, String genreName) { 14 this.id = id; 13 15 this.genreName = genreName; 14 16 } 15 17 16 18 @Id 17 @GeneratedValue 19 @GeneratedValue(strategy = GenerationType.IDENTITY) 18 20 private Long id; 19 21 20 22 private String genreName; 23 24 public Long getId() { 25 return id; 26 } 21 27 22 28 public String getGenreName() { -
src/main/java/mk/ukim/finki/db/library/model/Library.java
r5506b50 re5de1b0 15 15 } 16 16 17 public Library(String libraryName, String libraryCity) { 17 public Library(Long id, String libraryName, String libraryCity) { 18 this.id = id; 18 19 this.libraryName = libraryName; 19 20 this.libraryCity = libraryCity; -
src/main/java/mk/ukim/finki/db/library/model/Member.java
r5506b50 re5de1b0 33 33 private Library library; 34 34 35 public Member(String name, String surname, Date birth,String address, String town, String phoneNumber, String email, String encryptedPasswords) {36 super(name, surname, birth,address, town, phoneNumber, email, encryptedPasswords);35 public Member(String name, String surname, String address, String town, String phoneNumber, String email, String encryptedPasswords) { 36 super(name, surname,address, town, phoneNumber, email, encryptedPasswords); 37 37 } 38 38 -
src/main/java/mk/ukim/finki/db/library/model/MembershipType.java
r5506b50 re5de1b0 8 8 public MembershipType(){} 9 9 10 public MembershipType( String membershipTypeName) {10 public MembershipType(Long id, String membershipTypeName) { 11 11 this.membershipTypeName = membershipTypeName; 12 12 } 13 13 14 14 @Id 15 @GeneratedValue 15 @GeneratedValue(strategy = GenerationType.IDENTITY) 16 16 private Long id; 17 17 -
src/main/java/mk/ukim/finki/db/library/model/Person.java
r5506b50 re5de1b0 25 25 public Person(){ } 26 26 27 public Person(String name, String surname, Date birthDate,String address, String town, String phoneNumber, String email, String password) {27 public Person(String name, String surname, String address, String town, String phoneNumber, String email, String password) { 28 28 this.name = name; 29 29 this.surname = surname; 30 this.birthDate = birthDate;31 30 this.address = address; 32 31 this.town = town; -
src/main/java/mk/ukim/finki/db/library/model/PriceList.java
r5506b50 re5de1b0 3 3 import javax.persistence.Entity; 4 4 import javax.persistence.GeneratedValue; 5 import javax.persistence.GenerationType; 5 6 import javax.persistence.Id; 6 7 … … 10 11 public PriceList(){} 11 12 12 public PriceList( int price) {13 public PriceList(Long id, int price) { 13 14 this.price = price; 14 15 } 15 16 16 17 @Id 17 @GeneratedValue 18 @GeneratedValue(strategy = GenerationType.IDENTITY) 18 19 private Long id; 19 20 -
src/main/java/mk/ukim/finki/db/library/model/Room.java
r5506b50 re5de1b0 1 1 package mk.ukim.finki.db.library.model; 2 2 3 import javax.persistence.Entity; 4 import javax.persistence.GeneratedValue; 5 import javax.persistence.Id; 6 import javax.persistence.ManyToOne; 3 import javax.persistence.*; 7 4 8 5 @Entity … … 11 8 public Room(){} 12 9 13 public Room(int places, int freePlaces) { 10 public Room(Long id, String name, int places, int freePlaces) { 11 this.id = id; 12 this.name = name; 14 13 this.places = places; 15 14 this.freePlaces = freePlaces; … … 21 20 22 21 @Id 23 @GeneratedValue 22 @GeneratedValue(strategy = GenerationType.IDENTITY) 24 23 private Long id; 24 25 private String name; 25 26 26 27 private int places; -
src/main/java/mk/ukim/finki/db/library/model/SchoolType.java
r5506b50 re5de1b0 3 3 import javax.persistence.Entity; 4 4 import javax.persistence.GeneratedValue; 5 import javax.persistence.GenerationType; 5 6 import javax.persistence.Id; 6 7 … … 10 11 public SchoolType(){} 11 12 12 public SchoolType( String schoolTypeName) {13 public SchoolType(Long id, String schoolTypeName) { 13 14 this.schoolTypeName = schoolTypeName; 14 15 } 15 16 16 17 @Id 17 @GeneratedValue 18 @GeneratedValue(strategy = GenerationType.IDENTITY) 18 19 private Long id; 19 20 -
src/main/java/mk/ukim/finki/db/library/model/Writer.java
r5506b50 re5de1b0 3 3 import javax.persistence.Entity; 4 4 import javax.persistence.GeneratedValue; 5 import javax.persistence.GenerationType; 5 6 import javax.persistence.Id; 6 7 … … 10 11 public Writer(){} 11 12 12 public Writer(String writerName) { 13 public Writer(Long id, String writerName) { 14 this.id = id; 13 15 this.writerName = writerName; 14 16 } 15 17 16 18 @Id 17 @GeneratedValue 19 @GeneratedValue(strategy = GenerationType.IDENTITY) 18 20 private Long id; 19 21 20 22 private String writerName; 23 24 public Long getId() { 25 return id; 26 } 21 27 22 28 public String getWriterName() { -
src/main/java/mk/ukim/finki/db/library/service/BookService.java
r5506b50 re5de1b0 3 3 import mk.ukim.finki.db.library.model.Book; 4 4 import mk.ukim.finki.db.library.model.BookGenre; 5 import mk.ukim.finki.db.library.model.LibrariesEnum;6 5 7 6 import java.util.List; … … 13 12 Book findById(Long id); 14 13 15 Book create( String bookName, int bookNumber, boolean isFree, int bookPrice, int bookPriceLate, BookGenre bookGenre, LibrariesEnum librariesEnum); //, List<Long> genreIds, List<Long> writerIds14 Book create(Long id, String bookName, int bookNumber, boolean isFree, int bookPrice, int bookPriceLate); //, List<Long> genreIds, List<Long> writerIds 16 15 17 Book update(Long id, String bookName, int bookNumber, boolean isFree, int bookPrice, int bookPriceLate, List<Long> genreIds, List<Long> writerIds );16 Book update(Long id, String bookName, int bookNumber, boolean isFree, int bookPrice, int bookPriceLate, List<Long> genreIds, List<Long> writerIds, Long libraryId); 18 17 19 18 Book delete(Long id); 20 19 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 } -
src/main/java/mk/ukim/finki/db/library/service/GenreService.java
r5506b50 re5de1b0 11 11 List<Genre> listAll(); 12 12 13 Genre create( String name);13 Genre create(Long id, String name); 14 14 } -
src/main/java/mk/ukim/finki/db/library/service/LibraryService.java
r5506b50 re5de1b0 11 11 List<Library> listAll(); 12 12 13 Library create( String libraryName, String libraryCity);13 Library create(Long id, String libraryName, String libraryCity); 14 14 15 15 Library update(Long id, String libraryName, String libraryCity); -
src/main/java/mk/ukim/finki/db/library/service/MembershipTypeService.java
r5506b50 re5de1b0 11 11 List<MembershipType> listAll(); 12 12 13 MembershipType create( String name);13 MembershipType create(Long id, String name); 14 14 } -
src/main/java/mk/ukim/finki/db/library/service/PriceListService.java
r5506b50 re5de1b0 11 11 List<PriceList> listAll(); 12 12 13 PriceList create( int price);13 PriceList create(Long id, int price); 14 14 } -
src/main/java/mk/ukim/finki/db/library/service/RoomService.java
r5506b50 re5de1b0 11 11 List<Room> listAll(); 12 12 13 Room create( int name);13 Room create(Long id, String name, int places, int freePlaces); 14 14 } -
src/main/java/mk/ukim/finki/db/library/service/SchoolTypeService.java
r5506b50 re5de1b0 11 11 List<SchoolType> listAll(); 12 12 13 SchoolType create( String name);13 SchoolType create(Long id, String name); 14 14 } -
src/main/java/mk/ukim/finki/db/library/service/UserService.java
r5506b50 re5de1b0 3 3 import mk.ukim.finki.db.library.model.Person; 4 4 5 import java.util.Date;6 7 5 public interface UserService { 8 6 9 Person register(String name, String surname, Date birthDate,String address, String town, String phoneNumber,10 7 Person register(String name, String surname, String address, String town, String phoneNumber, 8 String email, String password); 11 9 12 10 Person login(String username, String password); -
src/main/java/mk/ukim/finki/db/library/service/WriterService.java
r5506b50 re5de1b0 11 11 List<Writer> listAll(); 12 12 13 Writer create( String name);13 Writer create(Long id, String name); 14 14 } -
src/main/java/mk/ukim/finki/db/library/service/impl/BookServiceImpl.java
r5506b50 re5de1b0 3 3 import mk.ukim.finki.db.library.model.*; 4 4 import mk.ukim.finki.db.library.model.exception.InvalidBookIdException; 5 import mk.ukim.finki.db.library.model.exception.LibraryNotFoundException; 5 6 import mk.ukim.finki.db.library.repository.BookRepository; 6 7 import mk.ukim.finki.db.library.repository.GenreRepository; 8 import mk.ukim.finki.db.library.repository.LibraryRepository; 7 9 import mk.ukim.finki.db.library.repository.WriterRepository; 8 10 import mk.ukim.finki.db.library.service.BookService; 9 import mk.ukim.finki.db.library.service.LibraryService;10 11 import org.springframework.stereotype.Service; 11 12 12 13 import java.util.List; 13 import java.util. stream.Collectors;14 import java.util.Optional; 14 15 15 16 @Service … … 19 20 private final WriterRepository writerRepository; 20 21 private final GenreRepository genreRepository; 22 private final LibraryRepository libraryRepository; 21 23 22 public BookServiceImpl(BookRepository bookRepository, WriterRepository writerRepository, GenreRepository genreRepository, Library Service libraryService) {24 public BookServiceImpl(BookRepository bookRepository, WriterRepository writerRepository, GenreRepository genreRepository, LibraryRepository libraryRepository) { 23 25 this.bookRepository = bookRepository; 24 26 this.writerRepository = writerRepository; 25 27 this.genreRepository = genreRepository; 28 this.libraryRepository = libraryRepository; 26 29 } 27 30 … … 37 40 38 41 @Override 39 public Book create(String bookName, int bookNumber, boolean isFree, int bookPrice, int bookPriceLate, 40 BookGenre bookGenre, LibrariesEnum librariesEnum) { //, List<Long> genreIds, List<Long> writerIds 42 public Book create(Long id, String bookName, int bookNumber, boolean isFree, int bookPrice, int bookPriceLate) { //, List<Long> genreIds, List<Long> writerIds 41 43 //List<Genre> genres = this.genreRepository.findAllById(genreIds); 42 44 //List<Writer> writers = this.writerRepository.findAllById(writerIds); 43 Book book = new Book( bookName, bookNumber, isFree, bookPrice, bookPriceLate, bookGenre, librariesEnum); //, genres, writers45 Book book = new Book(id, bookName, bookNumber, isFree, bookPrice, bookPriceLate); //, genres, writers 44 46 return this.bookRepository.save(book); 45 47 } 46 48 47 49 @Override 48 public Book update(Long id, String bookName, int bookNumber, boolean isFree, int bookPrice, int bookPriceLate, List<Long> genreIds, List<Long> writerIds ) {50 public Book update(Long id, String bookName, int bookNumber, boolean isFree, int bookPrice, int bookPriceLate, List<Long> genreIds, List<Long> writerIds, Long libraryId) { 49 51 Book book = this.findById(id); 50 52 book.setBookName(bookName); … … 60 62 book.setWriters(writers); 61 63 64 Library library = this.libraryRepository.findById(libraryId).orElseThrow(() -> new LibraryNotFoundException(libraryId)); 65 book.setLibrary(library); 66 62 67 return this.bookRepository.save(book); 63 68 } … … 70 75 } 71 76 77 @Override 78 public Book createB(Long id, String bookName, int bookNumber, boolean isFree, int bookPrice, int bookPriceLate, List<Long> genreIds, List<Long> writerIds, Long libraryId) { 79 List<Genre> genres = this.genreRepository.findAllById(genreIds); 80 List<Writer> writers = this.writerRepository.findAllById(genreIds); 81 82 Book book = new Book(); 83 book.setId(id); 84 book.setBookName(bookName); 85 book.setBookNumber(bookNumber); 86 book.setFree(isFree); 87 book.setBookPrice(bookPrice); 88 book.setBookPriceLate(bookPriceLate); 89 book.setGenre((Genre) genres); 90 book.setWriters(writers); 91 92 //book = new Book(bookName, bookNumber, isFree, bookPrice, bookPriceLate, genreIds, writerIds, libraryId); 93 return null; 94 } 72 95 73 96 //in bookRepository -
src/main/java/mk/ukim/finki/db/library/service/impl/GenreServiceImpl.java
r5506b50 re5de1b0 29 29 30 30 @Override 31 public Genre create( String name) {32 Genre genre = new Genre( name);31 public Genre create(Long id, String name) { 32 Genre genre = new Genre(id, name); 33 33 return this.genreRepository.save(genre); 34 34 } -
src/main/java/mk/ukim/finki/db/library/service/impl/LibraryServiceImpl.java
r5506b50 re5de1b0 25 25 26 26 @Override 27 public Library create( String libraryName, String libraryCity) {28 Library library = new Library( libraryName, libraryCity);27 public Library create(Long id, String libraryName, String libraryCity) { 28 Library library = new Library(id, libraryName, libraryCity); 29 29 return this.libraryRepository.save(library); 30 30 } -
src/main/java/mk/ukim/finki/db/library/service/impl/MembershipTypeServiceImpl.java
r5506b50 re5de1b0 30 30 31 31 @Override 32 public MembershipType create( String name) {33 MembershipType membershipType = new MembershipType( name);32 public MembershipType create(Long id, String name) { 33 MembershipType membershipType = new MembershipType(id, name); 34 34 return this.membershipTypeRepository.save(membershipType); 35 35 } -
src/main/java/mk/ukim/finki/db/library/service/impl/PriceListServiceImpl.java
r5506b50 re5de1b0 29 29 30 30 @Override 31 public PriceList create( int price) {32 PriceList priceList = new PriceList( price);31 public PriceList create(Long id, int price) { 32 PriceList priceList = new PriceList(id, price); 33 33 return this.priceListRepository.save(priceList); 34 34 } -
src/main/java/mk/ukim/finki/db/library/service/impl/RoomServiceImpl.java
r5506b50 re5de1b0 29 29 30 30 @Override 31 public Room create( int room) {32 Room room Num = new Room(room);33 return this.roomRepository.save(room Num);31 public Room create(Long id, String name, int places, int freePlaces) { 32 Room room = new Room(id, name, places, freePlaces); 33 return this.roomRepository.save(room); 34 34 } 35 35 } -
src/main/java/mk/ukim/finki/db/library/service/impl/SchoolTypeServiceImpl.java
r5506b50 re5de1b0 29 29 30 30 @Override 31 public SchoolType create( String name) {32 SchoolType schoolType = new SchoolType( name);31 public SchoolType create(Long id, String name) { 32 SchoolType schoolType = new SchoolType(id, name); 33 33 return this.schoolTypeRepository.save(schoolType); 34 34 } -
src/main/java/mk/ukim/finki/db/library/service/impl/UserServiceImpl.java
r5506b50 re5de1b0 2 2 3 3 import mk.ukim.finki.db.library.model.Person; 4 import mk.ukim.finki.db.library.model.exception.InvalidArgumentsException;5 4 import mk.ukim.finki.db.library.model.exception.InvalidUserCredentialsException; 6 5 import mk.ukim.finki.db.library.model.exception.InvalidUsernameOrPasswordException; … … 10 9 import org.springframework.stereotype.Service; 11 10 12 import java.util.Date;13 11 14 12 @Service … … 17 15 private final UserRepository userRepository; 18 16 19 public UserServiceImpl( UserRepository userRepository) {17 public UserServiceImpl(MemberRepository userRepository) { 20 18 this.userRepository = userRepository; 21 19 } 22 20 23 21 @Override 24 public Person register(String name, String surname, Date birthDate,String address, String town, String phoneNumber,25 22 public Person register(String name, String surname, String address, String town, String phoneNumber, 23 String email, String password) { //SchoolType schoolType, MembershipType membershipType, 26 24 27 Person member = new Person(name, surname, birthDate,address, town, phoneNumber, email, password);25 Person member = new Person(name, surname, address, town, phoneNumber, email, password); 28 26 29 27 return this.userRepository.save(member); -
src/main/java/mk/ukim/finki/db/library/service/impl/WriterServiceImpl.java
r5506b50 re5de1b0 30 30 31 31 @Override 32 public Writer create( String name) {33 Writer writer = new Writer( name);32 public Writer create(Long id, String name) { 33 Writer writer = new Writer(id, name); 34 34 return this.writerRepository.save(writer); 35 35 } -
src/main/java/mk/ukim/finki/db/library/web/BookController.java
r5506b50 re5de1b0 6 6 7 7 @Controller 8 @RequestMapping("/book s")8 @RequestMapping("/book") 9 9 public class BookController { 10 10 … … 15 15 } 16 16 17 18 17 19 } -
src/main/java/mk/ukim/finki/db/library/web/LoginController.java
r5506b50 re5de1b0 35 35 request.getParameter("password")); 36 36 request.getSession().setAttribute("username", member); 37 return "redirect:/ home";37 return "redirect:/books"; 38 38 } 39 39 catch (InvalidUserCredentialsException exception) { -
src/main/java/mk/ukim/finki/db/library/web/RegisterController.java
r5506b50 re5de1b0 35 35 public String register(@RequestParam String name, 36 36 @RequestParam String surname, 37 @RequestParam Date birthDate,38 37 @RequestParam String town, 39 38 @RequestParam String address, … … 41 40 @RequestParam String email, 42 41 @RequestParam String password 43 42 ) { 44 43 try{ 45 this.userService.register(name, surname, birthDate,town, address, phoneNumber, email, password);44 this.userService.register(name, surname, town, address, phoneNumber, email, password); 46 45 return "redirect:/login"; 47 46 } catch (InvalidArgumentsException | PasswordsDoNotMatchException exception) { -
src/main/resources/application.properties
r5506b50 re5de1b0 1 server.port=8081 2 3 spring.profiles.active=prod 4 5 #spring.datasource.hikari.connection-timeout=20000 6 #spring.datasource.hikari.maximum-pool-size=5 7 8 #spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQL95Dialect 9 #spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true 10 # 11 #spring.jpa.hibernate.ddl-auto=update 12 #spring.jpa.show-sql=true 13 # 14 #spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyComponentPathImpl 15 # 16 # 17 #spring.jpa.open-in-view=false 1 server.port=9091 18 2 19 3 # Datasource configuration 20 #spring.datasource.url=jdbc:postgresql://localhost:5432/libraryDB 21 #spring.datasource.username=vintageLibrary 22 #spring.datasource.password=baza123 4 spring.datasource.url=jdbc:postgresql://localhost:5432/parkingDB 5 spring.datasource.username=parkDB 6 spring.datasource.password=parkdb123 7 8 # Default connection pool 9 spring.datasource.hikari.connection-timeout=20000 10 spring.datasource.hikari.maximum-pool-size=5 11 12 spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQL95Dialect 13 spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true 14 15 spring.jpa.hibernate.ddl-auto=update 16 spring.jpa.show-sql=true 17 18 19 spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyComponentPathImpl 20 21 spring.jpa.open-in-view=false -
src/main/resources/templates/book.html
r5506b50 re5de1b0 1 1 <!DOCTYPE html> 2 <html lang="en" >2 <html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"> 3 3 <head> 4 <meta charset="UTF-8"> 5 <title>$Title$</title> 4 <meta charset="UTF-8"/> 5 <title>Books</title> 6 <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> 7 <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> 8 <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script> 9 <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> 6 10 </head> 7 11 <body> 8 $END$ 12 <!--Header--> 13 <nav class="navbar navbar-expand-md navbar-dark bg-dark"> 14 <div class="container"> 15 <a class="navbar-brand" href="/home">ONLINE LIBRARY</a> 16 <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" 17 aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation"> 18 <span class="navbar-toggler-icon"></span> 19 </button> 20 21 <div class="collapse navbar-collapse justify-content-end" id="navbarsExampleDefault"> 22 <ul class="navbar-nav m-auto"> 23 <li class="nav-item m-auto"> 24 <a class="nav-link active" href="/home">ПОЧЕТНА</a> 25 </li> 26 <li class="nav-item m-auto"> 27 <a class="nav-link active" href="/info">ИНФОРМАЦИИ</a> 28 </li> 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> 34 </li> 35 </ul> 36 37 <form class="form-inline my-2 my-lg-0"> 38 <a class="btn btn-primary btn-sm ml-3" href="/logout"> 39 <i class="fa fa-shopping-cart"></i> ОДЈАВИ СЕ 40 </a> 41 </form> 42 </div> 43 </div> 44 </nav> 45 46 <!--Main--> 47 <div class="container"> 48 <section class="jumbotron text-center"> 49 <h2 class="jumbotron-heading">Достапни книги</h2> 50 </section> 51 52 <div th:if="${hasError}"> 53 <h5 class="text-center text-danger" th:text="${error}"></h5> 54 </div> 55 56 <div class="container mb-4"> 57 <div class="row"> 58 <div class="col-12" > 59 <div class="table-responsive"> 60 <table class="table table-striped"> 61 <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> 67 </thead> 68 <tbody> 69 <tr> 70 <td></td> 71 </tr> 72 </tbody> 73 74 </table> 75 </div> 76 </div> 77 </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 </div> 94 95 </div> 96 97 98 99 <!-- Footer --> 100 <footer class="text-black-50 mt-xl-5"> 101 <div class="container"> 102 <div class="row"> 103 <div class="col-md-3 col-lg-1 col-xl-5"> 104 <h5>Contact</h5> 105 <hr class="bg-white mb-2 mt-0 d-inline-block mx-auto w-25"> 106 <ul class="list-unstyled"> 107 <li><i class="fa fa-envelope mr-2"></i>onlinelibrary@library.com</li> 108 <li><i class="fa fa-phone mr-2"></i> + 33 12 14 15 16</li> 109 <li><i class="fa fa-print mr-2"></i> + 33 12 14 15 16</li> 110 </ul> 111 </div> 112 </div> 113 </div> 114 </footer> 9 115 </body> 10 116 </html> -
src/main/resources/templates/guide.html
r5506b50 re5de1b0 30 30 </li> 31 31 <li class="nav-item m-auto"> 32 <a class="nav-link active" href="/ listBooks">ЛИСТА НА КНИГИ</a>32 <a class="nav-link active" href="/book">ЛИСТА НА КНИГИ</a> 33 33 </li> 34 34 </ul> -
src/main/resources/templates/home.html
r5506b50 re5de1b0 28 28 <li class="nav-item m-auto"> 29 29 <a class="nav-link active" href="/guide">УПАТСТВО</a> 30 </li>31 <li class="nav-item m-auto">32 <a class="nav-link active" href="/listBooks">ЛИСТА НА КНИГИ</a>33 30 </li> 34 31 </ul> -
src/main/resources/templates/info.html
r5506b50 re5de1b0 28 28 <li class="nav-item m-auto"> 29 29 <a class="nav-link active" href="/guide">УПАТСТВО</a> 30 </li>31 <li class="nav-item m-auto">32 <a class="nav-link active" href="/listBooks">ЛИСТА НА КНИГИ</a>33 30 </li> 34 31 </ul> -
src/main/resources/templates/library.html
r5506b50 re5de1b0 24 24 </li> 25 25 <li class="nav-item m-auto"> 26 <a class="nav-link active" href=" info.html">ИНФОРМАЦИИ</a>26 <a class="nav-link active" href="/info">ИНФОРМАЦИИ</a> 27 27 </li> 28 28 <li class="nav-item m-auto"> 29 <a class="nav-link active" href="guide.html">УПАТСТВО</a> 30 </li> 31 <li class="nav-item m-auto"> 32 <a class="nav-link active" href="/listBooks">ЛИСТА НА КНИГИ</a> 29 <a class="nav-link active" href="/guide">УПАТСТВО</a> 33 30 </li> 34 31 </ul> -
src/main/resources/templates/login.html
r5506b50 re5de1b0 30 30 <li class="nav-item m-auto"> 31 31 <a class="nav-link active" href="/guide">УПАТСТВО</a> 32 <li class="nav-item m-auto">33 <a class="nav-link active" href="/listBooks">ЛИСТА НА КНИГИ</a>34 </li>35 32 </li> 36 33 </ul> -
src/main/resources/templates/onlinePayment.html
r5506b50 re5de1b0 21 21 </li> 22 22 <li class="nav-item m-auto"> 23 <a class="nav-link active" href=" info.html">ИНФОРМАЦИИ</a>23 <a class="nav-link active" href="/info">ИНФОРМАЦИИ</a> 24 24 </li> 25 25 <li class="nav-item m-auto"> 26 <a class="nav-link active" href=" guide.html">УПАТСТВО</a>26 <a class="nav-link active" href="/guide">УПАТСТВО</a> 27 27 </li> 28 28 <li class="nav-item m-auto"> 29 <a class="nav-link active" href=" listBooks.html">ЛИСТА НА КНИГИ</a>29 <a class="nav-link active" href="/book">ЛИСТА НА КНИГИ</a> 30 30 </li> 31 31 </ul> -
src/main/resources/templates/register.html
r5506b50 re5de1b0 13 13 <nav class="navbar navbar-expand-md navbar-dark bg-dark"> 14 14 <div class="container"> 15 <a class="navbar-brand" href="/home"> ONLINELIBRARY</a>15 <a class="navbar-brand" href="/home">VINTAGE LIBRARY</a> 16 16 <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" 17 17 aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation"> … … 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="info.html">ИНФОРМАЦИИ</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="/listBooks">ЛИСТА НА КНИГИ</a> 30 <a class="nav-link active" href="guide.html">УПАТСТВО</a> 34 31 </li> 35 32 </ul> … … 44 41 </div> 45 42 46 <div class="container">43 <div class="container"> 47 44 48 <form class="form-signin mt-xl-2 col-md-8" method="post" action="/register"> 49 <h2 class="form-signin-heading">Регистрација</h2> 50 <br> 51 <p> 52 <label for="name" class="sr-only">Име</label> 53 <input type="text" id="name" name="name" class="form-control" placeholder="Name" required="" autofocus=""> 54 </p> 55 <p> 56 <label for="surname" class="sr-only">Презиме</label> 57 <input type="text" id="surname" name="surname" class="form-control" placeholder="Surname" required="" autofocus=""> 58 </p> 59 <p> 60 <label for="birth" class="sr-only">Датум на раѓање</label> 61 <input type="date" id="birth" name="birth" class="form-control" placeholder="Birth" required="" autofocus=""> 62 </p> 63 <p> 64 <label for="town" class="sr-only">Град</label> 65 <input type="text" id="town" name="town" class="form-control" placeholder="Town" required="" autofocus=""> 66 </p> 67 <p> 68 <label for="address" class="sr-only">Адреса</label> 69 <input type="text" id="address" name="address" class="form-control" placeholder="Address" required="" autofocus=""> 70 </p> 71 <p> 72 <label for="phonenumber" class="sr-only">Телефонски број</label> 73 <input type="text" id="phonenumber" name="phonenumber" class="form-control" placeholder="Phonenumber" required="" autofocus=""> 74 </p> 75 <p> 76 <label for="schoolType" class="sr-only">Тип на школо</label> 77 <input type="text" id="schoolType" name="schoolType" class="form-control" placeholder="SchoolType" required="" autofocus=""> 78 </p> 79 <p> 80 <label for="membershipType" class="sr-only">Тип на чланарина</label> 81 <input type="text" id="membershipType" name="membershipType" class="form-control" placeholder="MembershipType" required="" autofocus=""> 82 </p> 83 <p> 84 <label for="email" class="sr-only">Корисничко име</label> 85 <input type="text" id="email" name="email" class="form-control" placeholder="Username" required="" autofocus=""> 86 </p> 87 <p> 88 <label for="password" class="sr-only">Лозинка</label> 89 <input type="password" id="password" name="password" class="form-control" placeholder="Password" required=""> 90 </p> 91 <p> 92 <label for="paymentMethod" class="sr-only">Изберете начин на плаќање</label> 93 <input type="radio" id="paymentMethod" name="paymentMethod" class="form-control" placeholder="IsPayedBook" required=""> 94 </p> 45 <form class="form-signin mt-xl-2 col-md-8" method="post" action="/register"> 46 <h2 class="form-signin-heading">Регистрација</h2> 47 <br> 48 <p> 49 <label for="name" class="sr-only">Име</label> 50 <input type="text" id="name" name="name" class="form-control" placeholder="Name" required="" autofocus=""> 51 </p> 52 <p> 53 <label for="surname" class="sr-only">Презиме</label> 54 <input type="text" id="surname" name="surname" class="form-control" placeholder="Surname" required="" autofocus=""> 55 </p> 56 <!-- <p> 57 <label for="birthDate" class="sr-only">Датум на раѓање</label> 58 <input type="date" id="birthDate" name="birthDate" class="form-control" placeholder="Birth" required="" autofocus=""> 59 </p> --> 60 <p> 61 <label for="town" class="sr-only">Град</label> 62 <input type="text" id="town" name="town" class="form-control" placeholder="Town" required="" autofocus=""> 63 </p> 64 <p> 65 <label for="address" class="sr-only">Адреса</label> 66 <input type="text" id="address" name="address" class="form-control" placeholder="Address" required="" autofocus=""> 67 </p> 68 <p> 69 <label for="phoneNumber" class="sr-only">Телефонски број</label> 70 <input type="text" id="phoneNumber" name="phoneNumber" class="form-control" placeholder="Phonenumber" required="" autofocus=""> 71 </p> 72 <!-- <p> 73 <label for="schoolType" class="sr-only">Тип на школо</label> 74 <input type="text" id="schoolType" name="schoolType" class="form-control" placeholder="SchoolType" required="" autofocus=""> 75 </p> 76 <p> 77 <label for="membershipType" class="sr-only">Тип на чланарина</label> 78 <input type="text" id="membershipType" name="membershipType" class="form-control" placeholder="MembershipType" required="" autofocus=""> 79 </p> --> 80 <p> 81 <label for="email" class="sr-only">Корисничко име</label> 82 <input type="text" id="email" name="email" class="form-control" placeholder="Username" required="" autofocus=""> 83 </p> 84 <p> 85 <label for="password" class="sr-only">Лозинка</label> 86 <input type="password" id="password" name="password" class="form-control" placeholder="Password" required=""> 87 </p> 95 88 96 <button class="btn btn-lg btn-primary btn-block" type="submit">Регистрирај се</button>97 <br>98 <a href="/login" class="btn btn-block btn-light">Веќе имате профил? Најавете се тука!!</a>99 </form>100 89 101 </div> 90 <button class="btn btn-lg btn-primary btn-block" type="submit">Регистрирај се</button> 91 <br> 92 <a href="/login" class="btn btn-block btn-light">Веќе имате профил? Најавете се тука!!</a> 93 </form> 94 95 </div> 102 96 </section> 103 97 … … 110 104 <hr class="bg-white mb-2 mt-0 d-inline-block mx-auto w-25"> 111 105 <ul class="list-unstyled"> 112 <li><i class="fa fa-envelope mr-2"></i> onlinelibrary@library.com</li>106 <li><i class="fa fa-envelope mr-2"></i>vintagelibrary@library.com</li> 113 107 <li><i class="fa fa-phone mr-2"></i> + 33 12 14 15 16</li> 114 108 <li><i class="fa fa-print mr-2"></i> + 33 12 14 15 16</li>
Note:
See TracChangeset
for help on using the changeset viewer.