|
|
|
@ -84,23 +84,23 @@ public class CtgyFileService implements ICtgyFileService {
|
|
|
|
|
String orgFileName = "";
|
|
|
|
|
try {
|
|
|
|
|
orgFileName = StringUtils.cleanPath(Objects.requireNonNull(mf.getOriginalFilename()));
|
|
|
|
|
MinInfoBoard680 savedEntity = null;
|
|
|
|
|
|
|
|
|
|
// 파일 저장 && 전송
|
|
|
|
|
MinInfoBoard680 savedEntity = repository.findById(entity.getInCode()).orElseGet(MinInfoBoard680::new);
|
|
|
|
|
if(Checks.isEmpty(entity.getInCode()))
|
|
|
|
|
savedEntity = new MinInfoBoard680();
|
|
|
|
|
else
|
|
|
|
|
savedEntity = repository.findById(entity.getInCode()).orElseGet(MinInfoBoard680::new);
|
|
|
|
|
savedEntity.setInFilename(orgFileName);
|
|
|
|
|
savedEntity.setInFilesize(mf.getSize());
|
|
|
|
|
savedEntity.setInFileurl(serviceUrl + urlPath);
|
|
|
|
|
savedEntity.setInBgubun(CtgyConstants.PublicBoard.GUBUN.getCode());
|
|
|
|
|
savedEntity.setInDept(entity.getInDept());
|
|
|
|
|
savedEntity.setInTitle(entity.getInTitle());
|
|
|
|
|
savedEntity.setInContents(entity.getInContents());
|
|
|
|
|
|
|
|
|
|
JpaUtil.saveIfNullId(savedEntity.getInCode(), repository, savedEntity);
|
|
|
|
|
setEntity(savedEntity, entity);
|
|
|
|
|
JpaUtil.saveIfNullId(entity.getInCode(), repository, savedEntity);
|
|
|
|
|
|
|
|
|
|
entityList.add(savedEntity);
|
|
|
|
|
mf.transferTo(new File(fileUploadPath + File.separator + orgFileName));
|
|
|
|
|
|
|
|
|
|
// inputStream을 가져와서
|
|
|
|
|
// inputStream을 가져와
|
|
|
|
|
// copyOfLocation (저장위치)로 파일을 쓴다.
|
|
|
|
|
// copy의 옵션은 기존에 존재하면 REPLACE(대체한다), 오버라이딩 한다
|
|
|
|
|
//Files.copy(multipartFile.getInputStream(), copyOfLocation, StandardCopyOption.REPLACE_EXISTING);
|
|
|
|
@ -114,12 +114,14 @@ public class CtgyFileService implements ICtgyFileService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
MinInfoBoard680 savedEntity = repository.findById(entity.getInCode()).orElseGet(MinInfoBoard680::new);
|
|
|
|
|
savedEntity.setInBgubun(CtgyConstants.PublicBoard.GUBUN.getCode());
|
|
|
|
|
savedEntity.setInDept(entity.getInDept());
|
|
|
|
|
savedEntity.setInTitle(entity.getInTitle());
|
|
|
|
|
savedEntity.setInContents(entity.getInContents());
|
|
|
|
|
JpaUtil.saveIfNullId(savedEntity.getInCode(), repository, savedEntity);
|
|
|
|
|
MinInfoBoard680 savedEntity = null;
|
|
|
|
|
if(Checks.isEmpty(entity.getInCode()))
|
|
|
|
|
savedEntity = new MinInfoBoard680();
|
|
|
|
|
else
|
|
|
|
|
savedEntity = repository.findById(entity.getInCode()).orElseGet(MinInfoBoard680::new);
|
|
|
|
|
|
|
|
|
|
setEntity(savedEntity, entity);
|
|
|
|
|
JpaUtil.saveIfNullId(entity.getInCode(), repository, savedEntity);
|
|
|
|
|
}
|
|
|
|
|
return entityList;
|
|
|
|
|
}
|
|
|
|
@ -139,8 +141,22 @@ public class CtgyFileService implements ICtgyFileService {
|
|
|
|
|
repository.deleteById(inCode);
|
|
|
|
|
if(file.exists()) file.delete();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setEntity(MinInfoBoard680 savedEntity, MinInfoBoard680 entity){
|
|
|
|
|
savedEntity.setInBgubun(CtgyConstants.PublicBoard.GUBUN.getCode());
|
|
|
|
|
savedEntity.setInDept(entity.getInDept());
|
|
|
|
|
savedEntity.setInTitle(entity.getInTitle());
|
|
|
|
|
savedEntity.setInContents(entity.getInContents());
|
|
|
|
|
|
|
|
|
|
if(Checks.isEmpty(entity.getInCode())) {
|
|
|
|
|
savedEntity.setInCode(repository.getInCodeByInBgubun());
|
|
|
|
|
savedEntity.setInContentno(savedEntity.getInCode());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
// File.seperator 는 OS종속적이다.
|
|
|
|
|
// Spring에서 제공하는 cleanPath()를 통해서 ../ 내부 점들에 대해서 사용을 억제한다
|
|
|
|
|