Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions BackEnd/Library/src/main/java/Json/DateFormat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package Json;

public @interface DateFormat {

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@EnableScheduling
@SpringBootApplication
public class Library {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
package com.innovature.Library.controller;

import java.io.IOException;
//import java.security.Principal;
import java.util.Collection;
import java.util.List;

import javax.validation.Valid;

import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.innovature.Library.entity.Books;
import com.innovature.Library.entity.Borrow;
//import com.innovature.Library.entity.Category;
import com.innovature.Library.form.BooksForm;
import com.innovature.Library.repository.BooksRepository;
import com.innovature.Library.service.BooksService;
import com.innovature.Library.util.FileUtil;
import com.innovature.Library.view.BooksDetailView;
//import com.innovature.Library.view.BooksListView;
//import com.innovature.Library.view.BooksListView;
Expand All @@ -30,6 +42,10 @@ public class BooksController {
@Autowired
private BooksService service;

@Autowired
private BooksRepository booksRepository;
private Integer booksId;


@PostMapping
public BooksDetailView add(@Valid @RequestBody BooksForm form) {
Expand Down Expand Up @@ -73,5 +89,50 @@ public BooksDetailView update(
}



@GetMapping("/pagenated/")
public ResponseEntity<List<Books>>getAllBooks(
@RequestParam(defaultValue = "0") Integer pageNo,
@RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(defaultValue = "id") String sortBy)
{
List<Books> list = service.getAllBooks(pageNo-1, pageSize, sortBy);
return new ResponseEntity<List<Books>>(list,new HttpHeaders(),
HttpStatus.OK);

}










@PostMapping("/save/image/{booksId}")
public void saveBookImage(@RequestParam(value="image" ) MultipartFile multipartFile,
@PathVariable Integer booksId) throws IOException {

Books books = booksRepository.findByBooksId(booksId);

String fileName = StringUtils.cleanPath(multipartFile.getOriginalFilename());
books.setImage(fileName);

booksRepository.save(books);

// String UploadDir = "userProfile-photos/" + savedUserProfile.getUserprofileId();

FileUtil.saveUserProfile(fileName, multipartFile);

}

@GetMapping("/books/{booksId}")
public HttpEntity<byte[]> getImagePic(@PathVariable Integer booksId) {

return service.getImagePic(booksId);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.security.Principal;
import java.util.Collection;
import java.sql.Date;
import java.util.List;

import javax.validation.Valid;
Expand Down Expand Up @@ -32,30 +33,83 @@

@RestController
@RequestMapping("/borrow")
public class BorrowController {

public class BorrowController {

@Autowired
private BorrowService bService;


//load all borrow list
@GetMapping
public Collection<Borrow> list() {
return bService.listAll();
}


//pagenated borrow list at admin borrow
@GetMapping("/pagenated/")
public ResponseEntity<List<Borrow>>getAllBorrows(
@RequestParam(defaultValue = "1") Integer pageNo,
@RequestParam(defaultValue = "5") Integer pageSize,
@RequestParam(defaultValue = "id") String sortBy)
{
List<Borrow> list = bService.getAllBorrows(pageNo-1, pageSize, sortBy);
return new ResponseEntity<List<Borrow>>(list,new HttpHeaders(),
HttpStatus.OK);

}


@GetMapping("/pagenated/")
public ResponseEntity<List<Borrow>>getAllBorrow(
@RequestParam(defaultValue = "0") Integer pageNo,
@RequestParam(defaultValue = "10") Integer pageSize,
//load results of issuedate filter
@GetMapping("/loadByIssueDate/{date1}/{date2}")
public ResponseEntity<List<Borrow>> loadByIssueDate(
@PathVariable("date1") Date date1,
@PathVariable("date2") Date date2)
// {
// return bService.loadtAllByIssueDate(Date date1, Date date2);
// }
{
List<Borrow> list = bService.loadtAllByIssueDate(date1, date2);
return new ResponseEntity<List<Borrow>>(list,new HttpHeaders(),
HttpStatus.OK);
}






//Load filtered pagenated borrow list [on filtering]
@GetMapping("/{date1}/{date2}")
public ResponseEntity<List<Borrow>>getFilterBorrow(
// @PathVariable Date date1, @PathVariable Date date2,
@PathVariable("date1") Date date1,
@PathVariable("date2") Date date2,
@RequestParam(defaultValue = "1") Integer pageNo,
@RequestParam(defaultValue = "5") Integer pageSize,
@RequestParam(defaultValue = "id") String sortBy)
{
List<Borrow> list = bService.getAllBorrow(pageNo, pageSize, sortBy);

List<Borrow> list = bService.getAllBorrow(date1, date2,pageNo-1, pageSize, sortBy);
return new ResponseEntity<List<Borrow>>(list,new HttpHeaders(),
HttpStatus.OK);

}



//pagenation+sort at user borrow history
@GetMapping("/userBorrow/pagenated/")
public ResponseEntity<List<Borrow>>getBorrowHistory(
@RequestParam(defaultValue = "1") Integer pageNo,
@RequestParam(defaultValue = "5") Integer pageSize,
@RequestParam(defaultValue = "id") String sortBy)
{
List<Borrow> list = bService.getBorrowHistory(pageNo-1, pageSize, sortBy);
return new ResponseEntity<List<Borrow>>(list,new HttpHeaders(),
HttpStatus.OK);

}



Expand All @@ -66,39 +120,38 @@ public class BorrowController {
public BorrowDetailView add(@Valid @RequestBody BorrowForm form) {
return bService.add(form);
}

//borrow history @user
@GetMapping("/list/user")
public Collection<BorrowListView> list1(Principal p) {
return bService.list1();
}

@GetMapping("/user/notification")
public Collection<Borrow> listNotification(Principal p) {
return bService.listNotification();
}


@GetMapping
public Collection<Borrow> list() {
return bService.listAll();
@GetMapping("/user/UserNotification")
public Collection<Borrow> listUserNotification(Principal p) {
return bService.listNotification();
}



@GetMapping("/due")
public Collection<Borrow> listDue() {
return bService.listDue();
}


// @PostMapping("/emailsent")
// public String sendMail(@RequestBody Integer userId) {
// System.out.println("Inside mail controller");
// this.bService.sendMail(userId,
// "Due date expired",
// "Please return the books"
// );
// return "message sent";
// // return service.sendMail(userId);
// }
@GetMapping("/fine")
public Collection<Borrow> listfine() {
return bService.fine();
}

@GetMapping("/dueByUser")
public Collection<Borrow> listDueByUser() {
return bService.listDueByUser();
}


@GetMapping("/{borrowId}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,12 @@
@RequestMapping("/email")
public class EmailController {


// @Autowired
// private EmailService emailService;

@Autowired
private BorrowService service;


// @PostMapping("/emailsent")
// public ResponseEntity<?>sendEmail(@RequestBody EmailForm form){

// boolean result = this.emailService.sendEmail("Due date expired","please return the book asap", form.getSentto());
// // "OTP Verification", "Your OTP to change your password is "+"otp"+"use it to create a new password."
// if(result){
// return ResponseEntity.ok("Email Sent!");
// }else{
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Email not sent.");
// }
// }


@PostMapping("emailsent/{userId}")
public String sendMail(@PathVariable("userId") Integer userId) {
System.out.println(userId);
Expand All @@ -56,16 +42,5 @@ public String sendMail(@PathVariable("userId") Integer userId) {
// return service.sendMail(userId);
}

// @PostMapping("/emailsent/{email}")

// public ResponseEntity<?>sendEmail(@PathVariable("email") String email) {

// boolean result = this.emailService.sendEmail("Due date expired","please return the book asap", form.getSentto());
// // "OTP Verification", "Your OTP to change your password is "+"otp"+"use it to create a new password."
// if(result){
// return ResponseEntity.ok("Email Sent!");
// }else{
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Email not sent.");
// }
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
import javax.persistence.Id;
import javax.persistence.ManyToOne;

import org.springframework.data.annotation.Transient;

import javax.persistence.Column;

import com.innovature.Library.form.BooksForm;

@Entity
Expand All @@ -31,6 +35,8 @@ private Status(byte value) {
private Integer booksCopies;
@ManyToOne(optional = false, fetch = FetchType.EAGER)
private Category category;
@Column(nullable = true, length = 64)
private String image;


public Books(){}
Expand All @@ -49,6 +55,16 @@ public Books(BooksForm form,Category category){
//this.categoryName = new Category(Category);
}


@Transient
public String getPhotosImagePath() {
if (image == null || booksId == null)
return null;
return "/items - photos/" + booksId + image;
}



public Integer getBooksId() {
return booksId;
}
Expand Down Expand Up @@ -96,6 +112,19 @@ public Category getCategory() {
public void setCategory(Category category) {
this.category = category;
}



public String getImage() {
return image;
}

public void setImage(String image) {
this.image = image;
}




public Books(int booksId, String booksName,String publication,String auther,String status,Integer booksCopies,Category category){
this.booksId = booksId;
Expand Down
Loading