部门删除event

This commit is contained in:
none
2023-02-23 15:30:55 +08:00
parent e7d335eb88
commit aa5d3a21d8
6 changed files with 70 additions and 0 deletions

View File

@@ -2,11 +2,13 @@ package xyz.playedu.api.controller.backend;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
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.event.DepartmentDestroyEvent;
import xyz.playedu.api.exception.NotFoundException;
import xyz.playedu.api.middleware.BackendPermissionMiddleware;
import xyz.playedu.api.request.backend.DepartmentRequest;
@@ -31,6 +33,9 @@ public class DepartmentController {
@Autowired
private DepartmentBus departmentBus;
@Autowired
private ApplicationContext ctx;
@BackendPermissionMiddleware(slug = BPermissionConstant.DEPARTMENT_INDEX)
@GetMapping("/index")
public JsonResponse index() {
@@ -90,6 +95,9 @@ public class DepartmentController {
public JsonResponse destroy(@PathVariable Integer id) throws NotFoundException {
Department department = departmentService.findOrFail(id);
departmentService.deleteById(department.getId());
ctx.publishEvent(new DepartmentDestroyEvent(this, id, new Date()));
return JsonResponse.success();
}

View File

@@ -213,4 +213,9 @@ public class UserController {
return JsonResponse.success();
}
@PostMapping("/store-batch")
public JsonResponse batchStore() {
return null;
}
}