Changeset e5de1b0 for src/main/java
- Timestamp:
- 09/22/22 15:35:07 (2 years ago)
- Branches:
- master
- Children:
- 3692f0d
- Parents:
- 5506b50
- 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 //} 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) {
Note:
See TracChangeset
for help on using the changeset viewer.