Skip to content
Open

Arun #39

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
7316a13
modified
Rorschach-ar Jan 19, 2023
51d291e
login
Rorschach-ar Jan 20, 2023
ba5c362
Merge pull request #29 from negilbabu/Development
Rorschach-ar Jan 20, 2023
63fe44a
UI
Rorschach-ar Jan 20, 2023
5a9f612
alignment
negilbabu Jan 23, 2023
f43ba6a
Delete FrontEnd/node_modules directory
negilbabu Jan 23, 2023
68e1f5f
Delete package-lock.json
negilbabu Jan 23, 2023
d5aa809
Delete package.json
negilbabu Jan 23, 2023
680ebea
testing
negilbabu Jan 23, 2023
f6e61a2
Merge pull request #31 from negilbabu/Negil
negilbabu Jan 23, 2023
47e9733
Merge pull request #32 from negilbabu/Arun
negilbabu Jan 23, 2023
9a11d42
Merge pull request #33 from negilbabu/Development
negilbabu Jan 23, 2023
664a169
baseUrl
negilbabu Jan 23, 2023
d241089
css
negilbabu Jan 23, 2023
4a9de72
modifications
Rorschach-ar Jan 24, 2023
aa99534
modifications
Rorschach-ar Jan 24, 2023
2745394
testing
negilbabu Jan 24, 2023
90a10ca
Merge pull request #35 from negilbabu/Negil
negilbabu Jan 24, 2023
fb40b46
testing
negilbabu Jan 24, 2023
34c149f
Merge pull request #36 from negilbabu/Negil
negilbabu Jan 24, 2023
e38170a
email
negilbabu Jan 25, 2023
a973ffe
expiry
negilbabu Jan 25, 2023
07c4594
testing
negilbabu Jan 25, 2023
b427358
modification
Rorschach-ar Jan 27, 2023
21d1629
merge conflit
Rorschach-ar Jan 27, 2023
b1c1fc9
Merge branch 'Development' into Arun
Rorschach-ar Jan 30, 2023
27a6eec
Merge pull request #37 from negilbabu/Arun
Rorschach-ar Jan 30, 2023
9f7fc4f
baseurl
Rorschach-ar Jan 30, 2023
90b05ed
addbook
Rorschach-ar Jan 30, 2023
365311d
Accept request
Rorschach-ar Jan 30, 2023
88339de
user reg
Rorschach-ar Jan 30, 2023
19ef90c
Merge pull request #41 from negilbabu/Development
Rorschach-ar Jan 30, 2023
54191fe
Merge pull request #42 from negilbabu/Arun
Rorschach-ar Jan 30, 2023
65257fe
Merge pull request #43 from negilbabu/Development
negilbabu Jan 30, 2023
44fd9ee
testing
negilbabu Jan 30, 2023
5fd6a5f
Merge pull request #44 from negilbabu/Negil
negilbabu Jan 30, 2023
2927202
Merge pull request #45 from negilbabu/Development
Rorschach-ar Jan 30, 2023
44cf383
ui
negilbabu Jan 30, 2023
82ddaa4
Merge pull request #46 from negilbabu/Negil
negilbabu Jan 30, 2023
0432e28
Merge pull request #47 from negilbabu/Development
Rorschach-ar Jan 30, 2023
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 @@ -69,8 +69,27 @@ public Collection<Borrow> list() {
return new ResponseEntity<Page<Borrow>>(list,new HttpHeaders(),
HttpStatus.OK);



}

@GetMapping("/admin/statusFilter/")
public ResponseEntity<Page<Borrow>>getAllBorrowByStatus(
@RequestParam(defaultValue = "1") Integer pageNo,
@RequestParam(defaultValue = "5") Integer pageSize,
@RequestParam(defaultValue = "borrowId") String sortBy,
@RequestParam(defaultValue = "1") Integer direction,
@RequestParam(defaultValue = "1") Integer status)
{
Page<Borrow> list = bService.getAllBorrByStat(pageNo-1, pageSize, sortBy,direction,status);
return new ResponseEntity<Page<Borrow>>(list,new HttpHeaders(),
HttpStatus.OK);



}



//BORROW @ADMIN //pagenated borrow list at admin VIEW borrow single api
@GetMapping("/admin/pagenated/")
Expand Down Expand Up @@ -166,6 +185,20 @@ public Collection<Borrow> listDue() {
}


@GetMapping("/admin/fine/")
public ResponseEntity<Page<Borrow>>listfine(
@RequestParam(defaultValue = "1") Integer pageNo,
@RequestParam(defaultValue = "5") Integer pageSize,
@RequestParam(defaultValue = "borrowId") String sortBy,
@RequestParam(defaultValue = "1") Integer direction)
{
Page<Borrow> list = bService.getAllFine(pageNo-1, pageSize, sortBy,direction);
return new ResponseEntity<Page<Borrow>>(list,new HttpHeaders(),
HttpStatus.OK);

}


@GetMapping("admin/fine")
public Collection<Borrow> listfine() {
return bService.fine();
Expand Down Expand Up @@ -238,7 +271,7 @@ public BorrowDetailView undo(




//chart
@GetMapping("/admin/chart")
public rentChartView getchart(){
rentChartView test =borrowServices.getChart();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.innovature.Library.controller;


import java.util.Random;

import java.time.LocalTime;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
Expand All @@ -11,21 +14,17 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import com.innovature.Library.form.EmailForm;
import com.innovature.Library.form.OtpForm;
import com.innovature.Library.repository.EmailRepository;
import com.innovature.Library.service.BorrowService;
import com.innovature.Library.service.EmailService;



import com.innovature.Library.entity.Email;
import com.innovature.Library.entity.User;
import com.innovature.Library.repository.UserRepository;


// tgsrhyrsrthr
@RestController
@RequestMapping("/email")
public class EmailController {
Expand Down Expand Up @@ -58,41 +57,137 @@ public String sendMail(@PathVariable("userId") Integer userId) {


@PostMapping("/emailsentotp")
public ResponseEntity<?>sendOtpEmail(@RequestBody EmailForm form){
public ResponseEntity sendOtpEmail(@RequestBody EmailForm form){
String emailid=form.getSentto();

if("".equals(emailid) ){

return ResponseEntity.status(HttpStatus.NOT_ACCEPTABLE).body("NULL VALUE EXCEPTION-");
}
else{
User user=userRepository.findByEmailId(form.getSentto());
if(user!=null){
emailRepository.deleteAll();

Random random = new Random();
int otp = 100000 + random.nextInt(900000);
Email otp2= new Email();
otp2.setOtp(otp);
otp2.setEmail(form.getSentto());
otp2.setEmail(form.getSentto());

LocalTime myObj = LocalTime.now();
LocalTime exp=myObj;
otp2.setExpiry(exp);

emailRepository.save(otp2);
var email=form.getSentto();
Email email2= emailRepository.findByEmail(email);

if(email2!=null){
email2.setOtp(otp);
email2.setExpiry(exp);
emailRepository.save(email2);
}
else
emailRepository.save(otp2);

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.EXPECTATION_FAILED);
}
}
else{
return null;
return new ResponseEntity(null,HttpStatus.BAD_REQUEST);

}

}


}


@PostMapping("verify")
public ResponseEntity add(@RequestBody OtpForm form){
var otp=form.getOtp();
if(otp==null){
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("NULL VALUE EXCEPTION");
}
else{

ResponseEntity result = emailService.add(form);

if(result.getStatusCodeValue()==202){
return new ResponseEntity(HttpStatus.ACCEPTED);

}
else if(result.getStatusCodeValue()==504){
return ResponseEntity.status(HttpStatus.GATEWAY_TIMEOUT).body("OTP EXPIRED");
}

else
return ResponseEntity.status(HttpStatus.NOT_ACCEPTABLE).body("OTP VERIFICATION FAILED");
}
}

@PostMapping("verify")
public boolean add(@RequestBody OtpForm form){

return emailService.add(form);
// @PostMapping("verify")
// public ResponseEntity add(@RequestBody OtpForm form){
// var otp=form.getOtp();
// if(otp==null){
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("NULL VALUE EXCEPTION");
// }
// else{

// boolean result = emailService.add(form);
// if(result)
// {
// return new ResponseEntity(null,HttpStatus.ACCEPTED);
// // return new ResponseEntity.status(HttpStatus.ACCEPTED).body("OTP VERIFICATION SUCCESS");
// }
// else
// {
// // return new ResponseEntity(null,HttpStatus.BAD_REQUEST);

// return ResponseEntity.status(HttpStatus.NOT_ACCEPTABLE).body("OTP VERIFICATION FAILED");
// }
// }
// }



@PostMapping("verifyPassword")
public ResponseEntity addPassword(@RequestBody OtpForm form){

var psd=form.getNewPassword();
var npsd=form.getCnewPassword();

if(psd==null || npsd==null){
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("NULL VALUE EXCEPTION");
}
else if(!psd.equals(npsd) ){
return ResponseEntity.status(HttpStatus.BAD_GATEWAY).body("PASSWORD MISSMATCH");
}
else{

boolean result = emailService.addPassword(form);
if(result)
{
return new ResponseEntity(null,HttpStatus.ACCEPTED);
}
else
{
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("PASSWORD CHANGE FAILED");
}
}






}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package com.innovature.Library.controller;

import java.security.Principal;
Expand All @@ -13,29 +9,22 @@
import org.springframework.http.HttpStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.HttpEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils;


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 java.util.Collection;
import javax.validation.Valid;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
// 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.RestController;


import com.innovature.Library.entity.User;
// import com.innovature.Library.entity.User;
import com.innovature.Library.form.UserForm;
import com.innovature.Library.security.util.SecurityUtil;
import com.innovature.Library.service.UserService;
Expand Down Expand Up @@ -73,6 +62,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 All @@ -87,11 +80,6 @@ public void deletes(
userService.deletes(userId);
}

// @GetMapping("/{userId}")
// public void deletes(
// @PathVariable("userId") Integer userId) {
// userService.deletes(userId);
// }


@GetMapping("/admin/{userId}")
Expand All @@ -102,7 +90,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
Loading