Changeset e5de1b0 for src/main/java


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/java/mk/ukim/finki/db/library
Files:
32 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) {
Note: See TracChangeset for help on using the changeset viewer.