use of com.ruoyi.common.exception.ServiceException in project RuoYi-Flowable-Plus by KonBAI-Q.
the class SysDeptServiceImpl method checkDeptDataScope.
/**
* 校验部门是否有数据权限
*
* @param deptId 部门id
*/
@Override
public void checkDeptDataScope(Long deptId) {
if (!LoginHelper.isAdmin()) {
SysDept dept = new SysDept();
dept.setDeptId(deptId);
List<SysDept> depts = this.selectDeptList(dept);
if (CollUtil.isEmpty(depts)) {
throw new ServiceException("没有权限访问部门数据!");
}
}
}
use of com.ruoyi.common.exception.ServiceException in project RuoYi-Flowable-Plus by KonBAI-Q.
the class GenTableServiceImpl method validateEdit.
/**
* 修改保存参数校验
*
* @param genTable 业务信息
*/
@Override
public void validateEdit(GenTable genTable) {
if (GenConstants.TPL_TREE.equals(genTable.getTplCategory())) {
String options = JsonUtils.toJsonString(genTable.getParams());
Dict paramsObj = JsonUtils.parseMap(options);
if (StringUtils.isEmpty(paramsObj.getStr(GenConstants.TREE_CODE))) {
throw new ServiceException("树编码字段不能为空");
} else if (StringUtils.isEmpty(paramsObj.getStr(GenConstants.TREE_PARENT_CODE))) {
throw new ServiceException("树父编码字段不能为空");
} else if (StringUtils.isEmpty(paramsObj.getStr(GenConstants.TREE_NAME))) {
throw new ServiceException("树名称字段不能为空");
} else if (GenConstants.TPL_SUB.equals(genTable.getTplCategory())) {
if (StringUtils.isEmpty(genTable.getSubTableName())) {
throw new ServiceException("关联子表的表名不能为空");
} else if (StringUtils.isEmpty(genTable.getSubTableFkName())) {
throw new ServiceException("子表关联的外键名不能为空");
}
}
}
}
use of com.ruoyi.common.exception.ServiceException in project RuoYi-Flowable-Plus by KonBAI-Q.
the class GenTableServiceImpl method importGenTable.
/**
* 导入表结构
*
* @param tableList 导入表列表
*/
@Override
public void importGenTable(List<GenTable> tableList) {
String operName = LoginHelper.getUsername();
try {
for (GenTable table : tableList) {
String tableName = table.getTableName();
GenUtils.initTable(table, operName);
int row = baseMapper.insert(table);
if (row > 0) {
// 保存列信息
List<GenTableColumn> genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
List<GenTableColumn> saveColumns = new ArrayList<>();
for (GenTableColumn column : genTableColumns) {
GenUtils.initColumnField(column, table);
saveColumns.add(column);
}
if (CollUtil.isNotEmpty(saveColumns)) {
genTableColumnMapper.insertBatch(saveColumns);
}
}
}
} catch (Exception e) {
throw new ServiceException("导入失败:" + e.getMessage());
}
}
use of com.ruoyi.common.exception.ServiceException in project RuoYi-Flowable-Plus by KonBAI-Q.
the class SysOssServiceImpl method upload.
@Override
public SysOss upload(MultipartFile file) {
String originalfileName = file.getOriginalFilename();
String suffix = StringUtils.substring(originalfileName, originalfileName.lastIndexOf("."), originalfileName.length());
IOssStrategy storage = OssFactory.instance();
UploadResult uploadResult;
try {
uploadResult = storage.uploadSuffix(file.getBytes(), suffix, file.getContentType());
} catch (IOException e) {
throw new ServiceException(e.getMessage());
}
// 保存文件信息
SysOss oss = new SysOss();
oss.setUrl(uploadResult.getUrl());
oss.setFileSuffix(suffix);
oss.setFileName(uploadResult.getFilename());
oss.setOriginalName(originalfileName);
oss.setService(storage.getServiceType().getValue());
baseMapper.insert(oss);
return oss;
}
use of com.ruoyi.common.exception.ServiceException in project RuoYi-Flowable-Plus by KonBAI-Q.
the class SysRoleServiceImpl method deleteRoleByIds.
/**
* 批量删除角色信息
*
* @param roleIds 需要删除的角色ID
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int deleteRoleByIds(Long[] roleIds) {
for (Long roleId : roleIds) {
checkRoleAllowed(new SysRole(roleId));
checkRoleDataScope(roleId);
SysRole role = selectRoleById(roleId);
if (countUserRoleByRoleId(roleId) > 0) {
throw new ServiceException(String.format("%1$s已分配,不能删除", role.getRoleName()));
}
}
List<Long> ids = Arrays.asList(roleIds);
// 删除角色与菜单关联
roleMenuMapper.delete(new LambdaQueryWrapper<SysRoleMenu>().in(SysRoleMenu::getRoleId, ids));
// 删除角色与部门关联
roleDeptMapper.delete(new LambdaQueryWrapper<SysRoleDept>().in(SysRoleDept::getRoleId, ids));
return baseMapper.deleteBatchIds(ids);
}
Aggregations