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.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ protected void configure(HttpSecurity http) throws Exception {
.securityContext().and()
.anonymous().and()
.authorizeRequests()

.antMatchers(GET,"/users/admin/**/").access("hasRole('ROLE_ADMIN')")
.antMatchers(GET,"/users/admin/viewProfile").access("hasRole('ROLE_ADMIN')")

.antMatchers(OPTIONS, "/users").anonymous()
.antMatchers(POST, "/users").anonymous()
.antMatchers(OPTIONS, "/login").anonymous()
Expand All @@ -62,7 +66,7 @@ protected void configure(HttpSecurity http) throws Exception {
.antMatchers(OPTIONS, "/**").anonymous()

//category
.antMatchers(GET,"/category/admin").access("hasRole('ROLE_ADMIN')")
.antMatchers(GET,"/category/admin/**/").access("hasRole('ROLE_ADMIN')")
.antMatchers(POST,"/category").access("hasRole('ROLE_ADMIN')")
.antMatchers(DELETE,"/category").access("hasRole('ROLE_ADMIN')")
.antMatchers(PUT,"/category/{catogoryId}").access("hasRole('ROLE_ADMIN')")
Expand All @@ -71,6 +75,7 @@ protected void configure(HttpSecurity http) throws Exception {
.antMatchers(GET,"/books/admin/**/").access("hasRole('ROLE_ADMIN')")
.antMatchers(GET,"/books/user/**/").access("hasRole('ROLE_USER')")
.antMatchers(POST,"/books").access("hasRole('ROLE_ADMIN')")
.antMatchers(POST,"/books/save/image/{booksId}").access("hasRole('ROLE_ADMIN')")
.antMatchers(DELETE,"/books/{booksId}").access("hasRole('ROLE_ADMIN')")
.antMatchers(PUT,"/books/{booksId}").access("hasRole('ROLE_ADMIN')")

Expand All @@ -80,6 +85,8 @@ protected void configure(HttpSecurity http) throws Exception {
.antMatchers(POST,"/borrow/").access("hasRole('ROLE_USER')")
.antMatchers(PUT,"/borrow/admin/**").access("hasRole('ROLE_ADMIN')")

//user




Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,15 @@ public String sendMail(@PathVariable("userId") Integer userId) {
boolean result = this.emailService.sendEmail("OTP Verification","Your OTP to change your password is \t"+ otp +"\tuse it to create a new password.", 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.");
return new ResponseEntity(null,HttpStatus.ACCEPTED);
}
else{
return new ResponseEntity(null,HttpStatus.BAD_REQUEST);
}
}
else{
return null;
return new ResponseEntity(null,HttpStatus.NOT_ACCEPTABLE);

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ public Collection<User> list(Principal p) {
public Collection<User> viewProfile(){
return userService.viewProfile(SecurityUtil.getCurrentUserId());
}
@GetMapping("/admin/viewProfile/")
public Collection<User> viewAdminProfile(){
return userService.viewProfile(SecurityUtil.getCurrentUserId());
}

@PutMapping("/{userId}")
public UserView updates(
Expand Down Expand Up @@ -102,7 +106,7 @@ public Collection getUserById(



@GetMapping("admin/pagenated/")
@GetMapping("/admin/pagenated/")
public ResponseEntity<Page<User>>getAllBooks(
@RequestParam(defaultValue = "1") Integer pageNo,
@RequestParam(defaultValue = "10") Integer pageSize,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@

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

import java.time.LocalDate;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -42,13 +37,12 @@
import com.innovature.Library.view.BorrowListView;
import com.innovature.Library.view.rentChartView;

import java.util.List;


@Service
public class BorrowServiceImpl implements BorrowService {

// @Autowired
// private JavaMailSender mailSender;

@Autowired
private JavaMailSender mailSender;

Expand All @@ -61,15 +55,13 @@ public class BorrowServiceImpl implements BorrowService {
@Autowired
UserRepository userRepository;

// private Object mailSender;


@Override
public BorrowDetailView add(BorrowForm form) {
Books books = booksRepository.findByBooksId(form.getBooksId());
User user = userRepository.findById(SecurityUtil.getCurrentUserId());
// String status= form.setStatus("REQUESTED");
// return new BorrowDetailView(borrowRepository.save(new
// Borrow(form,books,user)));


return new BorrowDetailView(borrowRepository.save(new Borrow(books, user)));

Expand Down Expand Up @@ -155,13 +147,7 @@ public BorrowDetailView updates(Integer borrowId, BorrowForm form) {
public BorrowDetailView updatereject(Integer borrowId, BorrowForm form) {

Borrow borrow = borrowRepository.findByBorrowId(borrowId);
// Books books=booksRepository.findByBooksId(borrowId);

// borrow.setIssueDate("NA");
// borrow.setDueDate("NA");
// borrow.setReturnDate("NA");
// String status= form.setStatus("REQUESTED");
// category.setCategoryName(form.getCategoryName());
borrow.setReason(form.getReason());
borrow.setIssueDate(null);
borrow.setReturnDate(null);
Expand Down Expand Up @@ -228,7 +214,7 @@ public List<Borrow> getAllBorrow(java.sql.Date date1, java.sql.Date date2, Integ
public Page<Borrow> getAllBor(java.sql.Date date1, java.sql.Date date2, Integer pageNo, Integer pageSize,
String sortBy, Integer direction) {

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

var sortByDescending = Sort.by(sortBy).descending();
var sortByAscending = Sort.by(sortBy).ascending();

Expand All @@ -245,9 +231,7 @@ public Page<Borrow> getAllBor(java.sql.Date date1, java.sql.Date date2, Integer
return pagedResult;
}

// Page<Borrow> pagedResult =
// borrowRepository.findbyIssuDat(date1,date2,paging);
// return pagedResult;


}

Expand Down Expand Up @@ -287,7 +271,7 @@ public Page<Borrow> getAllBorr(Integer pageNo, Integer pageSize, String sortBy,
Page<Borrow> pagedResult = borrowRepository.findAll(paging);
return pagedResult;
}
// return pagedResult;


}

Expand All @@ -306,37 +290,13 @@ public List<Borrow> getBorrowHistory(Integer pageNo, Integer pageSize, String so
}
}

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

// mail//
// @Override
// @Transactional
// @Scheduled(cron="*/50 * * * * * ")
// public void sendMail(Integer userId,String subject,String text) {
// System.out.println("ssss");
// // User user = userRepository.findByUserId(userId);
// User user=userRepository.findById(userId);

// SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
// simpleMailMessage.setFrom("bookstore.shopp@gmail.com");
// simpleMailMessage.setTo(user.getEmail());
// simpleMailMessage.setSubject(subject);
// simpleMailMessage.setText(text);

// this.mailSender.send(simpleMailMessage);
// }

@Override
@Transactional
// @Scheduled(cron="* */1 * * * * ")
@Scheduled(cron = "0 0 12 * * ?")
public void sendMails() {
System.out.println("Email sent successfully");

// User user=userRepository.findById(userId);

Collection<Borrow> borrow = borrowRepository.findbyBorrowIdandStatus();
for (Borrow bor : borrow) {
User user = userRepository.findById(bor.getUser().getUserId()); // fetching uid from user
Expand All @@ -363,14 +323,11 @@ public void sendMail(Integer userId, String subject, String text) {
@Transactional
// @Scheduled(cron="* */1 * * * * ")
@Scheduled(cron = "0 0 10 * * ?")
public void fineGeneration() {
System.out.println("reachllllllllllllll");
public void fineGeneration() {

Collection<Borrow> borrow = borrowRepository.findbyBorrowId();
System.out.println("hereeeeeeeeeeeeeee");

for (Borrow bor : borrow) {
System.out.println(bor.getBorrowId());

Date d = new Date();
Long due = d.getTime() - bor.getDueDate().getTime(); // date conversion to time
due = due / 86400000; // time conversion to date
Expand Down Expand Up @@ -401,11 +358,9 @@ public rentChartView getChart() {

for (Borrow a : s) {
if(a.getIssueDate()!=null) {

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


hm.put(b.getDayOfWeek().getValue(), new Result(hm.get(b.getDayOfWeek().getValue()).getIssueCount() + 1,
hm.get(b.getDayOfWeek().getValue()).getReturnedCount()));
Expand All @@ -416,12 +371,10 @@ public rentChartView getChart() {
if (a.getStatus().equals("RETURNED")) {

c = a.getBookReturnedDate();
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());
}
}
for (Map.Entry<Integer, Result> mapElement : hm.entrySet()) {
Expand Down Expand Up @@ -518,7 +471,7 @@ else if (direction == -1 && status == 2) {
public BorrowDetailView updatePaymentStatus(Integer borrowId, BorrowForm form) {

Borrow borrow = borrowRepository.findByBorrowId(borrowId);
Books books = booksRepository.findbyBorrowId(borrowId);


borrow.setPaymentStatus("PAID");
return new BorrowDetailView(borrowRepository.save(borrow));
Expand All @@ -530,19 +483,6 @@ public List<Borrow> listcsv() {
}


// @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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.innovature.Library.view;

//import com.innovature.Library.entity.Books;

import com.innovature.Library.entity.Category;

public class BooksListView {
Expand All @@ -9,7 +9,6 @@ public class BooksListView {
private CategoryDetailView category;
private final String publication;
private final String auther;
// private final String status;
private final Integer booksCopies;
private String image;

Expand All @@ -21,21 +20,11 @@ public BooksListView(int booksId, String booksName,Category category,String publ
this.category = new CategoryDetailView(category);
this.publication = publication;
this.auther = auther;
// this.status = status;
this.image=image;


this.booksCopies = booksCopies;
}
// public BooksListView(int booksId, String booksName,Integer categoryId,String categoryName,String publication,String auther,String booksCopies)
// {

// this.booksId = booksId;
// this.booksName = booksName;
// this.category = new Category(categoryId,categoryName);
// this.publication = publication;
// this.auther = auther;
// // this.status = status;
// this.booksCopies = booksCopies;
// }




Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.innovature.Library.view;

// import java.util.Date;


import com.innovature.Library.entity.Borrow;

Expand Down
27 changes: 7 additions & 20 deletions FrontEnd/Library/src/app/acceptrequest/acceptrequest.component.css
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
p{
padding: 0px 0px 30px 1000px;
margin: 0px;
background-color: rgb(0, 0, 0);
/* background-image: url('../../../a.png'); */

}

.btnhome{
margin-top: 20px;
margin-bottom: 10px;
padding: 7;
border-color: rgb(124, 241, 134);
background-color: rgba(83, 254, 3, 0.853);
font-size: 13px;
border-radius: 25px;

}

.text-danger1{

Expand All @@ -41,11 +23,11 @@ p{
border-radius: 7px;
}
.btn{
width: 150%;
width: 100%;
padding: 7px 2px;
margin: 5px ;
box-sizing: border-box;
border: 2px solid rgb(250, 97, 97);
border: 2px solid rgb(27, 26, 26);
background-color:rgba(106, 215, 56, 0.682);
color: rgb(0, 0, 0);
border-radius: 7px;
Expand Down Expand Up @@ -78,3 +60,8 @@ th {
color: rgb(255, 255, 255);
border-radius: 3px;
}
table{
text-align: center;
/* margin-left: 40%;
margin-top:5%; */
}
Loading