update 优化默认部门,不允许删除

This commit is contained in:
AprilWind 2025-06-06 10:06:23 +08:00
parent 7471fa7ee0
commit 8f95374cef
2 changed files with 7 additions and 2 deletions

View File

@ -77,4 +77,9 @@ public interface SystemConstants {
*/
String ROOT_DEPT_ANCESTORS = "0";
/**
* 默认部门 ID
*/
Long DEFAULT_DEPT_ID = 100L;
}

View File

@ -113,8 +113,8 @@ public class SysDeptController extends BaseController {
@Log(title = "部门管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{deptId}")
public R<Void> remove(@PathVariable Long deptId) {
if (StringUtils.equals(SystemConstants.ROOT_DEPT_ANCESTORS, String.valueOf(deptId))) {
return R.warn("根部门不允许删除");
if (SystemConstants.DEFAULT_DEPT_ID.equals(deptId)) {
return R.warn("默认部门,不允许删除");
}
if (deptService.hasChildByDeptId(deptId)) {
return R.warn("存在下级部门,不允许删除");