mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-12-17 17:19:42 +08:00
后台权限控制
This commit is contained in:
@@ -5,8 +5,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import xyz.playedu.api.bus.DepartmentBus;
|
||||
import xyz.playedu.api.constant.BPermissionConstant;
|
||||
import xyz.playedu.api.domain.Department;
|
||||
import xyz.playedu.api.exception.NotFoundException;
|
||||
import xyz.playedu.api.middleware.BackendPermissionMiddleware;
|
||||
import xyz.playedu.api.request.backend.DepartmentRequest;
|
||||
import xyz.playedu.api.service.DepartmentService;
|
||||
import xyz.playedu.api.types.JsonResponse;
|
||||
@@ -29,6 +31,7 @@ public class DepartmentController {
|
||||
@Autowired
|
||||
private DepartmentBus departmentBus;
|
||||
|
||||
@BackendPermissionMiddleware(slug = BPermissionConstant.DEPARTMENT_INDEX)
|
||||
@GetMapping("/index")
|
||||
public JsonResponse index() {
|
||||
Map<Integer, List<Department>> departments = departmentService.all().stream().collect(Collectors.groupingBy(Department::getParentId));
|
||||
@@ -39,12 +42,14 @@ public class DepartmentController {
|
||||
return JsonResponse.data(data);
|
||||
}
|
||||
|
||||
@BackendPermissionMiddleware(slug = BPermissionConstant.DEPARTMENT_STORE)
|
||||
@GetMapping("/create")
|
||||
public JsonResponse create(@RequestParam(name = "parent_id", defaultValue = "0") Integer parentId) {
|
||||
List<Department> data = departmentService.listByParentId(parentId);
|
||||
return JsonResponse.data(data);
|
||||
}
|
||||
|
||||
@BackendPermissionMiddleware(slug = BPermissionConstant.DEPARTMENT_STORE)
|
||||
@PostMapping("/create")
|
||||
public JsonResponse store(@RequestBody @Validated DepartmentRequest request) throws NotFoundException {
|
||||
String parentChain = "";
|
||||
@@ -65,12 +70,14 @@ public class DepartmentController {
|
||||
return JsonResponse.success();
|
||||
}
|
||||
|
||||
@BackendPermissionMiddleware(slug = BPermissionConstant.DEPARTMENT_UPDATE)
|
||||
@GetMapping("/{id}")
|
||||
public JsonResponse edit(@PathVariable Integer id) throws NotFoundException {
|
||||
Department department = departmentService.findOrFail(id);
|
||||
return JsonResponse.data(department);
|
||||
}
|
||||
|
||||
@BackendPermissionMiddleware(slug = BPermissionConstant.DEPARTMENT_UPDATE)
|
||||
@PutMapping("/{id}")
|
||||
public JsonResponse update(@PathVariable Integer id, @RequestBody DepartmentRequest request) throws NotFoundException {
|
||||
Department department = departmentService.findOrFail(id);
|
||||
@@ -78,6 +85,7 @@ public class DepartmentController {
|
||||
return JsonResponse.success();
|
||||
}
|
||||
|
||||
@BackendPermissionMiddleware(slug = BPermissionConstant.DEPARTMENT_DESTROY)
|
||||
@DeleteMapping("/{id}")
|
||||
public JsonResponse destroy(@PathVariable Integer id) throws NotFoundException {
|
||||
Department department = departmentService.findOrFail(id);
|
||||
|
||||
Reference in New Issue
Block a user