Skip to content

Commit

Permalink
hot fix : 이미지 변경사항이 있는지 공고등록 model에 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
MyunghyunNero committed Nov 23, 2023
1 parent 76fd537 commit 4f04ddd
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
10 changes: 6 additions & 4 deletions src/main/java/kusitms/gallae/controller/ManagerController.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public ResponseEntity<BaseResponse<Long>> 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());
}

Expand All @@ -112,6 +112,7 @@ public ResponseEntity<BaseResponse<Long>> 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())));
}
Expand Down Expand Up @@ -208,7 +209,7 @@ public ResponseEntity<BaseResponse<Long>> 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();
Expand All @@ -227,6 +228,7 @@ public ResponseEntity<BaseResponse<Long>> 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())));
Expand All @@ -249,7 +251,7 @@ public ResponseEntity<BaseResponse<Long>> 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();
Expand All @@ -267,7 +269,7 @@ public ResponseEntity<BaseResponse<Long>> 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())));
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/kusitms/gallae/dto/model/EditModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,6 @@ public class EditModel {
private String body;

private MultipartFile photo;

private String photoCheck;
}
2 changes: 2 additions & 0 deletions src/main/java/kusitms/gallae/dto/model/PostModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ public class PostModel {
private String body;

private MultipartFile photo;

private String photoCheck;
}
2 changes: 2 additions & 0 deletions src/main/java/kusitms/gallae/dto/program/ProgramPostReq.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,6 @@ public class ProgramPostReq {
private String hashtag;

private String body;

private String photoCheck;
}
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@ private List<ProgramManagerRes> getProgramManagerRes(List<Program> 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());
Expand Down

0 comments on commit 4f04ddd

Please sign in to comment.