Java Code Examples for org.jeecg.modules.system.entity.SysPermission#setParentId()

The following examples show how to use org.jeecg.modules.system.entity.SysPermission#setParentId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SysPermissionServiceImpl.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
@Override
@CacheEvict(value = CacheConstant.SYS_DATA_PERMISSIONS_CACHE,allEntries=true)
public void addPermission(SysPermission sysPermission) throws JeecgBootException {
	//----------------------------------------------------------------------
	//判断是否是一级菜单,是的话清空父菜单
	if(CommonConstant.MENU_TYPE_0.equals(sysPermission.getMenuType())) {
		sysPermission.setParentId(null);
	}
	//----------------------------------------------------------------------
	String pid = sysPermission.getParentId();
	if(oConvertUtils.isNotEmpty(pid)) {
		//设置父节点不为叶子节点
		this.sysPermissionMapper.setMenuLeaf(pid, 0);
	}
	sysPermission.setCreateTime(new Date());
	sysPermission.setDelFlag(0);
	sysPermission.setLeaf(true);
	this.save(sysPermission);
}
 
Example 2
Source File: SysPermissionServiceImpl.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
@Override
@CacheEvict(value = CacheConstant.SYS_DATA_PERMISSIONS_CACHE,allEntries=true)
public void addPermission(SysPermission sysPermission) throws JeecgBootException {
	//----------------------------------------------------------------------
	//判断是否是一级菜单,是的话清空父菜单
	if(CommonConstant.MENU_TYPE_0.equals(sysPermission.getMenuType())) {
		sysPermission.setParentId(null);
	}
	//----------------------------------------------------------------------
	String pid = sysPermission.getParentId();
	if(oConvertUtils.isNotEmpty(pid)) {
		//设置父节点不为叶子节点
		this.sysPermissionMapper.setMenuLeaf(pid, 0);
	}
	sysPermission.setCreateTime(new Date());
	sysPermission.setDelFlag(0);
	sysPermission.setLeaf(true);
	this.save(sysPermission);
}
 
Example 3
Source File: SysPermissionServiceImpl.java    From teaching with Apache License 2.0 6 votes vote down vote up
@Override
@CacheEvict(value = CacheConstant.SYS_DATA_PERMISSIONS_CACHE,allEntries=true)
public void addPermission(SysPermission sysPermission) throws JeecgBootException {
	//----------------------------------------------------------------------
	//判断是否是一级菜单,是的话清空父菜单
	if(CommonConstant.MENU_TYPE_0.equals(sysPermission.getMenuType())) {
		sysPermission.setParentId(null);
	}
	//----------------------------------------------------------------------
	String pid = sysPermission.getParentId();
	if(oConvertUtils.isNotEmpty(pid)) {
		//设置父节点不为叶子节点
		this.sysPermissionMapper.setMenuLeaf(pid, 0);
	}
	sysPermission.setCreateTime(new Date());
	sysPermission.setDelFlag(0);
	sysPermission.setLeaf(true);
	this.save(sysPermission);
}
 
Example 4
Source File: SysPermissionServiceImpl.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
@Override
@CacheEvict(value = CacheConstant.SYS_DATA_PERMISSIONS_CACHE,allEntries=true)
public void addPermission(SysPermission sysPermission) throws JeecgBootException {
	//----------------------------------------------------------------------
	//判断是否是一级菜单,是的话清空父菜单
	if(CommonConstant.MENU_TYPE_0.equals(sysPermission.getMenuType())) {
		sysPermission.setParentId(null);
	}
	//----------------------------------------------------------------------
	String pid = sysPermission.getParentId();
	if(oConvertUtils.isNotEmpty(pid)) {
		//设置父节点不为叶子节点
		this.sysPermissionMapper.setMenuLeaf(pid, 0);
	}
	sysPermission.setCreateTime(new Date());
	sysPermission.setDelFlag(0);
	sysPermission.setLeaf(true);
	this.save(sysPermission);
}
 
Example 5
Source File: SysPermissionServiceImpl.java    From jeecg-cloud with Apache License 2.0 5 votes vote down vote up
@Override
@CacheEvict(value = CacheConstant.SYS_DATA_PERMISSIONS_CACHE,allEntries=true)
public void editPermission(SysPermission sysPermission) throws JeecgBootException {
	SysPermission p = this.getById(sysPermission.getId());
	//TODO 该节点判断是否还有子节点
	if(p==null) {
		throw new JeecgBootException("未找到菜单信息");
	}else {
		sysPermission.setUpdateTime(new Date());
		//----------------------------------------------------------------------
		//Step1.判断是否是一级菜单,是的话清空父菜单ID
		if(CommonConstant.MENU_TYPE_0.equals(sysPermission.getMenuType())) {
			sysPermission.setParentId("");
		}
		//Step2.判断菜单下级是否有菜单,无则设置为叶子节点
		int count = this.count(new QueryWrapper<SysPermission>().lambda().eq(SysPermission::getParentId, sysPermission.getId()));
		if(count==0) {
			sysPermission.setLeaf(true);
		}
		//----------------------------------------------------------------------
		this.updateById(sysPermission);
		
		//如果当前菜单的父菜单变了,则需要修改新父菜单和老父菜单的,叶子节点状态
		String pid = sysPermission.getParentId();
		if((oConvertUtils.isNotEmpty(pid) && !pid.equals(p.getParentId())) || oConvertUtils.isEmpty(pid)&&oConvertUtils.isNotEmpty(p.getParentId())) {
			//a.设置新的父菜单不为叶子节点
			this.sysPermissionMapper.setMenuLeaf(pid, 0);
			//b.判断老的菜单下是否还有其他子菜单,没有的话则设置为叶子节点
			int cc = this.count(new QueryWrapper<SysPermission>().lambda().eq(SysPermission::getParentId, p.getParentId()));
			if(cc==0) {
				if(oConvertUtils.isNotEmpty(p.getParentId())) {
					this.sysPermissionMapper.setMenuLeaf(p.getParentId(), 1);
				}
			}
			
		}
	}
	
}
 
Example 6
Source File: SysPermissionServiceImpl.java    From jeecg-boot-with-activiti with MIT License 5 votes vote down vote up
@Override
@CacheEvict(value = CacheConstant.SYS_DATA_PERMISSIONS_CACHE,allEntries=true)
public void editPermission(SysPermission sysPermission) throws JeecgBootException {
	SysPermission p = this.getById(sysPermission.getId());
	//TODO 该节点判断是否还有子节点
	if(p==null) {
		throw new JeecgBootException("未找到菜单信息");
	}else {
		sysPermission.setUpdateTime(new Date());
		//----------------------------------------------------------------------
		//Step1.判断是否是一级菜单,是的话清空父菜单ID
		if(CommonConstant.MENU_TYPE_0.equals(sysPermission.getMenuType())) {
			sysPermission.setParentId("");
		}
		//Step2.判断菜单下级是否有菜单,无则设置为叶子节点
		int count = this.count(new QueryWrapper<SysPermission>().lambda().eq(SysPermission::getParentId, sysPermission.getId()));
		if(count==0) {
			sysPermission.setLeaf(true);
		}
		//----------------------------------------------------------------------
		this.updateById(sysPermission);
		
		//如果当前菜单的父菜单变了,则需要修改新父菜单和老父菜单的,叶子节点状态
		String pid = sysPermission.getParentId();
		if((oConvertUtils.isNotEmpty(pid) && !pid.equals(p.getParentId())) || oConvertUtils.isEmpty(pid)&&oConvertUtils.isNotEmpty(p.getParentId())) {
			//a.设置新的父菜单不为叶子节点
			this.sysPermissionMapper.setMenuLeaf(pid, 0);
			//b.判断老的菜单下是否还有其他子菜单,没有的话则设置为叶子节点
			int cc = this.count(new QueryWrapper<SysPermission>().lambda().eq(SysPermission::getParentId, p.getParentId()));
			if(cc==0) {
				if(oConvertUtils.isNotEmpty(p.getParentId())) {
					this.sysPermissionMapper.setMenuLeaf(p.getParentId(), 1);
				}
			}
			
		}
	}
	
}
 
Example 7
Source File: SysPermissionServiceImpl.java    From teaching with Apache License 2.0 5 votes vote down vote up
@Override
@CacheEvict(value = CacheConstant.SYS_DATA_PERMISSIONS_CACHE,allEntries=true)
public void editPermission(SysPermission sysPermission) throws JeecgBootException {
	SysPermission p = this.getById(sysPermission.getId());
	//TODO 该节点判断是否还有子节点
	if(p==null) {
		throw new JeecgBootException("未找到菜单信息");
	}else {
		sysPermission.setUpdateTime(new Date());
		//----------------------------------------------------------------------
		//Step1.判断是否是一级菜单,是的话清空父菜单ID
		if(CommonConstant.MENU_TYPE_0.equals(sysPermission.getMenuType())) {
			sysPermission.setParentId("");
		}
		//Step2.判断菜单下级是否有菜单,无则设置为叶子节点
		int count = this.count(new QueryWrapper<SysPermission>().lambda().eq(SysPermission::getParentId, sysPermission.getId()));
		if(count==0) {
			sysPermission.setLeaf(true);
		}
		//----------------------------------------------------------------------
		this.updateById(sysPermission);
		
		//如果当前菜单的父菜单变了,则需要修改新父菜单和老父菜单的,叶子节点状态
		String pid = sysPermission.getParentId();
		if((oConvertUtils.isNotEmpty(pid) && !pid.equals(p.getParentId())) || oConvertUtils.isEmpty(pid)&&oConvertUtils.isNotEmpty(p.getParentId())) {
			//a.设置新的父菜单不为叶子节点
			this.sysPermissionMapper.setMenuLeaf(pid, 0);
			//b.判断老的菜单下是否还有其他子菜单,没有的话则设置为叶子节点
			int cc = this.count(new QueryWrapper<SysPermission>().lambda().eq(SysPermission::getParentId, p.getParentId()));
			if(cc==0) {
				if(oConvertUtils.isNotEmpty(p.getParentId())) {
					this.sysPermissionMapper.setMenuLeaf(p.getParentId(), 1);
				}
			}
			
		}
	}
	
}
 
Example 8
Source File: SysPermissionServiceImpl.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
@Override
@CacheEvict(value = CacheConstant.SYS_DATA_PERMISSIONS_CACHE,allEntries=true)
public void editPermission(SysPermission sysPermission) throws JeecgBootException {
	SysPermission p = this.getById(sysPermission.getId());
	//TODO 该节点判断是否还有子节点
	if(p==null) {
		throw new JeecgBootException("未找到菜单信息");
	}else {
		sysPermission.setUpdateTime(new Date());
		//----------------------------------------------------------------------
		//Step1.判断是否是一级菜单,是的话清空父菜单ID
		if(CommonConstant.MENU_TYPE_0.equals(sysPermission.getMenuType())) {
			sysPermission.setParentId("");
		}
		//Step2.判断菜单下级是否有菜单,无则设置为叶子节点
		int count = this.count(new QueryWrapper<SysPermission>().lambda().eq(SysPermission::getParentId, sysPermission.getId()));
		if(count==0) {
			sysPermission.setLeaf(true);
		}
		//----------------------------------------------------------------------
		this.updateById(sysPermission);
		
		//如果当前菜单的父菜单变了,则需要修改新父菜单和老父菜单的,叶子节点状态
		String pid = sysPermission.getParentId();
		if((oConvertUtils.isNotEmpty(pid) && !pid.equals(p.getParentId())) || oConvertUtils.isEmpty(pid)&&oConvertUtils.isNotEmpty(p.getParentId())) {
			//a.设置新的父菜单不为叶子节点
			this.sysPermissionMapper.setMenuLeaf(pid, 0);
			//b.判断老的菜单下是否还有其他子菜单,没有的话则设置为叶子节点
			int cc = this.count(new QueryWrapper<SysPermission>().lambda().eq(SysPermission::getParentId, p.getParentId()));
			if(cc==0) {
				if(oConvertUtils.isNotEmpty(p.getParentId())) {
					this.sysPermissionMapper.setMenuLeaf(p.getParentId(), 1);
				}
			}
			
		}
	}
	
}