解决删除图片遇到的空指针异常,增加判断
This commit is contained in:
@@ -228,7 +228,9 @@ public class AccountHeadService {
|
||||
List<String> pathList = new ArrayList<>();
|
||||
for(AccountHead accountHead: list){
|
||||
sb.append("[").append(accountHead.getBillNo()).append("]");
|
||||
if(StringUtil.isNotEmpty(accountHead.getFileName())) {
|
||||
pathList.add(accountHead.getFileName());
|
||||
}
|
||||
if("1".equals(accountHead.getStatus())) {
|
||||
throw new BusinessRunTimeException(ExceptionConstants.ACCOUNT_HEAD_UN_AUDIT_DELETE_FAILED_CODE,
|
||||
String.format(ExceptionConstants.ACCOUNT_HEAD_UN_AUDIT_DELETE_FAILED_MSG));
|
||||
|
||||
@@ -450,7 +450,9 @@ public class DepotHeadService {
|
||||
List<DepotHead> dhList = getDepotHeadListByIds(ids);
|
||||
for(DepotHead depotHead: dhList){
|
||||
sb.append("[").append(depotHead.getNumber()).append("]");
|
||||
if(StringUtil.isNotEmpty(depotHead.getFileName())) {
|
||||
pathList.add(depotHead.getFileName());
|
||||
}
|
||||
//只有未审核的单据才能被删除
|
||||
if("0".equals(depotHead.getStatus())) {
|
||||
User userInfo = userService.getCurrentUser();
|
||||
|
||||
@@ -299,8 +299,10 @@ public class MaterialService {
|
||||
List<Material> list = getMaterialListByIds(ids);
|
||||
for(Material material: list){
|
||||
sb.append("[").append(material.getName()).append("]");
|
||||
if(StringUtil.isNotEmpty(material.getImgName())) {
|
||||
pathList.add(material.getImgName());
|
||||
}
|
||||
}
|
||||
logService.insertLog("商品", sb.toString(),
|
||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
||||
User userInfo=userService.getCurrentUser();
|
||||
|
||||
@@ -364,9 +364,9 @@ public class SystemConfigService {
|
||||
if(fileUploadType == 1) {
|
||||
//本地
|
||||
for(String pathStr: pathList) {
|
||||
if(StringUtil.isNotEmpty(pathStr)) {
|
||||
String[] pathArr = pathStr.split(",");
|
||||
for (int i = 0; i < pathArr.length; i++) {
|
||||
String path = pathArr[i];
|
||||
for (String path : pathArr) {
|
||||
// 提取文件的路径
|
||||
String pathDir = getDirByPath(path);
|
||||
if (StringUtil.isNotEmpty(pathDir)) {
|
||||
@@ -394,6 +394,7 @@ public class SystemConfigService {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(fileUploadType == 2) {
|
||||
//oss
|
||||
String endpoint = platformConfigService.getPlatformConfigByKey("aliOss_endpoint").getPlatformValue();
|
||||
@@ -401,9 +402,10 @@ public class SystemConfigService {
|
||||
String accessKeySecret = platformConfigService.getPlatformConfigByKey("aliOss_accessKeySecret").getPlatformValue();
|
||||
String bucketName = platformConfigService.getPlatformConfigByKey("aliOss_bucketName").getPlatformValue();
|
||||
for(String pathStr: pathList) {
|
||||
if(StringUtil.isNotEmpty(pathStr)) {
|
||||
String[] pathArr = pathStr.split(",");
|
||||
for (int i = 0; i < pathArr.length; i++) {
|
||||
String path = pathArr[i];
|
||||
for (String path : pathArr) {
|
||||
if(StringUtil.isNotEmpty(path)) {
|
||||
// 创建OSSClient实例。
|
||||
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
||||
try {
|
||||
@@ -426,6 +428,8 @@ public class SystemConfigService {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user