去除权限控制
This commit is contained in:
@@ -6,3 +6,6 @@ scp bill-1.0.0-SNAPSHOT.jar me:~/bill-service
|
||||
#scp bill-1.0.0-SNAPSHOT.jar gc:/tmp
|
||||
#ssh gc "sudo cp /tmp/bill-1.0.0-SNAPSHOT.jar /home/bill/service ; sudo sh /home/bill/service/run.sh"
|
||||
|
||||
ssh me "sh ~/bill-service/run.sh"
|
||||
|
||||
|
||||
|
||||
@@ -28,14 +28,14 @@ public class MerchantController {
|
||||
|
||||
@RequestMapping(value = "/merchants",method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasAnyAuthority('admin','merchant:all','merchant:create','book:create','book:create')")
|
||||
//@PreAuthorize("hasAnyAuthority('admin','merchant:all','merchant:create','book:create','book:create')")
|
||||
public ResponseEntity create(@RequestBody Merchant resources) {
|
||||
return new ResponseEntity(merchantRepo.saveAndFlush(resources), HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/merchants",method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasAnyAuthority('admin','merchant:all','merchant:select','book:create','book:update')")
|
||||
//@PreAuthorize("hasAnyAuthority('admin','merchant:all','merchant:select','book:create','book:update')")
|
||||
public ResponseEntity<List<Merchant>> fetchMerchants() {
|
||||
return ResponseEntity.ok(merchantRepo.findAllByEnabledIsTrue());
|
||||
}
|
||||
@@ -43,7 +43,7 @@ public class MerchantController {
|
||||
|
||||
@RequestMapping(value = "/merchants/{id}",method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasAnyAuthority('admin','merchant:all','merchant:select')")
|
||||
//@PreAuthorize("hasAnyAuthority('admin','merchant:all','merchant:select')")
|
||||
public ResponseEntity<Merchant> getMerchant(@PathVariable long id){
|
||||
Optional<Merchant> merchant = merchantRepo.findById(id);
|
||||
if(merchant.isPresent()){
|
||||
|
||||
@@ -34,14 +34,14 @@ public class PermissionController {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/permissions/tree")
|
||||
@PreAuthorize("hasAnyAuthority('admin','permission:all','permission:select')")
|
||||
//@PreAuthorize("hasAnyAuthority('admin','permission:all','permission:select')")
|
||||
public ResponseEntity getTree(){
|
||||
return new ResponseEntity(permissionService.getPermissionTree(permissionService.findByPid(0L)), HttpStatus.OK);
|
||||
}
|
||||
|
||||
// @Log("查询权限")
|
||||
@GetMapping(value = "/permissions")
|
||||
@PreAuthorize("hasAnyAuthority('admin','permission:all','permission:select')")
|
||||
//@PreAuthorize("hasAnyAuthority('admin','permission:all','permission:select')")
|
||||
public ResponseEntity getPermissions(CommonQueryCriteria criteria){
|
||||
List<PermissionDTO> permissionDTOS = permissionService.queryAll(criteria);
|
||||
Object obj = permissionService.buildTree(permissionDTOS);
|
||||
@@ -63,7 +63,7 @@ public class PermissionController {
|
||||
|
||||
// @Log("修改权限")
|
||||
@PutMapping(value = "/permissions")
|
||||
@PreAuthorize("hasAnyAuthority('admin','permission:all','permission:update')")
|
||||
//@PreAuthorize("hasAnyAuthority('admin','permission:all','permission:update')")
|
||||
public ResponseEntity update(@Validated(Permission.Update.class) @RequestBody Permission resources){
|
||||
permissionService.update(resources);
|
||||
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
||||
@@ -71,7 +71,7 @@ public class PermissionController {
|
||||
|
||||
// @Log("删除权限")
|
||||
@DeleteMapping(value = "/permissions/{id}")
|
||||
@PreAuthorize("hasAnyAuthority('admin','permission:all','permission:delete')")
|
||||
//@PreAuthorize("hasAnyAuthority('admin','permission:all','permission:delete')")
|
||||
public ResponseEntity delete(@PathVariable Long id){
|
||||
permissionService.delete(id);
|
||||
return new ResponseEntity(HttpStatus.OK);
|
||||
|
||||
@@ -28,7 +28,7 @@ public class PostController {
|
||||
|
||||
@RequestMapping(value = "/posts",method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasAnyAuthority('admin','post:all','post:create','book:create','book:edit')")
|
||||
//@PreAuthorize("hasAnyAuthority('admin','post:all','post:create','book:create','book:edit')")
|
||||
public ResponseEntity create(@RequestBody Post post) {
|
||||
// public ResponseEntity<Post> create(@RequestBody NewPost newPost) {
|
||||
// JwtUser authUser = (JwtUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||
@@ -44,7 +44,7 @@ public class PostController {
|
||||
|
||||
@RequestMapping(value = "/posts",method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasAnyAuthority('admin','post:all','post:select','book:create','book:edit')")
|
||||
//@PreAuthorize("hasAnyAuthority('admin','post:all','post:select','book:create','book:edit')")
|
||||
public ResponseEntity<List<Post>> fetch() {
|
||||
// JwtUser authUser = (JwtUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||
// long userId = authUser.getId();
|
||||
@@ -54,7 +54,7 @@ public class PostController {
|
||||
|
||||
@RequestMapping(value = "/posts/{id}",method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasAnyAuthority('admin','post:all','post:select')")
|
||||
//@PreAuthorize("hasAnyAuthority('admin','post:all','post:select')")
|
||||
public ResponseEntity<Post> get(@PathVariable long id){
|
||||
log.info("post id:" + id);
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public class RoleController {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/roles/{id}")
|
||||
@PreAuthorize("hasAnyAuthority('admin','role:all','role:select')")
|
||||
//@PreAuthorize("hasAnyAuthority('admin','role:all','role:select')")
|
||||
public ResponseEntity getRoles(@PathVariable Long id){
|
||||
return new ResponseEntity(roleService.findById(id), HttpStatus.OK);
|
||||
}
|
||||
@@ -50,14 +50,14 @@ public class RoleController {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/roles/all")
|
||||
@PreAuthorize("hasAnyAuthority('admin','role:all','user:all','user:create','user:edit')")
|
||||
//@PreAuthorize("hasAnyAuthority('admin','role:all','user:all','user:create','user:edit')")
|
||||
public ResponseEntity getAll(@PageableDefault(value = 2000, sort = {"level"}, direction = Sort.Direction.ASC) Pageable pageable){
|
||||
return new ResponseEntity(roleService.queryAll(pageable), HttpStatus.OK);
|
||||
}
|
||||
|
||||
// @Log("查询角色")
|
||||
@GetMapping(value = "/roles")
|
||||
@PreAuthorize("hasAnyAuthority('admin','role:all','role:select')")
|
||||
//@PreAuthorize("hasAnyAuthority('admin','role:all','role:select')")
|
||||
public ResponseEntity getRoles(CommonQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity(roleService.queryAll(criteria,pageable), HttpStatus.OK);
|
||||
}
|
||||
@@ -70,7 +70,7 @@ public class RoleController {
|
||||
|
||||
// @Log("新增角色")
|
||||
@PostMapping(value = "/roles")
|
||||
@PreAuthorize("hasAnyAuthority('admin','role:all','role:create')")
|
||||
//@PreAuthorize("hasAnyAuthority('admin','role:all','role:create')")
|
||||
public ResponseEntity create(@Validated @RequestBody Role resources){
|
||||
if (resources.getId() != null) {
|
||||
throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID");
|
||||
@@ -81,7 +81,7 @@ public class RoleController {
|
||||
|
||||
// @Log("修改角色")
|
||||
@PutMapping(value = "/roles")
|
||||
@PreAuthorize("hasAnyAuthority('admin','role:all','role:update')")
|
||||
//@PreAuthorize("hasAnyAuthority('admin','role:all','role:update')")
|
||||
public ResponseEntity update(@Validated(Role.Update.class) @RequestBody Role resources){
|
||||
roleService.update(resources);
|
||||
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
||||
@@ -89,7 +89,7 @@ public class RoleController {
|
||||
|
||||
// @Log("修改角色权限")
|
||||
@PutMapping(value = "/roles/permission")
|
||||
@PreAuthorize("hasAnyAuthority('admin','role:all','role:update')")
|
||||
//@PreAuthorize("hasAnyAuthority('admin','role:all','role:update')")
|
||||
public ResponseEntity updatePermission(@RequestBody Role resources){
|
||||
roleService.updatePermission(resources,roleService.findById(resources.getId()));
|
||||
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
||||
@@ -97,7 +97,7 @@ public class RoleController {
|
||||
|
||||
// @Log("修改角色菜单")
|
||||
@PutMapping(value = "/roles/menu")
|
||||
@PreAuthorize("hasAnyAuthority('admin','role:all','role:update')")
|
||||
//@PreAuthorize("hasAnyAuthority('admin','role:all','role:update')")
|
||||
public ResponseEntity updateMenu(@RequestBody Role resources){
|
||||
roleService.updateMenu(resources,roleService.findById(resources.getId()));
|
||||
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
||||
@@ -105,7 +105,7 @@ public class RoleController {
|
||||
|
||||
// @Log("删除角色")
|
||||
@DeleteMapping(value = "/roles/{id}")
|
||||
@PreAuthorize("hasAnyAuthority('admin','role:all','role:delete')")
|
||||
//@PreAuthorize("hasAnyAuthority('admin','role:all','role:delete')")
|
||||
public ResponseEntity delete(@PathVariable Long id){
|
||||
roleService.delete(id);
|
||||
return new ResponseEntity(HttpStatus.OK);
|
||||
|
||||
@@ -28,21 +28,21 @@ public class TitleController {
|
||||
|
||||
@RequestMapping(value = "/titles",method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasAnyAuthority('admin','title:all','title:create','book:create','book:edit')")
|
||||
//@PreAuthorize("hasAnyAuthority('admin','title:all','title:create','book:create','book:edit')")
|
||||
public ResponseEntity<Title> create(@RequestBody Title resources) {
|
||||
return ResponseEntity.ok(titleRepo.saveAndFlush(resources));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/titles",method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasAnyAuthority('admin','title:all','title:select','book:create','book:edit')")
|
||||
//@PreAuthorize("hasAnyAuthority('admin','title:all','title:select','book:create','book:edit')")
|
||||
public ResponseEntity<List<Title>> fetch() {
|
||||
return ResponseEntity.ok(titleRepo.findAll());
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/titles/{id}",method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
@PreAuthorize("hasAnyAuthority('admin','title:all','title:select')")
|
||||
//@PreAuthorize("hasAnyAuthority('admin','title:all','title:select')")
|
||||
public ResponseEntity<Title> get(@PathVariable long id){
|
||||
/** 登记 Title */
|
||||
Optional<Title> title = titleRepo.findById(id);
|
||||
|
||||
@@ -86,7 +86,7 @@ public class UserController {
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/users", method = RequestMethod.PUT)
|
||||
@PreAuthorize("hasAnyAuthority('admin','user:all','user:update')")
|
||||
//@PreAuthorize("hasAnyAuthority('admin','user:all','user:update')")
|
||||
public ResponseEntity update(@Validated(User.Update.class) @RequestBody User resources){
|
||||
checkLevel(resources);
|
||||
userService.update(resources);
|
||||
@@ -100,7 +100,7 @@ public class UserController {
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/users/{id}", method = RequestMethod.DELETE)
|
||||
@PreAuthorize("hasAnyAuthority('admin','user:all','user:delete')")
|
||||
//@PreAuthorize("hasAnyAuthority('admin','user:all','user:delete')")
|
||||
public ResponseEntity delete(@PathVariable Long id){
|
||||
// Integer currentLevel = Collections.min(roleService.findByUser_Id(SecurityUtils.getUserId()).stream().map(RoleSmallDTO::getLevel).collect(Collectors.toList()));
|
||||
// Integer optLevel = Collections.min(roleService.findByUser_Id(id).stream().map(RoleSmallDTO::getLevel).collect(Collectors.toList()));
|
||||
@@ -119,7 +119,7 @@ public class UserController {
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/users", method = RequestMethod.GET)
|
||||
@PreAuthorize("hasAnyAuthority('admin','user:all','user:select')")
|
||||
//@PreAuthorize("hasAnyAuthority('admin','user:all','user:select')")
|
||||
public ResponseEntity getUsers(UserQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity(userService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
// Set<Long> deptSet = new HashSet<>();
|
||||
@@ -160,7 +160,7 @@ public class UserController {
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/users/updatePassword",method = RequestMethod.POST)
|
||||
@PreAuthorize("hasAnyAuthority('admin','user:all','user:update')")
|
||||
//@PreAuthorize("hasAnyAuthority('admin','user:all','user:update')")
|
||||
public ResponseEntity updatePass(@RequestBody User user){
|
||||
UserDetails userDetails = (JwtUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user