fix: file upload시 기존 파일(정보) 삭제후 업로드 처리

dev
Jonguk. Lim 6 months ago
parent 7cbc8fe52a
commit 438fb0a1e4

@ -70,7 +70,7 @@ public interface BizNimsMapper extends AbstractMapper {
NimsApiDto.DsuseRptInfo selectDsuseRptInfoByUsrRptIdNo(final Map<String, String> map); NimsApiDto.DsuseRptInfo selectDsuseRptInfoByUsrRptIdNo(final Map<String, String> map);
// 이미지 업로드시 이전 이미지 삭제를 위한 fileId 조회 // 이미지 업로드시 이전 이미지 삭제를 위한 fileId 조회
String selectFileId(Map<String, String> map); List<String> selectFileId(Map<String, String> map);
//List<NimsApiDto.DsuseRptInfoDtl> selectDsuseRptInfoDtls(final Map<String, String> map); //List<NimsApiDto.DsuseRptInfoDtl> selectDsuseRptInfoDtls(final Map<String, String> map);

@ -1,7 +1,7 @@
package cokr.xit.adds.biz.nims.service.bean; package cokr.xit.adds.biz.nims.service.bean;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -985,12 +985,12 @@ public class BizNimsServiceBean extends AbstractServiceBean implements BizNimsSe
* </pre> * </pre>
*/ */
private String uploadFileAndSave(String infType, String infKey, String subType, MultipartFile mf) { private String uploadFileAndSave(String infType, String infKey, String subType, MultipartFile mf) {
String fileId = bizNimsMapper.selectFileId(Map.of("infType", infType, "infKey", infKey, "subType", subType)); List<String> fileIds = bizNimsMapper.selectFileId(Map.of("infType", infType, "infKey", infKey, "subType", subType));
if(!isEmpty(fileId)){ if(!fileIds.isEmpty()){
fileService.delete(new String[]{fileId}); fileService.delete(fileIds.toArray(new String[0]));
} }
MultipartFile[] uploads = Arrays.asList(mf).toArray(new MultipartFile[0]); MultipartFile[] uploads = Collections.singletonList(mf).toArray(new MultipartFile[0]);
List<FileInfo> files = (new FileInfoFactory()).makeFileInfos((new FileInfo.Relation()).setInfoType(infType).setInfoKey(infKey).setSubType(subType), uploads); List<FileInfo> files = (new FileInfoFactory()).makeFileInfos((new FileInfo.Relation()).setInfoType(infType).setInfoKey(infKey).setSubType(subType), uploads);
fileService.create(files); fileService.create(files);

Loading…
Cancel
Save