diff --git a/src/main/java/kusitms/gallae/controller/ManagerController.java b/src/main/java/kusitms/gallae/controller/ManagerController.java index 8d02c1f..e47d1ff 100644 --- a/src/main/java/kusitms/gallae/controller/ManagerController.java +++ b/src/main/java/kusitms/gallae/controller/ManagerController.java @@ -93,7 +93,7 @@ public ResponseEntity> saveProgram( PostModel model ) throws IOException { String photoUrl = null; - if(model.getPhoto() != null && !model.getPhoto().isEmpty()) { + if(model.getPhoto() != null && model.getPhotoCheck().equals("1")) { photoUrl = s3Service.upload(model.getPhoto()); } @@ -112,6 +112,7 @@ public ResponseEntity> saveProgram( programPostReq.setLink(model.getLink()); programPostReq.setHashtag(model.getHashtag()); programPostReq.setBody(model.getBody()); + programPostReq.setPhotoCheck(model.getPhotoCheck()); return ResponseEntity.ok(new BaseResponse<>(this.managerService.postProgram(programPostReq, principal.getName()))); } @@ -208,7 +209,7 @@ public ResponseEntity> tempSaveProgram( EditModel model ) throws IOException { String photoUrl = null; - if(model.getPhoto() != null) { + if(model.getPhoto() != null && model.getPhotoCheck().equals("1")) { photoUrl = s3Service.upload(model.getPhoto()); } ProgramPostReq programPostReq = new ProgramPostReq(); @@ -227,6 +228,7 @@ public ResponseEntity> tempSaveProgram( programPostReq.setLink(model.getLink()); programPostReq.setHashtag(model.getHashtag()); programPostReq.setBody(model.getBody()); + programPostReq.setPhotoCheck(model.getPhotoCheck()); return ResponseEntity.ok(new BaseResponse<>(this.managerService.editProgram(programPostReq, principal.getName()))); @@ -249,7 +251,7 @@ public ResponseEntity> tempSaveProgram( PostModel model ) throws IOException { String photoUrl = null; - if(model.getPhoto() != null && !model.getPhoto().isEmpty()) { + if(model.getPhoto() != null && model.getPhotoCheck().equals("1")) { photoUrl = s3Service.upload(model.getPhoto()); } ProgramPostReq programPostReq = new ProgramPostReq(); @@ -267,7 +269,7 @@ public ResponseEntity> tempSaveProgram( programPostReq.setLink(model.getLink()); programPostReq.setHashtag(model.getHashtag()); programPostReq.setBody(model.getBody()); - + programPostReq.setPhotoCheck(model.getPhotoCheck()); return ResponseEntity.ok(new BaseResponse<>(this.managerService.postTempProgram(programPostReq, principal.getName()))); } diff --git a/src/main/java/kusitms/gallae/dto/model/EditModel.java b/src/main/java/kusitms/gallae/dto/model/EditModel.java index 2202fb0..be9fa66 100644 --- a/src/main/java/kusitms/gallae/dto/model/EditModel.java +++ b/src/main/java/kusitms/gallae/dto/model/EditModel.java @@ -43,4 +43,6 @@ public class EditModel { private String body; private MultipartFile photo; + + private String photoCheck; } diff --git a/src/main/java/kusitms/gallae/dto/model/PostModel.java b/src/main/java/kusitms/gallae/dto/model/PostModel.java index bb436a0..e06d41c 100644 --- a/src/main/java/kusitms/gallae/dto/model/PostModel.java +++ b/src/main/java/kusitms/gallae/dto/model/PostModel.java @@ -45,4 +45,6 @@ public class PostModel { private String body; private MultipartFile photo; + + private String photoCheck; } diff --git a/src/main/java/kusitms/gallae/dto/program/ProgramPostReq.java b/src/main/java/kusitms/gallae/dto/program/ProgramPostReq.java index 7aaf8ad..84b749f 100644 --- a/src/main/java/kusitms/gallae/dto/program/ProgramPostReq.java +++ b/src/main/java/kusitms/gallae/dto/program/ProgramPostReq.java @@ -44,4 +44,6 @@ public class ProgramPostReq { private String hashtag; private String body; + + private String photoCheck; } \ No newline at end of file diff --git a/src/main/java/kusitms/gallae/service/admin/ManagerServiceImpl.java b/src/main/java/kusitms/gallae/service/admin/ManagerServiceImpl.java index 2ab5e88..9ac60bf 100644 --- a/src/main/java/kusitms/gallae/service/admin/ManagerServiceImpl.java +++ b/src/main/java/kusitms/gallae/service/admin/ManagerServiceImpl.java @@ -199,10 +199,10 @@ private List getProgramManagerRes(List programs){ private Program getProgramEntity(Program program ,ProgramPostReq programPostReq) { program.setProgramName(programPostReq.getProgramName()); - if(program.getPhotoUrl()==null) { - program.setPhotoUrl(programPostReq.getPhotoUrl()); - }else{ - s3Service.deleteFile(program.getPhotoUrl()); + if(programPostReq.getPhotoCheck().equals("1")) { + if (program.getPhotoUrl() != null) { + s3Service.deleteFile(program.getPhotoUrl()); + } program.setPhotoUrl(programPostReq.getPhotoUrl()); } program.setLocation(programPostReq.getLocation());