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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
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;
Expand All @@ -21,6 +25,7 @@
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;
Expand Down Expand Up @@ -85,6 +90,21 @@ 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, pageSize, sortBy);
return new ResponseEntity<List<Books>>(list,new HttpHeaders(),
HttpStatus.OK);

}







Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class BorrowController {




//borrow list @admin
@GetMapping("/pagenated/")
public ResponseEntity<List<Borrow>>getAllBorrow(
@RequestParam(defaultValue = "0") Integer pageNo,
Expand All @@ -53,6 +53,19 @@ public class BorrowController {

}

@GetMapping("/user/pagenated/")
public ResponseEntity<List<Borrow>>getBorrowHistory(
@RequestParam(defaultValue = "0") Integer pageNo,
@RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(defaultValue = "id") String sortBy)
{
List<Borrow> list = bService.getBorrowHistory(pageNo, pageSize, sortBy);
return new ResponseEntity<List<Borrow>>(list,new HttpHeaders(),
HttpStatus.OK);

}





Expand All @@ -66,11 +79,12 @@ 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();
Expand All @@ -90,6 +104,12 @@ public Collection<Borrow> listDue() {
return bService.listDue();
}


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

@GetMapping("/dueByUser")
public Collection<Borrow> listDueByUser() {
return bService.listDueByUser();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository;
import com.innovature.Library.entity.Books;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;


public interface BooksRepository extends Repository <Books, Integer> {
Expand All @@ -25,5 +27,8 @@ public interface BooksRepository extends Repository <Books, Integer> {
@Query(value = "select * from books where books_id in(select books_id from books where category_id=?1)",nativeQuery = true)
Collection<Books> findbyCategoryId(Integer categoryId);


public Page<Books> findAll(Pageable paging);


}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ public interface BorrowRepository extends PagingAndSortingRepository<Borrow, Int

Collection<BorrowListView> findAllByUserUserId(Integer userId);



public Page<Borrow> findAll(Pageable paging);
public Page<Borrow> findAllByUserUserId(Integer userId,Pageable paging);

// public Page<Borrow> findAll(org.springframework.data.domain.Pageable paging);

Expand All @@ -39,13 +42,13 @@ public interface BorrowRepository extends PagingAndSortingRepository<Borrow, Int


//To select all user(without used_id) by due date expired(@admin side)
@Query(value = "select * from borrow where borrow_id in(select borrow_id from borrow where due_date<curdate() and status='APPROVED' )", nativeQuery = true)
@Query(value = "select * from borrow where borrow_id in(select borrow_id from borrow where due_date<curdate() and status='APPROVED')", nativeQuery = true)
Collection<Borrow> findbyBorrowIdandStatus();



// @Query(value = "select * from borrow where borrow_id in(select borrow_id from borrow where due_date<curdate() and status='APPROVED' )", nativeQuery = true)
// Collection <Borrow> findbyBorrowIdandStat();
@Query(value = "select * from borrow where borrow_id in(select borrow_id from borrow where due_date<curdate() and status!='RETURNED')", nativeQuery = true)
Collection <Borrow> findbyBorrowIdandDueDateandStatus();



Expand All @@ -66,7 +69,10 @@ public interface BorrowRepository extends PagingAndSortingRepository<Borrow, Int
void findDueDays(Integer borrowId);

//public Borrow save(Collection<Borrow> borrow);


//total sum of fine /user
// @Query(value=" select sum(fine) from borrow where user_id=?",nativeQuery=true)
// void findFineByUserId(Integer userId);


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

import java.io.IOException;
import java.util.Collection;
import java.util.List;

import org.springframework.http.HttpEntity;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.view.RedirectView;
Expand Down Expand Up @@ -31,6 +33,8 @@ public interface BooksService {

RedirectView uploadImage(MultipartFile multipartFile) throws IOException;

List<Books> getAllBooks(Integer pageNo, Integer pageSize, String sortBy);



}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public interface BorrowService {
BorrowDetailView updatereject(Integer borrowId,BorrowForm form);

List<Borrow> getAllBorrow(Integer pageNo, Integer pageSize, String sortBy);
List<Borrow> getBorrowHistory(Integer pageNo, Integer pageSize, String sortBy);

BorrowDetailView updateReturn(Integer borrowId, BorrowForm form);

Expand All @@ -45,6 +46,8 @@ public interface BorrowService {

void fineGeneration();

Collection<Borrow> fine();




Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.innovature.Library.service.impl;

import java.io.IOException;
import java.util.ArrayList;
// import java.net.http.HttpHeaders;
import java.util.Collection;
import java.util.List;

//import java.util.ArrayList;
import javax.transaction.Transactional;
//import java.util.Collection;
Expand All @@ -15,6 +18,12 @@
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.view.RedirectView;


import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;

import com.innovature.Library.entity.Books;
import com.innovature.Library.entity.Category;
import com.innovature.Library.exception.NotFoundException;
Expand Down Expand Up @@ -107,6 +116,22 @@ public RedirectView uploadImage(MultipartFile multipartFile) throws IOException
return null;
}



public List<Books>getAllBooks(Integer pageNo, Integer pageSize, String sortBy){

Pageable paging = PageRequest.of(pageNo, pageSize, Sort.by(sortBy));

Page<Books> pagedResult = booksRepository.findAll(paging);

if(pagedResult.hasContent()){
return pagedResult.getContent();
} else {
return new ArrayList<Books>();
}
}


}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,22 @@ public Collection<Borrow> listAll() {
}


@Override
public Collection<Borrow> listDue() {
return borrowRepository.findbyBorrowIdandStatus();
}


@Override
public Collection<Borrow> listDueByUser() {
return borrowRepository.findbyUserIdandStatus(SecurityUtil.getCurrentUserId());
}

@Override
public Collection<Borrow> fine() {
return borrowRepository.findbyBorrowIdandDueDateandStatus();
}



@Override
Expand All @@ -91,9 +101,6 @@ public BorrowDetailView list(Integer borrowId){
}





@Override
public Collection<BorrowListView> list1() {
return borrowRepository.findAllByUserUserId(SecurityUtil.getCurrentUserId());
Expand Down Expand Up @@ -200,7 +207,7 @@ public BorrowDetailView listByUser(Integer borrowId, BorrowForm form) {




///pagenation and sort///

public List<Borrow>getAllBorrow(Integer pageNo, Integer pageSize, String sortBy){

Expand All @@ -216,10 +223,26 @@ public BorrowDetailView listByUser(Integer borrowId, BorrowForm form) {
}


@Override
public Collection<Borrow> listDue() {
return borrowRepository.findbyBorrowIdandStatus();
public List<Borrow>getBorrowHistory(Integer pageNo, Integer pageSize, String sortBy){

Pageable paging = PageRequest.of(pageNo, pageSize, Sort.by(sortBy));

Page<Borrow> pagedResult = borrowRepository.findAllByUserUserId(SecurityUtil.getCurrentUserId(),paging);

if(pagedResult.hasContent()){
return pagedResult.getContent();
} else {
return new ArrayList<Borrow>();
}
}

// @Override
// public Collection<BorrowListView> list1() {
// return borrowRepository.findAllByUserUserId(SecurityUtil.getCurrentUserId());
// }



//mail//
// @Override
// @Transactional
Expand Down Expand Up @@ -275,7 +298,7 @@ public void sendMail(Integer userId, String subject, String text) {
@Override
@Transactional
// @Scheduled(cron="* */1 * * * * ")
@Scheduled(cron="0 0 12 * * ?")
@Scheduled(cron="0 0 9 * * ?")
public void fineGeneration() {
System.out.println("reachllllllllllllll");

Expand All @@ -290,8 +313,7 @@ public void fineGeneration() {
due=due/86400000; //time conversion to date
bor.setDueDays(due);

bor.setFine(due*5);

bor.setFine(due*5);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


public class FileUtil {
public static final String PATH = "/home/negilbabu/Desktop/project/LibraryRepository/FrondEnd/iprjt-07-11/iprjt/src/assets/BooksImage/";
public static final String PATH = "/home/negilbabu/Desktop/project/LibraryRepository/FrontEnd/iprjt/src/assets/BooksImage/";
//public static final String PATH = "/home/arun/Library@dec9@12PM/Library/iprjt-07-11/iprjt/src/assets/BooksImage/";

public static final String PROFILE_PIC_DIR = "item_pics/";
Expand Down
23 changes: 22 additions & 1 deletion FrontEnd/iprjt/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading