【fix sonar】 SysPermissionServiceImpl.java文件
This commit is contained in:
+6
-4
@@ -51,6 +51,8 @@ public class SysPermissionServiceImpl extends ServiceImpl<SysPermissionMapper, S
|
|||||||
@Resource
|
@Resource
|
||||||
private SysDepartPermissionMapper sysDepartPermissionMapper;
|
private SysDepartPermissionMapper sysDepartPermissionMapper;
|
||||||
|
|
||||||
|
private static final String ERROR_MSG = "未找到菜单信息";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TreeModel> queryListByParentId(String parentId) {
|
public List<TreeModel> queryListByParentId(String parentId) {
|
||||||
return sysPermissionMapper.queryListByParentId(parentId);
|
return sysPermissionMapper.queryListByParentId(parentId);
|
||||||
@@ -65,7 +67,7 @@ public class SysPermissionServiceImpl extends ServiceImpl<SysPermissionMapper, S
|
|||||||
public void deletePermission(String id) throws JeroBootException {
|
public void deletePermission(String id) throws JeroBootException {
|
||||||
SysPermission sysPermission = this.getById(id);
|
SysPermission sysPermission = this.getById(id);
|
||||||
if(sysPermission==null) {
|
if(sysPermission==null) {
|
||||||
throw new JeroBootException("未找到菜单信息");
|
throw new JeroBootException(ERROR_MSG);
|
||||||
}
|
}
|
||||||
String pid = sysPermission.getParentId();
|
String pid = sysPermission.getParentId();
|
||||||
if(oConvertUtils.isNotEmpty(pid)) {
|
if(oConvertUtils.isNotEmpty(pid)) {
|
||||||
@@ -100,7 +102,7 @@ public class SysPermissionServiceImpl extends ServiceImpl<SysPermissionMapper, S
|
|||||||
query.eq(SysPermission::getParentId, parentId);
|
query.eq(SysPermission::getParentId, parentId);
|
||||||
// 查出该主键下的所有子级
|
// 查出该主键下的所有子级
|
||||||
List<SysPermission> permissionList = this.list(query);
|
List<SysPermission> permissionList = this.list(query);
|
||||||
if (permissionList != null && permissionList.size() > 0) {
|
if (permissionList != null && !permissionList.isEmpty()) {
|
||||||
String id = ""; // id
|
String id = ""; // id
|
||||||
int num = 0; // 查出的子级数量
|
int num = 0; // 查出的子级数量
|
||||||
// 如果查出的集合不为空, 则先删除所有
|
// 如果查出的集合不为空, 则先删除所有
|
||||||
@@ -134,7 +136,7 @@ public class SysPermissionServiceImpl extends ServiceImpl<SysPermissionMapper, S
|
|||||||
public void deletePermissionLogical(String id) throws JeroBootException {
|
public void deletePermissionLogical(String id) throws JeroBootException {
|
||||||
SysPermission sysPermission = this.getById(id);
|
SysPermission sysPermission = this.getById(id);
|
||||||
if(sysPermission==null) {
|
if(sysPermission==null) {
|
||||||
throw new JeroBootException("未找到菜单信息");
|
throw new JeroBootException(ERROR_MSG);
|
||||||
}
|
}
|
||||||
String pid = sysPermission.getParentId();
|
String pid = sysPermission.getParentId();
|
||||||
int count = this.count(new QueryWrapper<SysPermission>().lambda().eq(SysPermission::getParentId, pid));
|
int count = this.count(new QueryWrapper<SysPermission>().lambda().eq(SysPermission::getParentId, pid));
|
||||||
@@ -172,7 +174,7 @@ public class SysPermissionServiceImpl extends ServiceImpl<SysPermissionMapper, S
|
|||||||
SysPermission p = this.getById(sysPermission.getId());
|
SysPermission p = this.getById(sysPermission.getId());
|
||||||
//TODO 该节点判断是否还有子节点
|
//TODO 该节点判断是否还有子节点
|
||||||
if(p==null) {
|
if(p==null) {
|
||||||
throw new JeroBootException("未找到菜单信息");
|
throw new JeroBootException(ERROR_MSG);
|
||||||
}else {
|
}else {
|
||||||
sysPermission.setUpdateTime(new Date());
|
sysPermission.setUpdateTime(new Date());
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user