mirror of
https://github.com/ccmjga/zhilu-admin
synced 2026-03-13 21:27:19 +08:00
新增岗位、角色和权限的删除功能,更新相关API接口和前端组件,优化操作逻辑和权限校验
This commit is contained in:
@@ -5,8 +5,7 @@ import com.zl.mjga.dto.PageResponseDto;
|
||||
import com.zl.mjga.dto.ai.LlmQueryDto;
|
||||
import com.zl.mjga.dto.ai.LlmVm;
|
||||
import com.zl.mjga.exception.BusinessException;
|
||||
import com.zl.mjga.repository.DepartmentRepository;
|
||||
import com.zl.mjga.repository.UserRepository;
|
||||
import com.zl.mjga.repository.*;
|
||||
import com.zl.mjga.service.AiChatService;
|
||||
import com.zl.mjga.service.EmbeddingService;
|
||||
import com.zl.mjga.service.LlmService;
|
||||
@@ -20,9 +19,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jooq.generated.mjga.enums.LlmCodeEnum;
|
||||
import org.jooq.generated.mjga.tables.pojos.AiLlmConfig;
|
||||
import org.jooq.generated.mjga.tables.pojos.Department;
|
||||
import org.jooq.generated.mjga.tables.pojos.User;
|
||||
import org.jooq.generated.mjga.tables.pojos.*;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -41,6 +38,10 @@ public class AiController {
|
||||
private final EmbeddingService embeddingService;
|
||||
private final UserRepository userRepository;
|
||||
private final DepartmentRepository departmentRepository;
|
||||
private final PositionRepository positionRepository;
|
||||
private final RoleRepository repository;
|
||||
private final PermissionRepository permissionRepository;
|
||||
private final RoleRepository roleRepository;
|
||||
|
||||
@PostMapping(value = "/action/execute", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
|
||||
public Flux<String> actionExecute(Principal principal, @RequestBody String userMessage) {
|
||||
@@ -124,7 +125,7 @@ public class AiController {
|
||||
userRepository.deleteByUsername(username);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority(T(com.zl.mjga.model.urp.EPermission).WRITE_USER_ROLE_PERMISSION)")
|
||||
@PreAuthorize("hasAuthority(T(com.zl.mjga.model.urp.EPermission).WRITE_DEPARTMENT_PERMISSION)")
|
||||
@DeleteMapping("/action/department")
|
||||
void deleteDepartment(@RequestParam String name) {
|
||||
Department department = departmentRepository.fetchOneByName(name);
|
||||
@@ -134,6 +135,36 @@ public class AiController {
|
||||
departmentRepository.deleteByName(name);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority(T(com.zl.mjga.model.urp.EPermission).WRITE_POSITION_PERMISSION)")
|
||||
@DeleteMapping("/action/position")
|
||||
void deletePosition(@RequestParam String name) {
|
||||
Position position = positionRepository.fetchOneByName(name);
|
||||
if (position == null) {
|
||||
throw new BusinessException("该岗位不存在");
|
||||
}
|
||||
positionRepository.deleteById(position.getId());
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority(T(com.zl.mjga.model.urp.EPermission).WRITE_USER_ROLE_PERMISSION)")
|
||||
@DeleteMapping("/action/role")
|
||||
void deleteRole(@RequestParam String name) {
|
||||
Role role = roleRepository.fetchOneByName(name);
|
||||
if (role == null) {
|
||||
throw new BusinessException("该角色不存在");
|
||||
}
|
||||
roleRepository.deleteById(role.getId());
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority(T(com.zl.mjga.model.urp.EPermission).WRITE_USER_ROLE_PERMISSION)")
|
||||
@DeleteMapping("/action/permission")
|
||||
void deletePermission(@RequestParam String name) {
|
||||
Permission permission = permissionRepository.fetchOneByName(name);
|
||||
if (permission == null) {
|
||||
throw new BusinessException("该权限不存在");
|
||||
}
|
||||
permissionRepository.deleteById(permission.getId());
|
||||
}
|
||||
|
||||
@PostMapping("/chat/refresh")
|
||||
void createNewConversation(Principal principal) {
|
||||
aiChatService.evictChatMemory(principal.getName());
|
||||
|
||||
@@ -7,9 +7,15 @@ import lombok.Getter;
|
||||
@Getter
|
||||
public enum Actions {
|
||||
CREATE_USER("CREATE_USER", "创建用户"),
|
||||
CREATE_DEPARTMENT("CREATE_DEPARTMENT", "创建部门"),
|
||||
DELETE_USER("DELETE_USER", "删除用户"),
|
||||
DELETE_DEPARTMENT("DELETE_DEPARTMENT", "删除部门");
|
||||
CREATE_DEPARTMENT("CREATE_DEPARTMENT", "创建部门"),
|
||||
DELETE_DEPARTMENT("DELETE_DEPARTMENT", "删除部门"),
|
||||
CREATE_POSITION("CREATE_POSITION", "创建岗位"),
|
||||
DELETE_POSITION("DELETE_POSITION", "删除岗位"),
|
||||
CREATE_ROLE("CREATE_ROLE", "创建角色"),
|
||||
DELETE_ROLE("CREATE_ROLE", "删除角色"),
|
||||
CREATE_PERMISSION("CREATE_PERMISSION", "创建权限"),
|
||||
DELETE_PERMISSION("DELETE_PERMISSION", "删除权限");
|
||||
public static final String INDEX_KEY = "action";
|
||||
private final String code;
|
||||
private final String content;
|
||||
|
||||
Reference in New Issue
Block a user