Changeset e5de1b0 for src/main


Ignore:
Timestamp:
09/22/22 15:35:07 (2 years ago)
Author:
Leona <leona@…>
Branches:
master
Children:
3692f0d
Parents:
5506b50
Message:

changes in models & services - 1

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 //}
     1package mk.ukim.finki.db.library.config;
     2
     3import mk.ukim.finki.db.library.model.*;
     4import mk.ukim.finki.db.library.service.*;
     5import org.springframework.stereotype.Component;
     6
     7import javax.annotation.PostConstruct;
     8import java.util.List;
     9
     10@Component
     11public 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  
    33import javax.persistence.*;
    44import java.util.List;
     5import java.util.Optional;
    56
    67@Entity
     
    910    public Book(){}
    1011
    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){}
    1813
    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) {
    4515        this.bookName = bookName;
    4616        this.bookNumber = bookNumber;
     
    4818        this.bookPrice = bookPrice;
    4919        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;
    5251    }
    5352
     
    6665    private int bookPriceLate;
    6766
    68     @Enumerated
    69     private BookGenre bookGenre;
    70 
    71     @Enumerated
    72     private LibrariesEnum librariesEnum;
    73 
    7467    @ManyToOne
    7568    private Library library;
     
    8376    public Library getLibrary() {
    8477        return library;
     78    }
     79
     80    public void setId(Long id) {
     81        this.id = id;
    8582    }
    8683
     
    117114    }
    118115
    119     public String getGenreOfBook(){return bookGenre.toString();}
    120 
    121     public String getLibraryOfBook(){return librariesEnum.toString();}
    122 
    123116    public void setBookNumber(int bookNumber) {
    124117        bookNumber = bookNumber;
  • src/main/java/mk/ukim/finki/db/library/model/Genre.java

    r5506b50 re5de1b0  
    33import javax.persistence.Entity;
    44import javax.persistence.GeneratedValue;
     5import javax.persistence.GenerationType;
    56import javax.persistence.Id;
    67
     
    1011    public Genre(){}
    1112
    12     public Genre(String genreName) {
     13    public Genre(Long id, String genreName) {
     14        this.id = id;
    1315        this.genreName = genreName;
    1416    }
    1517
    1618    @Id
    17     @GeneratedValue
     19    @GeneratedValue(strategy = GenerationType.IDENTITY)
    1820    private Long id;
    1921
    2022    private String genreName;
     23
     24    public Long getId() {
     25        return id;
     26    }
    2127
    2228    public String getGenreName() {
  • src/main/java/mk/ukim/finki/db/library/model/Library.java

    r5506b50 re5de1b0  
    1515    }
    1616
    17     public Library(String libraryName, String libraryCity) {
     17    public Library(Long id, String libraryName, String libraryCity) {
     18        this.id = id;
    1819        this.libraryName = libraryName;
    1920        this.libraryCity = libraryCity;
  • src/main/java/mk/ukim/finki/db/library/model/Member.java

    r5506b50 re5de1b0  
    3333    private Library library;
    3434
    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);
    3737    }
    3838
  • src/main/java/mk/ukim/finki/db/library/model/MembershipType.java

    r5506b50 re5de1b0  
    88    public MembershipType(){}
    99
    10     public MembershipType(String membershipTypeName) {
     10    public MembershipType(Long id, String membershipTypeName) {
    1111        this.membershipTypeName = membershipTypeName;
    1212    }
    1313
    1414    @Id
    15     @GeneratedValue
     15    @GeneratedValue(strategy = GenerationType.IDENTITY)
    1616    private Long id;
    1717
  • src/main/java/mk/ukim/finki/db/library/model/Person.java

    r5506b50 re5de1b0  
    2525    public Person(){ }
    2626
    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) {
    2828        this.name = name;
    2929        this.surname = surname;
    30         this.birthDate = birthDate;
    3130        this.address = address;
    3231        this.town = town;
  • src/main/java/mk/ukim/finki/db/library/model/PriceList.java

    r5506b50 re5de1b0  
    33import javax.persistence.Entity;
    44import javax.persistence.GeneratedValue;
     5import javax.persistence.GenerationType;
    56import javax.persistence.Id;
    67
     
    1011    public PriceList(){}
    1112
    12     public PriceList(int price) {
     13    public PriceList(Long id, int price) {
    1314        this.price = price;
    1415    }
    1516
    1617    @Id
    17     @GeneratedValue
     18    @GeneratedValue(strategy = GenerationType.IDENTITY)
    1819    private Long id;
    1920
  • src/main/java/mk/ukim/finki/db/library/model/Room.java

    r5506b50 re5de1b0  
    11package mk.ukim.finki.db.library.model;
    22
    3 import javax.persistence.Entity;
    4 import javax.persistence.GeneratedValue;
    5 import javax.persistence.Id;
    6 import javax.persistence.ManyToOne;
     3import javax.persistence.*;
    74
    85@Entity
     
    118    public Room(){}
    129
    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;
    1413        this.places = places;
    1514        this.freePlaces = freePlaces;
     
    2120
    2221    @Id
    23     @GeneratedValue
     22    @GeneratedValue(strategy = GenerationType.IDENTITY)
    2423    private Long id;
     24
     25    private String name;
    2526
    2627    private int places;
  • src/main/java/mk/ukim/finki/db/library/model/SchoolType.java

    r5506b50 re5de1b0  
    33import javax.persistence.Entity;
    44import javax.persistence.GeneratedValue;
     5import javax.persistence.GenerationType;
    56import javax.persistence.Id;
    67
     
    1011    public SchoolType(){}
    1112
    12     public SchoolType(String schoolTypeName) {
     13    public SchoolType(Long id, String schoolTypeName) {
    1314        this.schoolTypeName = schoolTypeName;
    1415    }
    1516
    1617    @Id
    17     @GeneratedValue
     18    @GeneratedValue(strategy = GenerationType.IDENTITY)
    1819    private Long id;
    1920
  • src/main/java/mk/ukim/finki/db/library/model/Writer.java

    r5506b50 re5de1b0  
    33import javax.persistence.Entity;
    44import javax.persistence.GeneratedValue;
     5import javax.persistence.GenerationType;
    56import javax.persistence.Id;
    67
     
    1011    public Writer(){}
    1112
    12     public Writer(String writerName) {
     13    public Writer(Long id, String writerName) {
     14        this.id = id;
    1315        this.writerName = writerName;
    1416    }
    1517
    1618    @Id
    17     @GeneratedValue
     19    @GeneratedValue(strategy = GenerationType.IDENTITY)
    1820    private Long id;
    1921
    2022    private String writerName;
     23
     24    public Long getId() {
     25        return id;
     26    }
    2127
    2228    public String getWriterName() {
  • src/main/java/mk/ukim/finki/db/library/service/BookService.java

    r5506b50 re5de1b0  
    33import mk.ukim.finki.db.library.model.Book;
    44import mk.ukim.finki.db.library.model.BookGenre;
    5 import mk.ukim.finki.db.library.model.LibrariesEnum;
    65
    76import java.util.List;
     
    1312    Book findById(Long id);
    1413
    15     Book create(String bookName, int bookNumber, boolean isFree, int bookPrice, int bookPriceLate, BookGenre bookGenre, LibrariesEnum librariesEnum); //, List<Long> genreIds, List<Long> writerIds
     14    Book create(Long id, String bookName, int bookNumber, boolean isFree, int bookPrice, int bookPriceLate); //, List<Long> genreIds, List<Long> writerIds
    1615
    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);
    1817
    1918    Book delete(Long id);
    2019
     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
    2122}
  • src/main/java/mk/ukim/finki/db/library/service/GenreService.java

    r5506b50 re5de1b0  
    1111    List<Genre> listAll();
    1212
    13     Genre create(String name);
     13    Genre create(Long id, String name);
    1414}
  • src/main/java/mk/ukim/finki/db/library/service/LibraryService.java

    r5506b50 re5de1b0  
    1111    List<Library> listAll();
    1212
    13     Library create(String libraryName, String libraryCity);
     13    Library create(Long id, String libraryName, String libraryCity);
    1414
    1515    Library update(Long id, String libraryName, String libraryCity);
  • src/main/java/mk/ukim/finki/db/library/service/MembershipTypeService.java

    r5506b50 re5de1b0  
    1111    List<MembershipType> listAll();
    1212
    13     MembershipType create(String name);
     13    MembershipType create(Long id, String name);
    1414}
  • src/main/java/mk/ukim/finki/db/library/service/PriceListService.java

    r5506b50 re5de1b0  
    1111    List<PriceList> listAll();
    1212
    13     PriceList create(int price);
     13    PriceList create(Long id, int price);
    1414}
  • src/main/java/mk/ukim/finki/db/library/service/RoomService.java

    r5506b50 re5de1b0  
    1111    List<Room> listAll();
    1212
    13     Room create(int name);
     13    Room create(Long id, String name, int places, int freePlaces);
    1414}
  • src/main/java/mk/ukim/finki/db/library/service/SchoolTypeService.java

    r5506b50 re5de1b0  
    1111    List<SchoolType> listAll();
    1212
    13     SchoolType create(String name);
     13    SchoolType create(Long id, String name);
    1414}
  • src/main/java/mk/ukim/finki/db/library/service/UserService.java

    r5506b50 re5de1b0  
    33import mk.ukim.finki.db.library.model.Person;
    44
    5 import java.util.Date;
    6 
    75public interface UserService {
    86
    9     Person register(String name, String surname, Date birthDate, String address, String town, String phoneNumber,
    10                      String email, String password);
     7    Person register(String name, String surname, String address, String town, String phoneNumber,
     8                    String email, String password);
    119
    1210    Person login(String username, String password);
  • src/main/java/mk/ukim/finki/db/library/service/WriterService.java

    r5506b50 re5de1b0  
    1111    List<Writer> listAll();
    1212
    13     Writer create(String name);
     13    Writer create(Long id, String name);
    1414}
  • src/main/java/mk/ukim/finki/db/library/service/impl/BookServiceImpl.java

    r5506b50 re5de1b0  
    33import mk.ukim.finki.db.library.model.*;
    44import mk.ukim.finki.db.library.model.exception.InvalidBookIdException;
     5import mk.ukim.finki.db.library.model.exception.LibraryNotFoundException;
    56import mk.ukim.finki.db.library.repository.BookRepository;
    67import mk.ukim.finki.db.library.repository.GenreRepository;
     8import mk.ukim.finki.db.library.repository.LibraryRepository;
    79import mk.ukim.finki.db.library.repository.WriterRepository;
    810import mk.ukim.finki.db.library.service.BookService;
    9 import mk.ukim.finki.db.library.service.LibraryService;
    1011import org.springframework.stereotype.Service;
    1112
    1213import java.util.List;
    13 import java.util.stream.Collectors;
     14import java.util.Optional;
    1415
    1516@Service
     
    1920    private final WriterRepository writerRepository;
    2021    private final GenreRepository genreRepository;
     22    private final LibraryRepository libraryRepository;
    2123
    22     public BookServiceImpl(BookRepository bookRepository, WriterRepository writerRepository, GenreRepository genreRepository, LibraryService libraryService) {
     24    public BookServiceImpl(BookRepository bookRepository, WriterRepository writerRepository, GenreRepository genreRepository, LibraryRepository libraryRepository) {
    2325        this.bookRepository = bookRepository;
    2426        this.writerRepository = writerRepository;
    2527        this.genreRepository = genreRepository;
     28        this.libraryRepository = libraryRepository;
    2629    }
    2730
     
    3740
    3841    @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
    4143        //List<Genre> genres = this.genreRepository.findAllById(genreIds);
    4244        //List<Writer> writers = this.writerRepository.findAllById(writerIds);
    43         Book book = new Book(bookName, bookNumber, isFree, bookPrice, bookPriceLate, bookGenre, librariesEnum); //, genres, writers
     45        Book book = new Book(id, bookName, bookNumber, isFree, bookPrice, bookPriceLate); //, genres, writers
    4446        return this.bookRepository.save(book);
    4547    }
    4648
    4749    @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) {
    4951        Book book =  this.findById(id);
    5052        book.setBookName(bookName);
     
    6062        book.setWriters(writers);
    6163
     64        Library library = this.libraryRepository.findById(libraryId).orElseThrow(() -> new LibraryNotFoundException(libraryId));
     65        book.setLibrary(library);
     66
    6267        return this.bookRepository.save(book);
    6368    }
     
    7075    }
    7176
     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    }
    7295
    7396    //in bookRepository
  • src/main/java/mk/ukim/finki/db/library/service/impl/GenreServiceImpl.java

    r5506b50 re5de1b0  
    2929
    3030    @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);
    3333        return this.genreRepository.save(genre);
    3434    }
  • src/main/java/mk/ukim/finki/db/library/service/impl/LibraryServiceImpl.java

    r5506b50 re5de1b0  
    2525
    2626    @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);
    2929        return this.libraryRepository.save(library);
    3030    }
  • src/main/java/mk/ukim/finki/db/library/service/impl/MembershipTypeServiceImpl.java

    r5506b50 re5de1b0  
    3030
    3131    @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);
    3434        return this.membershipTypeRepository.save(membershipType);
    3535    }
  • src/main/java/mk/ukim/finki/db/library/service/impl/PriceListServiceImpl.java

    r5506b50 re5de1b0  
    2929
    3030    @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);
    3333        return this.priceListRepository.save(priceList);
    3434    }
  • src/main/java/mk/ukim/finki/db/library/service/impl/RoomServiceImpl.java

    r5506b50 re5de1b0  
    2929
    3030    @Override
    31     public Room create(int room) {
    32         Room roomNum = new Room(room);
    33         return this.roomRepository.save(roomNum);
     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);
    3434    }
    3535}
  • src/main/java/mk/ukim/finki/db/library/service/impl/SchoolTypeServiceImpl.java

    r5506b50 re5de1b0  
    2929
    3030    @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);
    3333        return this.schoolTypeRepository.save(schoolType);
    3434    }
  • src/main/java/mk/ukim/finki/db/library/service/impl/UserServiceImpl.java

    r5506b50 re5de1b0  
    22
    33import mk.ukim.finki.db.library.model.Person;
    4 import mk.ukim.finki.db.library.model.exception.InvalidArgumentsException;
    54import mk.ukim.finki.db.library.model.exception.InvalidUserCredentialsException;
    65import mk.ukim.finki.db.library.model.exception.InvalidUsernameOrPasswordException;
     
    109import org.springframework.stereotype.Service;
    1110
    12 import java.util.Date;
    1311
    1412@Service
     
    1715    private final UserRepository userRepository;
    1816
    19     public UserServiceImpl(UserRepository userRepository) {
     17    public UserServiceImpl(MemberRepository userRepository) {
    2018        this.userRepository = userRepository;
    2119    }
    2220
    2321    @Override
    24     public Person register(String name, String surname, Date birthDate, String address, String town, String phoneNumber,
    25                             String email, String password) { //SchoolType schoolType, MembershipType membershipType,
     22    public Person register(String name, String surname, String address, String town, String phoneNumber,
     23                           String email, String password) { //SchoolType schoolType, MembershipType membershipType,
    2624
    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);
    2826
    2927        return this.userRepository.save(member);
  • src/main/java/mk/ukim/finki/db/library/service/impl/WriterServiceImpl.java

    r5506b50 re5de1b0  
    3030
    3131    @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);
    3434        return this.writerRepository.save(writer);
    3535    }
  • src/main/java/mk/ukim/finki/db/library/web/BookController.java

    r5506b50 re5de1b0  
    66
    77@Controller
    8 @RequestMapping("/books")
     8@RequestMapping("/book")
    99public class BookController {
    1010
     
    1515    }
    1616
     17
     18
    1719}
  • src/main/java/mk/ukim/finki/db/library/web/LoginController.java

    r5506b50 re5de1b0  
    3535                    request.getParameter("password"));
    3636            request.getSession().setAttribute("username", member);
    37             return "redirect:/home";
     37            return "redirect:/books";
    3838        }
    3939        catch (InvalidUserCredentialsException exception) {
  • src/main/java/mk/ukim/finki/db/library/web/RegisterController.java

    r5506b50 re5de1b0  
    3535    public String register(@RequestParam String name,
    3636                           @RequestParam String surname,
    37                            @RequestParam Date birthDate,
    3837                           @RequestParam String town,
    3938                           @RequestParam String address,
     
    4140                           @RequestParam String email,
    4241                           @RequestParam String password
    43                            ) {
     42    ) {
    4443        try{
    45             this.userService.register(name, surname, birthDate, town, address, phoneNumber, email, password);
     44            this.userService.register(name, surname, town, address, phoneNumber, email, password);
    4645            return "redirect:/login";
    4746        } 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
     1server.port=9091
    182
    193# Datasource configuration
    20 #spring.datasource.url=jdbc:postgresql://localhost:5432/libraryDB
    21 #spring.datasource.username=vintageLibrary
    22 #spring.datasource.password=baza123
     4spring.datasource.url=jdbc:postgresql://localhost:5432/parkingDB
     5spring.datasource.username=parkDB
     6spring.datasource.password=parkdb123
     7
     8# Default connection pool
     9spring.datasource.hikari.connection-timeout=20000
     10spring.datasource.hikari.maximum-pool-size=5
     11
     12spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQL95Dialect
     13spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
     14
     15spring.jpa.hibernate.ddl-auto=update
     16spring.jpa.show-sql=true
     17
     18
     19spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyComponentPathImpl
     20
     21spring.jpa.open-in-view=false
  • src/main/resources/templates/book.html

    r5506b50 re5de1b0  
    11<!DOCTYPE html>
    2 <html lang="en">
     2<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
    33<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>
    610</head>
    711<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>
    9115</body>
    10116</html>
  • src/main/resources/templates/guide.html

    r5506b50 re5de1b0  
    3030                </li>
    3131                <li class="nav-item m-auto">
    32                     <a class="nav-link active" href="/listBooks">ЛИСТА НА КНИГИ</a>
     32                    <a class="nav-link active" href="/book">ЛИСТА НА КНИГИ</a>
    3333                </li>
    3434            </ul>
  • src/main/resources/templates/home.html

    r5506b50 re5de1b0  
    2828                <li class="nav-item m-auto">
    2929                    <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>
    3330                </li>
    3431            </ul>
  • src/main/resources/templates/info.html

    r5506b50 re5de1b0  
    2828        <li class="nav-item m-auto">
    2929          <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>
    3330        </li>
    3431      </ul>
  • src/main/resources/templates/library.html

    r5506b50 re5de1b0  
    2424        </li>
    2525        <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>
    2727        </li>
    2828        <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>
    3330        </li>
    3431      </ul>
  • src/main/resources/templates/login.html

    r5506b50 re5de1b0  
    3030                <li class="nav-item m-auto">
    3131                    <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>
    3532                </li>
    3633            </ul>
  • src/main/resources/templates/onlinePayment.html

    r5506b50 re5de1b0  
    2121        </li>
    2222        <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>
    2424        </li>
    2525        <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>
    2727        </li>
    2828        <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>
    3030        </li>
    3131      </ul>
  • src/main/resources/templates/register.html

    r5506b50 re5de1b0  
    1313<nav class="navbar navbar-expand-md navbar-dark bg-dark">
    1414    <div class="container">
    15         <a class="navbar-brand" href="/home">ONLINE LIBRARY</a>
     15        <a class="navbar-brand" href="/home">VINTAGE LIBRARY</a>
    1616        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault"
    1717                aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
     
    2525                </li>
    2626                <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>
    2828                </li>
    2929                <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>
    3431                </li>
    3532            </ul>
     
    4441    </div>
    4542
    46 <div class="container">
     43    <div class="container">
    4744
    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>
    9588
    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>
    10089
    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>
    10296</section>
    10397
     
    110104                <hr class="bg-white mb-2 mt-0 d-inline-block mx-auto w-25">
    111105                <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>
    113107                    <li><i class="fa fa-phone mr-2"></i> + 33 12 14 15 16</li>
    114108                    <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.