【fix sonar】 SysPermissionServiceImpl.java文件
This commit is contained in:
+14
-12
@@ -41,7 +41,7 @@ public class SysPermissionServiceImpl extends ServiceImpl<SysPermissionMapper, S
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SysPermissionMapper sysPermissionMapper;
|
private SysPermissionMapper sysPermissionMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ISysPermissionDataRuleService permissionDataRuleService;
|
private ISysPermissionDataRuleService permissionDataRuleService;
|
||||||
|
|
||||||
@@ -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)) {
|
||||||
@@ -88,10 +90,10 @@ public class SysPermissionServiceImpl extends ServiceImpl<SysPermissionMapper, S
|
|||||||
//删除部门权限表
|
//删除部门权限表
|
||||||
sysDepartPermissionMapper.deleteByMap(map);
|
sysDepartPermissionMapper.deleteByMap(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据父id删除其关联的子节点数据
|
* 根据父id删除其关联的子节点数据
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public void removeChildrenBy(String parentId) {
|
public void removeChildrenBy(String parentId) {
|
||||||
@@ -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; // 查出的子级数量
|
||||||
// 如果查出的集合不为空, 则先删除所有
|
// 如果查出的集合不为空, 则先删除所有
|
||||||
@@ -125,7 +127,7 @@ public class SysPermissionServiceImpl extends ServiceImpl<SysPermissionMapper, S
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 逻辑删除
|
* 逻辑删除
|
||||||
*/
|
*/
|
||||||
@@ -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());
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
@@ -187,7 +189,7 @@ public class SysPermissionServiceImpl extends ServiceImpl<SysPermissionMapper, S
|
|||||||
}
|
}
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
this.updateById(sysPermission);
|
this.updateById(sysPermission);
|
||||||
|
|
||||||
//如果当前菜单的父菜单变了,则需要修改新父菜单和老父菜单的,叶子节点状态
|
//如果当前菜单的父菜单变了,则需要修改新父菜单和老父菜单的,叶子节点状态
|
||||||
String pid = sysPermission.getParentId();
|
String pid = sysPermission.getParentId();
|
||||||
if((oConvertUtils.isNotEmpty(pid) && !pid.equals(p.getParentId())) || oConvertUtils.isEmpty(pid)&&oConvertUtils.isNotEmpty(p.getParentId())) {
|
if((oConvertUtils.isNotEmpty(pid) && !pid.equals(p.getParentId())) || oConvertUtils.isEmpty(pid)&&oConvertUtils.isNotEmpty(p.getParentId())) {
|
||||||
@@ -200,10 +202,10 @@ public class SysPermissionServiceImpl extends ServiceImpl<SysPermissionMapper, S
|
|||||||
this.sysPermissionMapper.setMenuLeaf(p.getParentId(), 1);
|
this.sysPermissionMapper.setMenuLeaf(p.getParentId(), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -220,7 +222,7 @@ public class SysPermissionServiceImpl extends ServiceImpl<SysPermissionMapper, S
|
|||||||
query.eq(SysPermissionDataRule::getPermissionId, id);
|
query.eq(SysPermissionDataRule::getPermissionId, id);
|
||||||
int countValue = this.permissionDataRuleService.count(query);
|
int countValue = this.permissionDataRuleService.count(query);
|
||||||
if(countValue > 0) {
|
if(countValue > 0) {
|
||||||
this.permissionDataRuleService.remove(query);
|
this.permissionDataRuleService.remove(query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user