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

dev
Jonguk. Lim 6 months ago
parent db88fcbcf0
commit 7cbc8fe52a

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

@ -557,9 +557,9 @@ public class BizNimsServiceBean extends AbstractServiceBean implements BizNimsSe
.pg("1") .pg("1")
.fg2("") // 보고 유형: ""- 전체, 0-신규, 1-취소, 2-변경 .fg2("") // 보고 유형: ""- 전체, 0-신규, 1-취소, 2-변경
.se("AAR") // 보고구분: AAR-폐기 .se("AAR") // 보고구분: AAR-폐기
.sdt(reqDto.getHdrDe()) .sdt(dsuseMgtDto.getHdrDe())
.edt(reqDto.getHdrDe()) .edt(dsuseMgtDto.getHdrDe())
.bc(reqDto.getBsshCd()) .bc(dsuseMgtDto.getBsshCd())
.gc(apiInfInfo.get("deptCd")) .gc(apiInfInfo.get("deptCd"))
.build(); .build();
@ -984,9 +984,14 @@ public class BizNimsServiceBean extends AbstractServiceBean implements BizNimsSe
* @return fileId * @return fileId
* </pre> * </pre>
*/ */
private String uploadFileAndSave(String infoType, String infoKey, 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));
if(!isEmpty(fileId)){
fileService.delete(new String[]{fileId});
}
MultipartFile[] uploads = Arrays.asList(mf).toArray(new MultipartFile[0]); MultipartFile[] uploads = Arrays.asList(mf).toArray(new MultipartFile[0]);
List<FileInfo> files = (new FileInfoFactory()).makeFileInfos((new FileInfo.Relation()).setInfoType(infoType).setInfoKey(infoKey).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);
return files.get(0).getId(); return files.get(0).getId();

@ -153,11 +153,11 @@ public class InfNimsServiceBean extends AbstractServiceBean implements InfNimsSe
ApiUtil.checkYmdError(dto.getEdt(), "edt"); ApiUtil.checkYmdError(dto.getEdt(), "edt");
// FIXME: API 호출 시 주석 해제 // FIXME: API 호출 시 주석 해제
// String rslt = ApiUtil.callNimsApi(nimsUrl + dsuseresult, dto); String rslt = ApiUtil.callNimsApi(nimsUrl + dsuseresult, dto);
// NimsApiResult<NimsApiDto.DsuseRptInfo> result = json.parse(rslt, new TypeReference<>() {}); NimsApiResult<NimsApiDto.DsuseRptInfo> result = json.parse(rslt, new TypeReference<>() {});
// return result.getResponse(); return result.getResponse();
return getDsuseRptResponse(); // return getDsuseRptResponse();
} }
private NimsApiResult.Response<NimsApiDto.DsuseRptInfo> getDsuseRptResponse() { private NimsApiResult.Response<NimsApiDto.DsuseRptInfo> getDsuseRptResponse() {

@ -700,7 +700,14 @@
<!-- 폐기 보고 정보 업무 테이블 end --> <!-- 폐기 보고 정보 업무 테이블 end -->
<!-- ============================= --> <!-- ============================= -->
<select id="selectFileId" parameterType="map" resultType="string">
/** nims-mysql-mapper|selectFileId-fileId 조회|julim */
SELECT file_id AS fileId
FROM tb_file
WHERE INF_TYPE = #{infType}
AND INF_KEY = #{infKey}
AND SUB_TYPE = #{subType}
</select>

Loading…
Cancel
Save