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
9 changes: 9 additions & 0 deletions BackEnd/Library/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.8</version>
</dependency>



</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;

import static org.springframework.http.HttpMethod.DELETE;
import static org.springframework.http.HttpMethod.GET;
import static org.springframework.http.HttpMethod.OPTIONS;
import static org.springframework.http.HttpMethod.POST;
import static org.springframework.http.HttpMethod.PUT;
Expand Down Expand Up @@ -54,11 +57,37 @@ protected void configure(HttpSecurity http) throws Exception {
.antMatchers(POST, "/users").anonymous()
.antMatchers(OPTIONS, "/login").anonymous()
.antMatchers(POST, "/login").anonymous()
.antMatchers(POST, "/email/**").anonymous()
.antMatchers(PUT, "/login").anonymous()
.antMatchers(OPTIONS, "/**").anonymous()
.antMatchers(OPTIONS, "/**").anonymous()

//category
.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')")

//books
.antMatchers(GET,"/books/admin/**/").access("hasRole('ROLE_ADMIN')")
.antMatchers(GET,"/books/user/**/").access("hasRole('ROLE_USER')")
.antMatchers(POST,"/books").access("hasRole('ROLE_ADMIN')")
.antMatchers(DELETE,"/books/{booksId}").access("hasRole('ROLE_ADMIN')")
.antMatchers(PUT,"/books/{booksId}").access("hasRole('ROLE_ADMIN')")


//borrow
.antMatchers(GET,"/borrow/admin/**").access("hasRole('ROLE_ADMIN')")
.antMatchers(GET,"/borrow/user/**/").access("hasRole('ROLE_USER')")
.antMatchers(POST,"/borrow/").access("hasRole('ROLE_USER')")
.antMatchers(PUT,"/borrow/admin/**").access("hasRole('ROLE_ADMIN')")





.anyRequest().authenticated();



}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.springframework.http.HttpHeaders;
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;
Expand Down Expand Up @@ -52,12 +53,12 @@ public BooksDetailView add(@Valid @RequestBody BooksForm form) {
return service.add(form);
}

@GetMapping
@GetMapping("/admin")
public Collection<Books> list() {
return service.listAll();
}

@GetMapping("/findByCategory/{categoryId}")
@GetMapping("user/findByCategory/{categoryId}")
public Collection<Books> listByCategory(
@PathVariable("categoryId") Integer categoryId)
{
Expand Down Expand Up @@ -90,18 +91,31 @@ public BooksDetailView update(



@GetMapping("/pagenated/")
public ResponseEntity<List<Books>>getAllBooks(
@RequestParam(defaultValue = "0") Integer pageNo,
@GetMapping("admin/pagenated/")
public ResponseEntity<Page<Books>>getAllBooks(
@RequestParam(defaultValue = "1") Integer pageNo,
@RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(defaultValue = "id") String sortBy)
@RequestParam(defaultValue = "auther") String sortBy,
@RequestParam(defaultValue = "1") Integer direction)
{
List<Books> list = service.getAllBooks(pageNo-1, pageSize, sortBy);
return new ResponseEntity<List<Books>>(list,new HttpHeaders(),
Page<Books> list = service.getAllBooks(pageNo-1, pageSize, sortBy,direction);
return new ResponseEntity<Page<Books>>(list,new HttpHeaders(),
HttpStatus.OK);

}

@GetMapping("user/pagenated/")
public ResponseEntity<Page<Books>>getAllBooksforUser(
@RequestParam(defaultValue = "1") Integer pageNo,
@RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(defaultValue = "auther") String sortBy,
@RequestParam(defaultValue = "1") Integer direction)
{
Page<Books> list = service.getAllBooks(pageNo-1, pageSize, sortBy,direction);
return new ResponseEntity<Page<Books>>(list,new HttpHeaders(),
HttpStatus.OK);

}



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
Expand Down Expand Up @@ -47,55 +48,96 @@ public Collection<Borrow> list() {


//pagenated borrow list at admin borrow
@GetMapping("/pagenated/")
public ResponseEntity<List<Borrow>>getAllBorrows(
// @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);

// }

//BORROW @ADMIN //pagenated borrow list at admin VIEW borrow single api
@GetMapping("/admin/pagenated/")
public ResponseEntity<Page<Borrow>>getAllBorTest(
@RequestParam(defaultValue = "1") Integer pageNo,
@RequestParam(defaultValue = "5") Integer pageSize,
@RequestParam(defaultValue = "id") String sortBy)
@RequestParam(defaultValue = "borrowId") String sortBy,
@RequestParam(defaultValue = "1") Integer direction)
{
List<Borrow> list = bService.getAllBorrows(pageNo-1, pageSize, sortBy);
return new ResponseEntity<List<Borrow>>(list,new HttpHeaders(),
Page<Borrow> list = bService.getAllBorr(pageNo-1, pageSize, sortBy,direction);
return new ResponseEntity<Page<Borrow>>(list,new HttpHeaders(),
HttpStatus.OK);

}


//load results of issuedate filter
@GetMapping("/loadByIssueDate/{date1}/{date2}")
public ResponseEntity<List<Borrow>> loadByIssueDate(
@PathVariable("date1") Date date1,
@PathVariable("date2") Date date2)
//LOAD-FILTER@ADMIN//load results of issuedate filter at Admin Borrow
// @GetMapping("/loadByIssueDate/{date1}/{date2}")
// public ResponseEntity<List<Borrow>> loadByIssueDate(
// @PathVariable("date1") Date date1,
// @PathVariable("date2") Date date2)

// {
// List<Borrow> list = bService.loadtAllByIssueDate(date1, date2);
// return new ResponseEntity<List<Borrow>>(list,new HttpHeaders(),
// HttpStatus.OK);
// }


//GET FILTER RESULT@ADMIN//filtered pagenated borrow list [on filtering] @admin//
// @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)
// {
// return bService.loadtAllByIssueDate(Date date1, Date date2);

// List<Borrow> list = bService.getAllBorrow(date1, date2,pageNo-1, pageSize, sortBy);
// return new ResponseEntity<List<Borrow>>(list,new HttpHeaders(),
// HttpStatus.OK);

// }
{
List<Borrow> list = bService.loadtAllByIssueDate(date1, date2);
return new ResponseEntity<List<Borrow>>(list,new HttpHeaders(),
HttpStatus.OK);
}

//GET FILTER RESULT@ADMIN//filtered single api
@GetMapping("/admin/{date1}/{date2}")
public ResponseEntity<Page<Borrow>>getTestFilterBorrow(
// @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 = "borrow_id") String sortBy,
@RequestParam(defaultValue = "1") Integer direction)
{

Page<Borrow> list = bService.getAllBor(date1, date2,pageNo-1, pageSize, sortBy,direction);
return new ResponseEntity<Page<Borrow>>(list,new HttpHeaders(), HttpStatus.OK);

}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//Load filtered pagenated borrow list [on filtering]
@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(date1, date2,pageNo-1, pageSize, sortBy);
return new ResponseEntity<List<Borrow>>(list,new HttpHeaders(),
HttpStatus.OK);

}

//load results of issuedate filter at User BorrowHistory
@GetMapping("user/loadByIssueDate/{date1}/{date2}")
public ResponseEntity<List<Borrow>> loadByIssueDateUser(
@PathVariable("date1") Date date1,
@PathVariable("date2") Date date2)

{
List<Borrow> list = bService.loadtAllByIssueDate(date1, date2);
return new ResponseEntity<List<Borrow>>(list,new HttpHeaders(),
HttpStatus.OK);
}


//pagenation+sort at user borrow history
Expand All @@ -111,7 +153,7 @@ public ResponseEntity<List<Borrow>> loadByIssueDate(

}


////////////////////////////////////////////////////////////////////////////////////



Expand All @@ -137,18 +179,28 @@ public Collection<Borrow> listUserNotification(Principal p) {



@GetMapping("/due")
@GetMapping("user/due")
public Collection<Borrow> listDue() {
return bService.listDue();
}


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

@GetMapping("/dueByUser")
@GetMapping("/borrowDetailView")
public Borrow BorrowDetail(Integer borrowId) {
return bService.BorrowDetail(borrowId);
}

@GetMapping("/borrowBlock")
public Integer BorrowBlock() {
return bService.BorrowBlock();
}

@GetMapping("user/dueByUser")
public Collection<Borrow> listDueByUser() {
return bService.listDueByUser();
}
Expand All @@ -167,7 +219,7 @@ public BorrowDetailView list(



@PutMapping("/{borrowId}")
@PutMapping("admin/accept/{borrowId}")
public BorrowDetailView updateApprove(
@PathVariable("borrowId") Integer borrowId,
@Valid @RequestBody BorrowForm form
Expand All @@ -176,7 +228,7 @@ public BorrowDetailView updateApprove(
}


@PutMapping("reject/{borrowId}")
@PutMapping("admin/reject/{borrowId}")
public BorrowDetailView updateReject(
@PathVariable("borrowId") Integer borrowId,
@Valid @RequestBody BorrowForm form
Expand All @@ -185,14 +237,14 @@ public BorrowDetailView updateReject(
}


@PutMapping("return/{borrowId}")
@PutMapping("admin/return/{borrowId}")
public BorrowDetailView updateReturn(
@PathVariable("borrowId") Integer borrowId,
@Valid @RequestBody BorrowForm form
) {
return bService.updateReturn(borrowId, form);
}
@PutMapping("undo/{borrowId}")
@PutMapping("admin/undo/{borrowId}")
public BorrowDetailView undo(
@PathVariable("borrowId") Integer borrowId,
@Valid @RequestBody BorrowForm form
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@
import java.util.Collection;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.innovature.Library.entity.Category;
Expand All @@ -25,11 +30,16 @@ public class CategoryController {
@Autowired
private CategoryService service;

@GetMapping
@GetMapping("/admin")
public Collection<Category> list(Principal p) {
return service.listAll();
}

@GetMapping("/user")
public Collection<Category> listforUser(Principal p) {
return service.listAll();
}


@PostMapping
public CategoryDetailView add(@Valid @RequestBody CategoryForm form) {
Expand Down Expand Up @@ -62,7 +72,18 @@ public CategoryDetailView list(
return service.list(catogoryId);
}

@GetMapping("admin/pagenated/")
public ResponseEntity<Page<Category>>getAllCategory(
@RequestParam(defaultValue = "1") Integer pageNo,
@RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(defaultValue = "categoryId") String sortBy,
@RequestParam(defaultValue = "1") Integer direction)
{
Page<Category> list = service.getAllCategory(pageNo-1, pageSize, sortBy,direction);
return new ResponseEntity<Page<Category>>(list,new HttpHeaders(),
HttpStatus.OK);

}



Expand Down
Loading