Browse Source

强化删除校验

test
smallchill 6 years ago
parent
commit
2471d5833b
  1. 2
      blade-service/blade-system/src/main/java/org/springblade/system/controller/DeptController.java
  2. 2
      blade-service/blade-system/src/main/java/org/springblade/system/controller/DictController.java
  3. 2
      blade-service/blade-system/src/main/java/org/springblade/system/controller/MenuController.java
  4. 8
      blade-service/blade-system/src/main/java/org/springblade/system/service/IDeptService.java
  5. 8
      blade-service/blade-system/src/main/java/org/springblade/system/service/IDictService.java
  6. 8
      blade-service/blade-system/src/main/java/org/springblade/system/service/IMenuService.java
  7. 11
      blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DeptServiceImpl.java
  8. 9
      blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictServiceImpl.java
  9. 10
      blade-service/blade-system/src/main/java/org/springblade/system/service/impl/MenuServiceImpl.java
  10. 3
      blade-service/blade-user/src/main/java/org/springblade/system/user/controller/UserController.java
  11. 8
      blade-service/blade-user/src/main/java/org/springblade/system/user/service/IUserService.java
  12. 9
      blade-service/blade-user/src/main/java/org/springblade/system/user/service/impl/UserServiceImpl.java

2
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));
}

2
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));
}
/**

2
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));
}
/**

8
blade-service/blade-system/src/main/java/org/springblade/system/service/IDeptService.java

@ -55,4 +55,12 @@ public interface IDeptService extends IService<Dept> {
*/
List<String> getDeptNames(String deptIds);
/**
* 删除部门
*
* @param ids
* @return
*/
boolean removeDept(String ids);
}

8
blade-service/blade-system/src/main/java/org/springblade/system/service/IDictService.java

@ -70,4 +70,12 @@ public interface IDictService extends IService<Dict> {
*/
boolean submit(Dict dict);
/**
* 删除字典
*
* @param ids
* @return
*/
boolean removeDict(String ids);
}

8
blade-service/blade-system/src/main/java/org/springblade/system/service/IMenuService.java

@ -88,4 +88,12 @@ public interface IMenuService extends IService<Menu> {
*/
List<Kv> authRoutes(BladeUser user);
/**
* 删除菜单
*
* @param ids
* @return
*/
boolean removeMenu(String ids);
}

11
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<DeptMapper, Dept> implements ID
return baseMapper.getDeptNames(Func.toStrArray(deptIds));
}
@Override
public boolean removeDept(String ids) {
Integer cnt = baseMapper.selectCount(Wrappers.<Dept>query().lambda().in(Dept::getParentId, Func.toLongList(ids)));
if (cnt > 0) {
throw new ApiException("请先删除子节点!");
}
return removeByIds(Func.toLongList(ids));
}
}

9
blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictServiceImpl.java

@ -74,4 +74,13 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements ID
}
return saveOrUpdate(dict);
}
@Override
public boolean removeDict(String ids) {
Integer cnt = baseMapper.selectCount(Wrappers.<Dict>query().lambda().in(Dict::getParentId, Func.toLongList(ids)));
if (cnt > 0) {
throw new ApiException("请先删除子节点!");
}
return removeByIds(Func.toLongList(ids));
}
}

10
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<MenuMapper, Menu> implements IM
return list;
}
@Override
public boolean removeMenu(String ids) {
Integer cnt = baseMapper.selectCount(Wrappers.<Menu>query().lambda().in(Menu::getParentId, Func.toLongList(ids)));
if (cnt > 0) {
throw new ApiException("请先删除子节点!");
}
return removeByIds(Func.toLongList(ids));
}
}

3
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));
}
/**

8
blade-service/blade-user/src/main/java/org/springblade/system/user/service/IUserService.java

@ -70,4 +70,12 @@ public interface IUserService extends BaseService<User> {
* @return
*/
boolean resetPassword(String userIds);
/**
* 删除用户
*
* @param userIds
* @return
*/
boolean removeUser(String userIds);
}

9
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<UserMapper, User> implement
return this.update(user, Wrappers.<User>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));
}
}

Loading…
Cancel
Save