Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hot fix : 이미지 변경사항이 있는지 공고등록 model에 추가 #38

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading