use of com.ruoyi.common.core.exception.ServiceException in project RuoYi-Cloud-Plus by JavaLionLi.
the class SysOssConfigServiceImpl method deleteWithValidByIds.
@Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if (isValid) {
if (CollUtil.containsAny(ids, OssConstant.SYSTEM_DATA_IDS)) {
throw new ServiceException("系统内置, 不可删除!");
}
}
List<SysOssConfig> list = Lists.newArrayList();
for (Long configId : ids) {
SysOssConfig config = baseMapper.selectById(configId);
list.add(config);
}
boolean flag = baseMapper.deleteBatchIds(ids) > 0;
if (flag) {
list.stream().forEach(sysOssConfig -> {
RedisUtils.deleteObject(getCacheKey(sysOssConfig.getConfigKey()));
});
}
return flag;
}
use of com.ruoyi.common.core.exception.ServiceException in project RuoYi-Cloud-Plus by JavaLionLi.
the class SysOssServiceImpl method upload.
@Override
public SysOss upload(MultipartFile file) {
String originalfileName = file.getOriginalFilename();
String suffix = StringUtils.substring(originalfileName, originalfileName.lastIndexOf("."), originalfileName.length());
OssClient 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.getConfigKey());
baseMapper.insert(oss);
return oss;
}
use of com.ruoyi.common.core.exception.ServiceException in project RuoYi-Cloud-Plus by JavaLionLi.
the class SysConfigServiceImpl method deleteConfigByIds.
/**
* 批量删除参数信息
*
* @param configIds 需要删除的参数ID
*/
@Override
public void deleteConfigByIds(Long[] configIds) {
for (Long configId : configIds) {
SysConfig config = selectConfigById(configId);
if (StringUtils.equals(UserConstants.YES, config.getConfigType())) {
throw new ServiceException(String.format("内置参数【%1$s】不能删除 ", config.getConfigKey()));
}
RedisUtils.deleteObject(getCacheKey(config.getConfigKey()));
}
baseMapper.deleteBatchIds(Arrays.asList(configIds));
}
use of com.ruoyi.common.core.exception.ServiceException in project RuoYi-Cloud-Plus by JavaLionLi.
the class SysDeptServiceImpl method insertDept.
/**
* 新增保存部门信息
*
* @param dept 部门信息
* @return 结果
*/
@Override
public int insertDept(SysDept dept) {
SysDept info = baseMapper.selectById(dept.getParentId());
// 如果父节点不为正常状态,则不允许新增子节点
if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) {
throw new ServiceException("部门停用,不允许新增");
}
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
return baseMapper.insert(dept);
}
use of com.ruoyi.common.core.exception.ServiceException in project RuoYi-Cloud-Plus by JavaLionLi.
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("没有权限访问部门数据!");
}
}
}
Aggregations