org.jeecg.common.exception.JeecgBootException Java Examples

The following examples show how to use org.jeecg.common.exception.JeecgBootException. 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-boot-with-activiti with MIT License 6 votes vote down vote up
/**
  * 逻辑删除
 */
@Override
@CacheEvict(value = CacheConstant.SYS_DATA_PERMISSIONS_CACHE,allEntries=true)
//@CacheEvict(value = CacheConstant.SYS_DATA_PERMISSIONS_CACHE,allEntries=true,condition="#sysPermission.menuType==2")
public void deletePermissionLogical(String id) throws JeecgBootException {
	SysPermission sysPermission = this.getById(id);
	if(sysPermission==null) {
		throw new JeecgBootException("未找到菜单信息");
	}
	String pid = sysPermission.getParentId();
	int count = this.count(new QueryWrapper<SysPermission>().lambda().eq(SysPermission::getParentId, pid));
	if(count==1) {
		//若父节点无其他子节点,则该父节点是叶子节点
		this.sysPermissionMapper.setMenuLeaf(pid, 1);
	}
	sysPermission.setDelFlag(1);
	this.updateById(sysPermission);
}
 
Example #2
Source File: QuartzJobController.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
/**
 * 暂停定时任务
 * 
 * @param job
 * @return
 */
@GetMapping(value = "/pause")
@ApiOperation(value = "暂停定时任务")
public Result<Object> pauseJob(@RequestParam(name = "jobClassName", required = true) String jobClassName) {
	QuartzJob job = null;
	try {
		job = quartzJobService.getOne(new LambdaQueryWrapper<QuartzJob>().eq(QuartzJob::getJobClassName, jobClassName));
		if (job == null) {
			return Result.error("定时任务不存在!");
		}
		scheduler.pauseJob(JobKey.jobKey(jobClassName.trim()));
	} catch (SchedulerException e) {
		throw new JeecgBootException("暂停定时任务失败");
	}
	job.setStatus(CommonConstant.STATUS_DISABLE);
	quartzJobService.updateById(job);
	return Result.ok("暂停定时任务成功");
}
 
Example #3
Source File: SysPermissionServiceImpl.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
  * 真实删除
 */
@Override
@Transactional
@CacheEvict(value = CacheConstant.SYS_DATA_PERMISSIONS_CACHE,allEntries=true)
public void deletePermission(String id) throws JeecgBootException {
	SysPermission sysPermission = this.getById(id);
	if(sysPermission==null) {
		throw new JeecgBootException("未找到菜单信息");
	}
	String pid = sysPermission.getParentId();
	if(oConvertUtils.isNotEmpty(pid)) {
		int count = this.count(new QueryWrapper<SysPermission>().lambda().eq(SysPermission::getParentId, pid));
		if(count==1) {
			//若父节点无其他子节点,则该父节点是叶子节点
			this.sysPermissionMapper.setMenuLeaf(pid, 1);
		}
	}
	sysPermissionMapper.deleteById(id);
	// 该节点可能是子节点但也可能是其它节点的父节点,所以需要级联删除
	this.removeChildrenBy(sysPermission.getId());
}
 
Example #4
Source File: JwtUtil.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
/**
 * 根据request中的token获取用户信息
 *
 * @return
 * @throws JeecgBootException
 */
public static LoginUser getLoginUser() throws JeecgBootException {
	HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
	if(request==null){
		log.warn(" 非request方式访问!! ");
		return null;
	}
	String accessToken = request.getHeader("X-Access-Token");
	if(oConvertUtils.isEmpty(accessToken)){
		return null;
	}
	String username = getUsername(accessToken);
	if (oConvertUtils.isEmpty(username)) {
		throw new JeecgBootException("未获取到用户");
	}
	RedisUtil redisUtil = SpringContextUtils.getApplicationContext().getBean(RedisUtil.class);
	LoginUser sysUser = (LoginUser) redisUtil.get(CacheConstant.SYS_USERS_CACHE_JWT +":" +username);
	return sysUser;
}
 
Example #5
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)
//@CacheEvict(value = CacheConstant.SYS_DATA_PERMISSIONS_CACHE,allEntries=true,condition="#sysPermission.menuType==2")
public void deletePermissionLogical(String id) throws JeecgBootException {
	SysPermission sysPermission = this.getById(id);
	if(sysPermission==null) {
		throw new JeecgBootException("未找到菜单信息");
	}
	String pid = sysPermission.getParentId();
	int count = this.count(new QueryWrapper<SysPermission>().lambda().eq(SysPermission::getParentId, pid));
	if(count==1) {
		//若父节点无其他子节点,则该父节点是叶子节点
		this.sysPermissionMapper.setMenuLeaf(pid, 1);
	}
	sysPermission.setDelFlag(1);
	this.updateById(sysPermission);
}
 
Example #6
Source File: DynamicDBUtil.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
/**
 * 通过 dbKey ,获取数据源
 *
 * @param dbKey
 * @return
 */
public static DruidDataSource getDbSourceByDbKey(final String dbKey) {
    //获取多数据源配置
    DynamicDataSourceModel dbSource = DataSourceCachePool.getCacheDynamicDataSourceModel(dbKey);
    //先判断缓存中是否存在数据库链接
    DruidDataSource cacheDbSource = DataSourceCachePool.getCacheBasicDataSource(dbKey);
    if (cacheDbSource != null && !cacheDbSource.isClosed()) {
        log.debug("--------getDbSourceBydbKey------------------从缓存中获取DB连接-------------------");
        return cacheDbSource;
    } else {
        DruidDataSource dataSource = getJdbcDataSource(dbSource);
        if(dataSource!=null && dataSource.isEnable()){
            DataSourceCachePool.putCacheBasicDataSource(dbKey, dataSource);
        }else{
            throw new JeecgBootException("动态数据源连接失败,dbKey:"+dbKey);
        }
        log.info("--------getDbSourceBydbKey------------------创建DB数据库连接-------------------");
        return dataSource;
    }
}
 
Example #7
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 #8
Source File: SysBaseApiImpl.java    From teaching with Apache License 2.0 6 votes vote down vote up
@Override
public String parseTemplateByCode(String templateCode,Map<String, String> map) {
    List<SysMessageTemplate> sysSmsTemplates = sysMessageTemplateService.selectByCode(templateCode);
    if(sysSmsTemplates==null||sysSmsTemplates.size()==0){
        throw new JeecgBootException("消息模板不存在,模板编码:"+templateCode);
    }
    SysMessageTemplate sysSmsTemplate = sysSmsTemplates.get(0);
    //模板内容
    String content = sysSmsTemplate.getTemplateContent();
    if(map!=null) {
        for (Map.Entry<String, String> entry : map.entrySet()) {
            String str = "${" + entry.getKey() + "}";
            content = content.replace(str, entry.getValue());
        }
    }
    return content;
}
 
Example #9
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 #10
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)
//@CacheEvict(value = CacheConstant.SYS_DATA_PERMISSIONS_CACHE,allEntries=true,condition="#sysPermission.menuType==2")
public void deletePermissionLogical(String id) throws JeecgBootException {
	SysPermission sysPermission = this.getById(id);
	if(sysPermission==null) {
		throw new JeecgBootException("未找到菜单信息");
	}
	String pid = sysPermission.getParentId();
	int count = this.count(new QueryWrapper<SysPermission>().lambda().eq(SysPermission::getParentId, pid));
	if(count==1) {
		//若父节点无其他子节点,则该父节点是叶子节点
		this.sysPermissionMapper.setMenuLeaf(pid, 1);
	}
	sysPermission.setDelFlag(1);
	this.updateById(sysPermission);
}
 
Example #11
Source File: DynamicDBUtil.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
/**
 * 通过 dbKey ,获取数据源
 *
 * @param dbKey
 * @return
 */
public static DruidDataSource getDbSourceByDbKey(final String dbKey) {
    //获取多数据源配置
    DynamicDataSourceModel dbSource = DataSourceCachePool.getCacheDynamicDataSourceModel(dbKey);
    //先判断缓存中是否存在数据库链接
    DruidDataSource cacheDbSource = DataSourceCachePool.getCacheBasicDataSource(dbKey);
    if (cacheDbSource != null && !cacheDbSource.isClosed()) {
        log.debug("--------getDbSourceBydbKey------------------从缓存中获取DB连接-------------------");
        return cacheDbSource;
    } else {
        DruidDataSource dataSource = getJdbcDataSource(dbSource);
        if(dataSource!=null && dataSource.isEnable()){
            DataSourceCachePool.putCacheBasicDataSource(dbKey, dataSource);
        }else{
            throw new JeecgBootException("动态数据源连接失败,dbKey:"+dbKey);
        }
        log.info("--------getDbSourceBydbKey------------------创建DB数据库连接-------------------");
        return dataSource;
    }
}
 
Example #12
Source File: QuartzJobController.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
 * 暂停定时任务
 * 
 * @param jobClassName
 * @return
 */
@RequiresRoles("admin")
@GetMapping(value = "/pause")
@ApiOperation(value = "暂停定时任务")
public Result<Object> pauseJob(@RequestParam(name = "jobClassName", required = true) String jobClassName) {
	QuartzJob job = null;
	try {
		job = quartzJobService.getOne(new LambdaQueryWrapper<QuartzJob>().eq(QuartzJob::getJobClassName, jobClassName));
		if (job == null) {
			return Result.error("定时任务不存在!");
		}
		scheduler.pauseJob(JobKey.jobKey(jobClassName.trim()));
	} catch (SchedulerException e) {
		throw new JeecgBootException("暂停定时任务失败");
	}
	job.setStatus(CommonConstant.STATUS_DISABLE);
	quartzJobService.updateById(job);
	return Result.ok("暂停定时任务成功");
}
 
Example #13
Source File: QuartzJobController.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
/**
 * 暂停定时任务
 * 
 * @param jobClassName
 * @return
 */
//@RequiresRoles({"admin"})
@GetMapping(value = "/pause")
@ApiOperation(value = "暂停定时任务")
public Result<Object> pauseJob(@RequestParam(name = "jobClassName", required = true) String jobClassName) {
	QuartzJob job = null;
	try {
		job = quartzJobService.getOne(new LambdaQueryWrapper<QuartzJob>().eq(QuartzJob::getJobClassName, jobClassName));
		if (job == null) {
			return Result.error("定时任务不存在!");
		}
		scheduler.pauseJob(JobKey.jobKey(jobClassName.trim()));
	} catch (SchedulerException e) {
		throw new JeecgBootException("暂停定时任务失败");
	}
	job.setStatus(CommonConstant.STATUS_DISABLE);
	quartzJobService.updateById(job);
	return Result.ok("暂停定时任务成功");
}
 
Example #14
Source File: QuartzJobController.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
/**
 * 暂停定时任务
 * 
 * @param jobClassName
 * @return
 */
//@RequiresRoles({"admin"})
@GetMapping(value = "/pause")
@ApiOperation(value = "暂停定时任务")
public Result<Object> pauseJob(@RequestParam(name = "jobClassName", required = true) String jobClassName) {
	QuartzJob job = null;
	try {
		job = quartzJobService.getOne(new LambdaQueryWrapper<QuartzJob>().eq(QuartzJob::getJobClassName, jobClassName));
		if (job == null) {
			return Result.error("定时任务不存在!");
		}
		scheduler.pauseJob(JobKey.jobKey(jobClassName.trim()));
	} catch (SchedulerException e) {
		throw new JeecgBootException("暂停定时任务失败");
	}
	job.setStatus(CommonConstant.STATUS_DISABLE);
	quartzJobService.updateById(job);
	return Result.ok("暂停定时任务成功");
}
 
Example #15
Source File: SysBaseApiImpl.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
@Override
public String parseTemplateByCode(String templateCode,Map<String, String> map) {
    List<SysMessageTemplate> sysSmsTemplates = sysMessageTemplateService.selectByCode(templateCode);
    if(sysSmsTemplates==null||sysSmsTemplates.size()==0){
        throw new JeecgBootException("消息模板不存在,模板编码:"+templateCode);
    }
    SysMessageTemplate sysSmsTemplate = sysSmsTemplates.get(0);
    //模板内容
    String content = sysSmsTemplate.getTemplateContent();
    if(map!=null) {
        for (Map.Entry<String, String> entry : map.entrySet()) {
            String str = "${" + entry.getKey() + "}";
            content = content.replace(str, entry.getValue());
        }
    }
    return content;
}
 
Example #16
Source File: SysBaseApiImpl.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
@Override
public String parseTemplateByCode(String templateCode,Map<String, String> map) {
    List<SysMessageTemplate> sysSmsTemplates = sysMessageTemplateService.selectByCode(templateCode);
    if(sysSmsTemplates==null||sysSmsTemplates.size()==0){
        throw new JeecgBootException("消息模板不存在,模板编码:"+templateCode);
    }
    SysMessageTemplate sysSmsTemplate = sysSmsTemplates.get(0);
    //模板内容
    String content = sysSmsTemplate.getTemplateContent();
    if(map!=null) {
        for (Map.Entry<String, String> entry : map.entrySet()) {
            String str = "${" + entry.getKey() + "}";
            content = content.replace(str, entry.getValue());
        }
    }
    return content;
}
 
Example #17
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 #18
Source File: SysPermissionServiceImpl.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
/**
  * 真实删除
 */
@Override
@Transactional
@CacheEvict(value = CacheConstant.SYS_DATA_PERMISSIONS_CACHE,allEntries=true)
public void deletePermission(String id) throws JeecgBootException {
	SysPermission sysPermission = this.getById(id);
	if(sysPermission==null) {
		throw new JeecgBootException("未找到菜单信息");
	}
	String pid = sysPermission.getParentId();
	if(oConvertUtils.isNotEmpty(pid)) {
		int count = this.count(new QueryWrapper<SysPermission>().lambda().eq(SysPermission::getParentId, pid));
		if(count==1) {
			//若父节点无其他子节点,则该父节点是叶子节点
			this.sysPermissionMapper.setMenuLeaf(pid, 1);
		}
	}
	sysPermissionMapper.deleteById(id);
	// 该节点可能是子节点但也可能是其它节点的父节点,所以需要级联删除
	this.removeChildrenBy(sysPermission.getId());
}
 
Example #19
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)
//@CacheEvict(value = CacheConstant.SYS_DATA_PERMISSIONS_CACHE,allEntries=true,condition="#sysPermission.menuType==2")
public void deletePermissionLogical(String id) throws JeecgBootException {
	SysPermission sysPermission = this.getById(id);
	if(sysPermission==null) {
		throw new JeecgBootException("未找到菜单信息");
	}
	String pid = sysPermission.getParentId();
	int count = this.count(new QueryWrapper<SysPermission>().lambda().eq(SysPermission::getParentId, pid));
	if(count==1) {
		//若父节点无其他子节点,则该父节点是叶子节点
		this.sysPermissionMapper.setMenuLeaf(pid, 1);
	}
	sysPermission.setDelFlag(1);
	this.updateById(sysPermission);
}
 
Example #20
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 #21
Source File: SysBaseApiImpl.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 获取数据库类型
 * @param dataSource
 * @return
 * @throws SQLException
 */
private String getDatabaseTypeByDataSource(DataSource dataSource) throws SQLException{
	if("".equals(DB_TYPE)) {
		Connection connection = dataSource.getConnection();
		try {
			DatabaseMetaData md = connection.getMetaData();
			String dbType = md.getDatabaseProductName().toLowerCase();
			if(dbType.indexOf("mysql")>=0) {
				DB_TYPE = DataBaseConstant.DB_TYPE_MYSQL;
			}else if(dbType.indexOf("oracle")>=0) {
				DB_TYPE = DataBaseConstant.DB_TYPE_ORACLE;
			}else if(dbType.indexOf("sqlserver")>=0||dbType.indexOf("sql server")>=0) {
				DB_TYPE = DataBaseConstant.DB_TYPE_SQLSERVER;
			}else if(dbType.indexOf("postgresql")>=0) {
				DB_TYPE = DataBaseConstant.DB_TYPE_POSTGRESQL;
			}else {
				throw new JeecgBootException("数据库类型:["+dbType+"]不识别!");
			}
		} catch (Exception e) {
			log.error(e.getMessage(), e);
		}finally {
			connection.close();
		}
	}
	return DB_TYPE;
	
}
 
Example #22
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 #23
Source File: SqlInjectionUtil.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
public static void checkDictTableSign(String dictCode, String sign, HttpServletRequest request) {
	//表字典SQL注入漏洞,签名校验
	String accessToken = request.getHeader("X-Access-Token");
	String signStr = dictCode + SqlInjectionUtil.TABLE_DICT_SIGN_SALT + accessToken;
	String javaSign = SecureUtil.md5(signStr);
	if (!javaSign.equals(sign)) {
		log.error("表字典,SQL注入漏洞签名校验失败 :" + sign + "!=" + javaSign+ ",dictCode=" + dictCode);
		throw new JeecgBootException("无权限访问!");
	}
	log.info(" 表字典,SQL注入漏洞签名校验成功!sign=" + sign + ",dictCode=" + dictCode);
}
 
Example #24
Source File: SysCategoryServiceImpl.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
@Override
public List<TreeSelectModel> queryListByCode(String pcode) throws JeecgBootException{
	String pid = ROOT_PID_VALUE;
	if(oConvertUtils.isNotEmpty(pcode)) {
		List<SysCategory> list = baseMapper.selectList(new LambdaQueryWrapper<SysCategory>().eq(SysCategory::getCode, pcode));
		if(list==null || list.size() ==0) {
			throw new JeecgBootException("该编码【"+pcode+"】不存在,请核实!");
		}
		if(list.size()>1) {
			throw new JeecgBootException("该编码【"+pcode+"】存在多个,请核实!");
		}
		pid = list.get(0).getId();
	}
	return baseMapper.queryListByPid(pid,null);
}
 
Example #25
Source File: SysPermissionServiceImpl.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
  * 真实删除
 */
@Override
@Transactional
@CacheEvict(value = CacheConstant.SYS_DATA_PERMISSIONS_CACHE,allEntries=true)
public void deletePermission(String id) throws JeecgBootException {
	SysPermission sysPermission = this.getById(id);
	if(sysPermission==null) {
		throw new JeecgBootException("未找到菜单信息");
	}
	String pid = sysPermission.getParentId();
	if(oConvertUtils.isNotEmpty(pid)) {
		int count = this.count(new QueryWrapper<SysPermission>().lambda().eq(SysPermission::getParentId, pid));
		if(count==1) {
			//若父节点无其他子节点,则该父节点是叶子节点
			this.sysPermissionMapper.setMenuLeaf(pid, 1);
		}
	}
	sysPermissionMapper.deleteById(id);
	// 该节点可能是子节点但也可能是其它节点的父节点,所以需要级联删除
	this.removeChildrenBy(sysPermission.getId());
	//关联删除
	Map map = new HashMap<>();
	map.put("permission_id",id);
	//删除数据规则
	this.deletePermRuleByPermId(id);
	//删除角色授权表
	sysRolePermissionMapper.deleteByMap(map);
	//删除部门权限表
	sysDepartPermissionMapper.deleteByMap(map);
	//删除部门角色授权
	sysDepartRolePermissionMapper.deleteByMap(map);
}
 
Example #26
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);
				}
			}
			
		}
	}
	
}
 
Example #27
Source File: QuartzJobServiceImpl.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 删除定时任务
 * 
 * @param jobClassName
 */
private void schedulerDelete(String jobClassName) {
	try {
		scheduler.pauseTrigger(TriggerKey.triggerKey(jobClassName));
		scheduler.unscheduleJob(TriggerKey.triggerKey(jobClassName));
		scheduler.deleteJob(JobKey.jobKey(jobClassName));
	} catch (Exception e) {
		log.error(e.getMessage(), e);
		throw new JeecgBootException("删除定时任务失败");
	}
}
 
Example #28
Source File: SysBaseApiImpl.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 获取数据库类型
 * @param dataSource
 * @return
 * @throws SQLException
 */
private String getDatabaseTypeByDataSource(DataSource dataSource) throws SQLException{
	if("".equals(DB_TYPE)) {
		Connection connection = dataSource.getConnection();
		try {
			DatabaseMetaData md = connection.getMetaData();
			String dbType = md.getDatabaseProductName().toLowerCase();
			if(dbType.indexOf("mysql")>=0) {
				DB_TYPE = DataBaseConstant.DB_TYPE_MYSQL;
			}else if(dbType.indexOf("oracle")>=0) {
				DB_TYPE = DataBaseConstant.DB_TYPE_ORACLE;
			}else if(dbType.indexOf("sqlserver")>=0||dbType.indexOf("sql server")>=0) {
				DB_TYPE = DataBaseConstant.DB_TYPE_SQLSERVER;
			}else if(dbType.indexOf("postgresql")>=0) {
				DB_TYPE = DataBaseConstant.DB_TYPE_POSTGRESQL;
			}else {
				throw new JeecgBootException("数据库类型:["+dbType+"]不识别!");
			}
		} catch (Exception e) {
			log.error(e.getMessage(), e);
		}finally {
			connection.close();
		}
	}
	return DB_TYPE;
	
}
 
Example #29
Source File: QuartzJobServiceImpl.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 删除定时任务
 * 
 * @param jobClassName
 */
private void schedulerDelete(String jobClassName) {
	try {
		scheduler.pauseTrigger(TriggerKey.triggerKey(jobClassName));
		scheduler.unscheduleJob(TriggerKey.triggerKey(jobClassName));
		scheduler.deleteJob(JobKey.jobKey(jobClassName));
	} catch (Exception e) {
		log.error(e.getMessage(), e);
		throw new JeecgBootException("删除定时任务失败");
	}
}
 
Example #30
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);
				}
			}
			
		}
	}
	
}