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
6 changes: 6 additions & 0 deletions BackEnd/Library/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@
<version>1.8</version>
</dependency>

<dependency>
<groupId>net.sf.supercsv</groupId>
<artifactId>super-csv</artifactId>
<version>2.4.0</version>
</dependency>



</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,20 @@ public List<Object[]> getcountByCategoryId() {

}

//book search

@GetMapping("/admin/searchBooks")
public ResponseEntity<Page<Books>> getAllBookStockSearch(
@RequestParam(defaultValue = "") String keyword,
@RequestParam(defaultValue = "1") Integer pageNo,
@RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(defaultValue = "id") String sortBy) {
System.out.println("paage size" + pageSize);
Page<Books> list = service.getAllBookStocks(keyword, pageNo - 1, pageSize, sortBy);
return new ResponseEntity<Page<Books>>(list, new HttpHeaders(),
HttpStatus.OK);

}


}
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package com.innovature.Library.controller;

import java.security.Principal;
import java.io.IOException;
import java.security.Principal;
import java.util.Collection;
import java.sql.Date;

import java.text.SimpleDateFormat;
import java.util.List;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -24,6 +28,12 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


import org.supercsv.io.CsvBeanWriter;
import org.supercsv.io.ICsvBeanWriter;
import org.supercsv.prefs.CsvPreference;


import com.innovature.Library.entity.Borrow;
import com.innovature.Library.form.BorrowForm;
import com.innovature.Library.service.BorrowService;
Expand Down Expand Up @@ -270,5 +280,43 @@ public rentChartView getchart(){
}


@GetMapping("admin/export")
public void Exportcsv(HttpServletResponse httpServletResponse) throws IOException {
httpServletResponse.setContentType("text/csv");
java.text.DateFormat datefFormat = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
String currentDateTime = datefFormat.format(new java.util.Date());
String headerKey = "Content-Disposition";
String headerValue = "attachment; filename=users_" + currentDateTime + ".csv";
httpServletResponse.setHeader(headerKey, headerValue);
List<Borrow> rents = bService.listcsv();

ICsvBeanWriter csvWriter = new CsvBeanWriter(httpServletResponse.getWriter(),
CsvPreference.STANDARD_PREFERENCE);
String[] csvHeader = { "borrow_id","first_name","books_name", "issue_date", "return_date","due_date","book_returned_date","reason","due_days","fine","status"};
String[] nameMapping = { "borrowId","firstName","booksName", "issueDate", "returnDate", "dueDate","bookReturnedDate","reason","dueDays","fine","status" };
csvWriter.writeHeader(csvHeader);
for (Borrow rent : rents) {
// System.out.println(" :"+rent.getStatus());
csvWriter.write(rent, nameMapping);
}
csvWriter.flush();
csvWriter.close();
}


@GetMapping("/admin/searchUser")
public ResponseEntity<Page<Borrow>> getAllBorrowedUserSearch(
@RequestParam(defaultValue = "") String keyword,
@RequestParam(defaultValue = "1") Integer pageNo,
@RequestParam(defaultValue = "10") Integer pageSize)
// @RequestParam(defaultValue = "user_id") String sortBy)
{
System.out.println("paage size" + pageSize);
Page<Borrow> list = bService.getAllBorrowedUserSearch(keyword, pageNo - 1, pageSize);
return new ResponseEntity<Page<Borrow>>(list, new HttpHeaders(),
HttpStatus.OK);

}


}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public ResponseEntity<ResponseMessage> uploadFile(@RequestParam("file") Multipar
message = "Please upload a csv file!";
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseMessage(message,""));
}




}
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,24 @@ public static boolean hasCSVFormat(MultipartFile file){
Integer.parseInt(csvRecord.get("booksCopies")),
Integer.parseInt(csvRecord.get("categoryId")),
Integer.parseInt(csvRecord.get("status"))
//csvRecord.get("image")


//csvRecord.get("image")
);
csvList.add(csvob);

}
return csvList;

}catch(IOException e){
throw new RuntimeException("fail to parse csv file"+e.getMessage());
}

}







}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,11 @@ public void setFine(Long fine) {
this.fine = fine;
}

public String getFirstName(){
return user.getFirstName();
}

public String getBooksName(){
return books.getBooksName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,8 @@ public interface BooksRepository extends Repository<Books, Integer> {
// @Query(value = "select sum(books_copies)", nativeQuery = true)
// List<Object[]> findbyBooksId1();

@Query(value = "Select * from books where status = 1 AND books_name like %?1% order by books_name like ?2% DESC,books_name like %?3 DESC,books_name like %?4% ", nativeQuery = true)
public Page<Books> findByKeywords(String keyword, String k, String k1, String k2, Pageable pageable);


}
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,23 @@ public interface BorrowRepository extends PagingAndSortingRepository<Borrow, Int
// @Query(value = "select * from borrow where issue_date between date_sub(curdate(),interval 7 day) and curdate()",nativeQuery = true)
// List<Borrow>findAllC();

// @Query(value = "Select * from borrow where books_name like %?1% order by books_name like ?2% DESC,books_name like %?3 DESC,books_name like %?4% ", nativeQuery = true)
// public Page<Borrow> findByKeywords(String keyword, String k, String k1, String k2, Pageable pageable);


// @Query(value = "SELECT * FROM borrow INNER JOIN user ON borrow.user_id = user.user_id where first_name like %?1% order by first_name like ?2% DESC,first_name like %?3 DESC,first_name like %?4% ", nativeQuery = true)
// public Page<Borrow> findByKeywords(String keyword, String k, String k1, String k2, Pageable pageable);

@Query(value = "select * from borrow where user_id in(select user_id from user where first_name like %?%", nativeQuery = true)
public Page<Borrow> findByKeywords(String keyword, String k, String k1, String k2, Pageable pageable);


}

//mysql> select count(borrow_id) from borrow where book_returned_date between '2023-01-01' and '2023-01-07';
//select count(borrow_id) from borrow where book_returned_date='2022-12-27';
//select count(borrow_id) from borrow where book_returned_date='2022-12-27';

// inner join eg = SELECT user.first_name FROM borrow INNER JOIN user ON borrow.user_id = user.user_id
// >no innerjoin= select user.first_name from user,borrow where user.user_id=borrow.user_id;
//>select * from borrow where user_id in(select user_id from user where first_name like 'ashwin');

Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public interface BooksService {

List<Object[]> getBookCountByCategory();

Page<Books>getAllBookStocks(String keyword, Integer pageNo,Integer pageSize,String sortBy);

}


Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ public interface BorrowService {
Integer BorrowBlock();

// public RentCharView getChart();

List<Borrow>listcsv();

Page<Borrow>getAllBorrowedUserSearch(String keyword, Integer pageNo,Integer pageSize);



}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public void save(MultipartFile file){
}





public List<csvUpload>getAll(){
return repository.findAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,20 @@ public List<Object[]> getBookCountByCategory() {
return booksRepository.findCountByCategoryId();
}

//book search

@Override
public Page<Books> getAllBookStocks(String keyword, Integer pageNo, Integer pageSize, String sortBy) {
Pageable paging = PageRequest.of(pageNo, pageSize, Sort.by(sortBy));
System.out.println(keyword);
String k = keyword;
String k1 = keyword;
String k2 = keyword;
Page<Books> pagedResult = booksRepository.findByKeywords(keyword, k, k1, k2, paging);
return pagedResult;

}


}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,11 +450,12 @@ public rentChartView getChart(){


for(Borrow a:s){
if(a.getStatus().equals("APPROVED"))
// if(a.getStatus().equals("APPROVED" ))
if(a.getIssueDate()!=null)
{

LocalDateTime b = a.getIssueDate();
System.out.println("---------------------------"+b);
// System.out.println("-----in issue----------------------"+b);
// System.out.println("........>>>>>>>>>>>>>>>>....."+ b.getDayOfWeek().getValue());

hm.put(b.getDayOfWeek().getValue(), new Result(hm.get(b.getDayOfWeek().getValue()).getIssueCount() + 1,
Expand All @@ -467,13 +468,13 @@ public rentChartView getChart(){
{

c = a.getBookReturnedDate();
System.out.println("cccccccccccccccccccccccccccccccccccccccccc="+c);
// System.out.println("cccccccccccccccccccccccccccccccccccccccccc="+c);


hm.put(c.getDayOfWeek().getValue(), new Result(hm.get(c.getDayOfWeek().getValue()).getIssueCount() ,
hm.get(c.getDayOfWeek().getValue()).getReturnedCount() +1));

System.out.println(hm.get(c.getDayOfWeek().getValue()).getReturnedCount());
// System.out.println(hm.get(c.getDayOfWeek().getValue()).getReturnedCount());
}
}
for (Map.Entry<Integer, Result > mapElement : hm.entrySet()) {
Expand Down Expand Up @@ -511,7 +512,23 @@ public void setReturnedCount(Integer returnedCount) {
}
}

@Override
public List<Borrow> listcsv() {
return borrowRepository.findAllC();
}


@Override
public Page<Borrow> getAllBorrowedUserSearch(String keyword, Integer pageNo, Integer pageSize) {
Pageable paging = PageRequest.of(pageNo, pageSize);
System.out.println(keyword);
String k = keyword;
String k1 = keyword;
String k2 = keyword;
Page<Borrow> pagedResult = borrowRepository.findByKeywords(keyword, k, k1, k2, paging);
return pagedResult;

}



Expand Down
Binary file removed BackEnd/Library29.zip
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes

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

2 changes: 2 additions & 0 deletions FrontEnd/iprjt/package.json → FrontEnd/Library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@popperjs/core": "^2.10.2",
"bootstrap": "^5.2.3",
"chart.js": "^4.1.2",
"file-saver": "^2.0.5",
"material-icons": "^1.13.1",
"ng-angular-popup": "^0.2.0",
"ngx-pagination": "^6.0.3",
Expand All @@ -37,6 +38,7 @@
"@angular/cli": "~14.2.5",
"@angular/compiler-cli": "^14.2.0",
"@ionic/angular-toolkit": "^7.0.0",
"@types/file-saver": "^2.0.5",
"@types/jasmine": "~4.0.0",
"jasmine-core": "~4.3.0",
"karma": "~6.4.0",
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@
td {
border: none;
padding-top: 6px;padding-bottom: 6px;
}
}
.form-control{
width: fit-content;
}
Loading