diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/controller/DeptController.java b/blade-service/blade-system/src/main/java/org/springblade/system/controller/DeptController.java index f18262ca..bed1d37d 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/controller/DeptController.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/controller/DeptController.java @@ -113,7 +113,7 @@ public class DeptController extends BladeController { @ApiOperation(value = "删除", notes = "传入ids", position = 5) @CacheEvict(cacheNames = {SYS_CACHE}) public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { - return R.status(deptService.removeByIds(Func.toLongList(ids))); + return R.status(deptService.removeDept(ids)); } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/controller/DictController.java b/blade-service/blade-system/src/main/java/org/springblade/system/controller/DictController.java index 5edf3909..8b30489d 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/controller/DictController.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/controller/DictController.java @@ -107,7 +107,7 @@ public class DictController extends BladeController { @CacheEvict(cacheNames = {DICT_CACHE}, allEntries = true) @ApiOperation(value = "删除", notes = "传入ids", position = 7) public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { - return R.status(dictService.removeByIds(Func.toLongList(ids))); + return R.status(dictService.removeDict(ids)); } /** diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/controller/MenuController.java b/blade-service/blade-system/src/main/java/org/springblade/system/controller/MenuController.java index d0775e1d..32763568 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/controller/MenuController.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/controller/MenuController.java @@ -101,7 +101,7 @@ public class MenuController extends BladeController { @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR) @ApiOperation(value = "删除", notes = "传入ids", position = 9) public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { - return R.status(menuService.removeByIds(Func.toLongList(ids))); + return R.status(menuService.removeMenu(ids)); } /** diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/IDeptService.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/IDeptService.java index 1eed7638..50cfee1e 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/service/IDeptService.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/IDeptService.java @@ -55,4 +55,12 @@ public interface IDeptService extends IService { */ List getDeptNames(String deptIds); + /** + * 删除部门 + * + * @param ids + * @return + */ + boolean removeDept(String ids); + } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/IDictService.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/IDictService.java index a45c74b6..d4410296 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/service/IDictService.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/IDictService.java @@ -70,4 +70,12 @@ public interface IDictService extends IService { */ boolean submit(Dict dict); + /** + * 删除字典 + * + * @param ids + * @return + */ + boolean removeDict(String ids); + } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/IMenuService.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/IMenuService.java index 58006ef8..6d632e71 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/service/IMenuService.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/IMenuService.java @@ -88,4 +88,12 @@ public interface IMenuService extends IService { */ List authRoutes(BladeUser user); + /** + * 删除菜单 + * + * @param ids + * @return + */ + boolean removeMenu(String ids); + } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DeptServiceImpl.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DeptServiceImpl.java index 5a77414a..41fd9873 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DeptServiceImpl.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DeptServiceImpl.java @@ -17,6 +17,8 @@ package org.springblade.system.service.impl; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.exceptions.ApiException; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springblade.core.tool.node.ForestNodeMerger; import org.springblade.core.tool.utils.Func; @@ -51,4 +53,13 @@ public class DeptServiceImpl extends ServiceImpl implements ID return baseMapper.getDeptNames(Func.toStrArray(deptIds)); } + @Override + public boolean removeDept(String ids) { + Integer cnt = baseMapper.selectCount(Wrappers.query().lambda().in(Dept::getParentId, Func.toLongList(ids))); + if (cnt > 0) { + throw new ApiException("请先删除子节点!"); + } + return removeByIds(Func.toLongList(ids)); + } + } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictServiceImpl.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictServiceImpl.java index 0c074402..a57ed058 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictServiceImpl.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictServiceImpl.java @@ -74,4 +74,13 @@ public class DictServiceImpl extends ServiceImpl implements ID } return saveOrUpdate(dict); } + + @Override + public boolean removeDict(String ids) { + Integer cnt = baseMapper.selectCount(Wrappers.query().lambda().in(Dict::getParentId, Func.toLongList(ids))); + if (cnt > 0) { + throw new ApiException("请先删除子节点!"); + } + return removeByIds(Func.toLongList(ids)); + } } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/MenuServiceImpl.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/MenuServiceImpl.java index 53b1b00e..76d0b572 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/MenuServiceImpl.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/MenuServiceImpl.java @@ -18,6 +18,7 @@ package org.springblade.system.service.impl; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.exceptions.ApiException; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.AllArgsConstructor; import org.springblade.core.secure.BladeUser; @@ -109,4 +110,13 @@ public class MenuServiceImpl extends ServiceImpl implements IM return list; } + @Override + public boolean removeMenu(String ids) { + Integer cnt = baseMapper.selectCount(Wrappers.query().lambda().in(Menu::getParentId, Func.toLongList(ids))); + if (cnt > 0) { + throw new ApiException("请先删除子节点!"); + } + return removeByIds(Func.toLongList(ids)); + } + } diff --git a/blade-service/blade-user/src/main/java/org/springblade/system/user/controller/UserController.java b/blade-service/blade-user/src/main/java/org/springblade/system/user/controller/UserController.java index cf779eb3..1fba7854 100644 --- a/blade-service/blade-user/src/main/java/org/springblade/system/user/controller/UserController.java +++ b/blade-service/blade-user/src/main/java/org/springblade/system/user/controller/UserController.java @@ -31,7 +31,6 @@ import org.springblade.core.secure.annotation.PreAuth; import org.springblade.core.tool.api.R; import org.springblade.core.tool.constant.BladeConstant; import org.springblade.core.tool.constant.RoleConstant; -import org.springblade.core.tool.utils.Func; import org.springblade.system.user.entity.User; import org.springblade.system.user.service.IUserService; import org.springblade.system.user.vo.UserVO; @@ -115,7 +114,7 @@ public class UserController { @PreAuth(RoleConstant.HAS_ROLE_ADMIN) @CacheEvict(cacheNames = {USER_CACHE}) public R remove(@RequestParam String ids) { - return R.status(userService.deleteLogic(Func.toLongList(ids))); + return R.status(userService.removeUser(ids)); } /** diff --git a/blade-service/blade-user/src/main/java/org/springblade/system/user/service/IUserService.java b/blade-service/blade-user/src/main/java/org/springblade/system/user/service/IUserService.java index 245131e1..2d5cbc74 100644 --- a/blade-service/blade-user/src/main/java/org/springblade/system/user/service/IUserService.java +++ b/blade-service/blade-user/src/main/java/org/springblade/system/user/service/IUserService.java @@ -70,4 +70,12 @@ public interface IUserService extends BaseService { * @return */ boolean resetPassword(String userIds); + + /** + * 删除用户 + * + * @param userIds + * @return + */ + boolean removeUser(String userIds); } diff --git a/blade-service/blade-user/src/main/java/org/springblade/system/user/service/impl/UserServiceImpl.java b/blade-service/blade-user/src/main/java/org/springblade/system/user/service/impl/UserServiceImpl.java index 4713b5c2..cefcb20d 100644 --- a/blade-service/blade-user/src/main/java/org/springblade/system/user/service/impl/UserServiceImpl.java +++ b/blade-service/blade-user/src/main/java/org/springblade/system/user/service/impl/UserServiceImpl.java @@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.exceptions.ApiException; import org.springblade.common.constant.CommonConstant; import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.secure.utils.SecureUtil; import org.springblade.core.tool.constant.BladeConstant; import org.springblade.core.tool.utils.DigestUtil; import org.springblade.core.tool.utils.Func; @@ -87,4 +88,12 @@ public class UserServiceImpl extends BaseServiceImpl implement return this.update(user, Wrappers.update().lambda().in(User::getId, Func.toLongList(userIds))); } + @Override + public boolean removeUser(String userIds) { + if (Func.contains(Func.toLongArray(userIds), SecureUtil.getUserId())) { + throw new ApiException("不能删除本账号!"); + } + return deleteLogic(Func.toLongList(userIds)); + } + }