파일 삭제 수정

master
mjkhan21 5 months ago
parent ad80a2886a
commit f6fdb8a228

@ -2,7 +2,6 @@ package cokr.xit.base.file.dao;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.egovframe.rte.psl.dataaccess.mapper.Mapper;
@ -201,7 +200,7 @@ public interface FileMapper extends AbstractMapper {
default int delete(List<FileInfo> files) {
if (isEmpty(files)) return 0;
String[] fileIDs = files.stream().map(FileInfo::getId).collect(Collectors.toList()).toArray(new String[files.size()]);
String[] fileIDs = files.stream().map(FileInfo::getId).toList().toArray(new String[files.size()]);
return deleteFiles(params().set("fileIDs", ifEmpty(fileIDs, () -> null)));
}
}

@ -183,7 +183,7 @@ public class FileBean extends AbstractBean {
*/
public int deleteOf(String infoType, String... infoKeys) {
List<FileInfo> files = getFilesOf(infoType, infoKeys);
if (delete(files) < 1) return 0;
delete(files);
return fileMapper.delete(files);
}
@ -194,7 +194,7 @@ public class FileBean extends AbstractBean {
*/
public int deleteByIDs(String... fileIDs) {
List<FileInfo> files = getFiles(fileIDs);
if (delete(files) < 1) return 0;
delete(files);
return fileMapper.delete(files);
}
@ -207,8 +207,12 @@ public class FileBean extends AbstractBean {
if (isEmpty(files)) return 0;
int affected = 0;
for (FileInfo file: files)
affected += file.delete() ? 1 : 0;
for (FileInfo file: files) {
if (file.delete())
++affected;
else
log().warn("Failed to delete {}({})", file.getPath(), file.getId());
}
return affected;
}

Loading…
Cancel
Save