|
|
|
@ -22,6 +22,10 @@ public class RoleServiceImpl implements RoleService {
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
TbRoleMapper roleMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
TbRoleResourceMapper roleResourceMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
SysUserDao sysUserDao;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -77,7 +81,21 @@ public class RoleServiceImpl implements RoleService {
|
|
|
|
|
if (id == SUPER_ADMIN) {
|
|
|
|
|
throw new ApiException("不能删除" + SUPER_ADMIN_NAME);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SysUserExample example = new SysUserExample();
|
|
|
|
|
SysUserExample.Criteria criteria = example.createCriteria();
|
|
|
|
|
criteria.andRoleEqualTo(id);
|
|
|
|
|
long count = sysUserDao.countByExample(example);
|
|
|
|
|
if (count > 0) {
|
|
|
|
|
throw new ApiException("该角色已被" + count + "个用户使用不能删除");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
roleMapper.deleteByPrimaryKey(id);
|
|
|
|
|
|
|
|
|
|
TbRoleResourceExample resourceExample = new TbRoleResourceExample();
|
|
|
|
|
TbRoleResourceExample.Criteria resourceExampleCriteria = resourceExample.createCriteria();
|
|
|
|
|
resourceExampleCriteria.andRoleIdEqualTo(id);
|
|
|
|
|
roleResourceMapper.deleteByExample(resourceExample);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|