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.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public BooksDetailView update(
@RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(defaultValue = "id") String sortBy)
{
List<Books> list = service.getAllBooks(pageNo, pageSize, sortBy);
List<Books> list = service.getAllBooks(pageNo-1, 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 @@ -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 @@ -41,25 +42,58 @@ public class BorrowController {


//borrow list @admin
@GetMapping("/pagenated/")
public ResponseEntity<List<Borrow>>getAllBorrow(
@RequestParam(defaultValue = "0") Integer pageNo,
@RequestParam(defaultValue = "10") Integer pageSize,


// @GetMapping("/fetching/{string}/{date1}/{date2}")
// public Collection<BookingView> listinguserdropdown(@PathVariable String string,@PathVariable Date date1, @PathVariable Date date2) {
// return bookingService.listinguserdropdown(string,date1, date2);
// }

@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("/{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);

}

@GetMapping("/user/pagenated/")
// @PutMapping("/{borrowId}")
// public BorrowDetailView updateApprove(
// @PathVariable("borrowId") Integer borrowId,
// @Valid @RequestBody BorrowForm form
// ) {
// return bService.updates(borrowId, form);
// }


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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,67 +5,75 @@
// import com.innovature.Library.security.util.SecurityUtil;

public class BorrowForm {
//private Date issueDate;
private Date returnDate;
private Date dueDate;
private Integer booksId;
private String reason;
//private String status;



// public Date getIssueDate() {
// return issueDate;
// }
// public void setIssueDate(Date issueDate) {
// this.issueDate = issueDate;
// }


public Date getReturnDate() {
return returnDate;
}
public void setReturnDate(Date returnDate) {
this.returnDate = returnDate;
}


public Date getDueDate() {
return dueDate;
}
public void setDueDate(Date dueDate) {
this.dueDate = dueDate;
}


public Integer getBooksId() {
return booksId;
}
public void setBooksId(Integer booksId) {
this.booksId = booksId;
}
public String getReason() {
return reason;
}
public void setReason(String reason) {
this.reason = reason;
}

// public String getStatus() {
// return status;
// }
// public void setStatus(String status) {
// this.status = status;
// }










// private Date issueDate;
private Date returnDate;
private Date dueDate;
private Integer booksId;
private String reason;
// private String status;
private Date startDate;
private Date endDate;

// public Date getIssueDate() {
// return issueDate;
// }
// public void setIssueDate(Date issueDate) {
// this.issueDate = issueDate;
// }

public Date getReturnDate() {
return returnDate;
}

public void setReturnDate(Date returnDate) {
this.returnDate = returnDate;
}

public Date getDueDate() {
return dueDate;
}

public void setDueDate(Date dueDate) {
this.dueDate = dueDate;
}

public Integer getBooksId() {
return booksId;
}

public void setBooksId(Integer booksId) {
this.booksId = booksId;
}

public String getReason() {
return reason;
}

public void setReason(String reason) {
this.reason = reason;
}

public Date getStartDate() {
return startDate;
}

public void setStartDate(Date startDate) {
this.startDate = startDate;
}

public Date getEndDate() {
return endDate;
}

public void setEndDate(Date endDate) {
this.endDate = endDate;
}

// public String getStatus() {
// return status;
// }
// public void setStatus(String status) {
// this.status = status;
// }

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.innovature.Library.repository;

import java.sql.Date;
import java.util.Collection;

//import org.springframework.data.repository.Repository;
Expand Down Expand Up @@ -72,7 +73,22 @@ public interface BorrowRepository extends PagingAndSortingRepository<Borrow, Int

//total sum of fine /user
// @Query(value=" select sum(fine) from borrow where user_id=?",nativeQuery=true)
// void findFineByUserId(Integer userId);
// void findFineByUserId(Integer userId); public Page<Borrow> findAll(Pageable paging);

// @Query(value = "select * from borrow where issue_date between '2022-12-12' and '2022-12-20' ", nativeQuery = true)
// public Page<Borrow> findbyIssuDate(Pageable paging);



@Query(value = "select * from borrow where issue_date between DATE(?1) and DATE(?2) and status!='REQUESTED'", nativeQuery = true)
public Page<Borrow> findbyIssuDate( java.sql.Date date1,java.sql.Date date2,Pageable paging);

// public Page<Borrow> findbyIssuDate(java.util.Date date1, java.util.Date date2, Pageable paging);


// @Query(value = "select * from booking where booked_date BETWEEN DATE(?2) AND DATE(?3) and vaccine_id in(select vaccine_id from vaccine where vaccine_type=?1);",nativeQuery = true)
// Collection<Booking> findAll(String string, Date date1, Date date2);



}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.innovature.Library.service;
import java.util.Collection;
import java.sql.Date;
import java.util.List;

import javax.validation.Valid;
Expand Down Expand Up @@ -29,7 +30,8 @@ public interface BorrowService {

BorrowDetailView updatereject(Integer borrowId,BorrowForm form);

List<Borrow> getAllBorrow(Integer pageNo, Integer pageSize, String sortBy);
List<Borrow> getAllBorrows(Integer pageNo, Integer pageSize, String sortBy);
List<Borrow> getAllBorrow(Date date1, Date date2, Integer pageNo, Integer pageSize, String sortBy);
List<Borrow> getBorrowHistory(Integer pageNo, Integer pageSize, String sortBy);

BorrowDetailView updateReturn(Integer borrowId, BorrowForm form);
Expand All @@ -48,6 +50,8 @@ public interface BorrowService {

Collection<Borrow> fine();






Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.Collection;
// import java.util.Date;
import java.util.Date;
//import java.sql.Date;

import javax.transaction.Transactional;

Expand Down Expand Up @@ -208,8 +209,30 @@ public BorrowDetailView listByUser(Integer borrowId, BorrowForm form) {


///pagenation and sort///
@Override
@Transactional
public List<Borrow>getAllBorrow( java.sql.Date date1, java.sql.Date date2,Integer pageNo, Integer pageSize, String sortBy){

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

Page<Borrow> pagedResult = borrowRepository.findbyIssuDate(date1,date2,paging);

public List<Borrow>getAllBorrow(Integer pageNo, Integer pageSize, String sortBy){
if(pagedResult.hasContent()){
return pagedResult.getContent();
} else {
return new ArrayList<Borrow>();
}


// @Override
// public Collection<BookingView> listinguserdropdown(String string, java.sql.Date date1, java.sql.Date date2) {
// return bookingRepository.findAll(string, date1, date2).stream().map(BookingView::new).collect(Collectors.toList());
// }
}

@Override
@Transactional
public List<Borrow>getAllBorrows(Integer pageNo, Integer pageSize, String sortBy){

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

Expand All @@ -223,6 +246,9 @@ public BorrowDetailView listByUser(Integer borrowId, BorrowForm form) {
}



@Override
@Transactional
public List<Borrow>getBorrowHistory(Integer pageNo, Integer pageSize, String sortBy){

Pageable paging = PageRequest.of(pageNo, pageSize, Sort.by(sortBy));
Expand Down
5 changes: 5 additions & 0 deletions FrontEnd/iprjt/src/app/books.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ export class BooksService {
return this.http.delete(this.apiurl+'/books/'+booksId,{headers:head_obj});
}


pagination1(page:any,tableSize:any,sort:any){
return this.http.get("http://localhost:8080/books/pagenated/?pageNo="+page+"&pageSize="+tableSize+"&sortBy="+sort)
}


update(id: any, data: any) {
// console.log(id)
Expand Down
25 changes: 18 additions & 7 deletions FrontEnd/iprjt/src/app/booksdisplay/booksdisplay.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,26 @@ <h1 style="text-align:center ;">Books Details</h1>
<thead class="bg-primary text-white">
<tr role="row">

<th>Book Name</th>
<th>Category-Name</th>
<th>Publication</th>
<th>Auther</th>
<th>Book Copies</th>
<th (click)="sortfn('booksName')">Book Name</th>
<th (click)="sortfn('category.categoryName')">Category-Name</th>
<th (click)="sortfn('publication')">Publication</th>
<th (click)="sortfn('auther')">Auther</th>
<th (click)="sortfn('booksCopies')">Book Copies</th>
<th>Book Cover</th>
<th>Action</th>

</tr>
</thead>
<tbody>
<tr *ngFor="let books of booksdata">
<tr *ngFor="let books of data | paginate
: {
itemsPerPage: tableSize,
currentPage: page,
totalItems: count
};


">

<td>{{books.booksName}}</td>
<td>{{books.category.categoryName}}</td>
Expand All @@ -48,7 +56,10 @@ <h1 style="text-align:center ;">Books Details</h1>

</tbody>
</table>

<div class="d-flex justify-content-center">
<pagination-controls (pageChange)="onTableDataChange(page=$event)">
</pagination-controls>
</div>
</div>
</div>
</div>
Loading