Skip to content

Commit

Permalink
Merge tag '20240109-hotfix' into develop
Browse files Browse the repository at this point in the history
   20240109-hotfix
  • Loading branch information
dragontaek-lee committed Jan 8, 2024
2 parents 11073b9 + 92584c6 commit 4848f3c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public enum ExceptionMessage {
ALREADY_FIRST_WORK("이미 대표 작업물 입니다."),
NOT_FOUND_FIRST_WORK("대표 작업을 찾을 수 없습니다."),
NOT_WORK_OWNER("작업물의 주인이 아닙니다."),
WORK_NO_THUMBNAIL("작업물의 썸네일이 없습니다."),

/** Magazine **/
NOT_FOUND_MAGAZINE("해당하는 매거진을 찾을 수 없습니다."),
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/gam/api/service/work/WorkServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.springframework.transaction.annotation.Transactional;

import javax.persistence.EntityNotFoundException;
import java.util.Objects;


@RequiredArgsConstructor
Expand All @@ -44,6 +45,10 @@ public WorkResponseDTO createWork(Long userId, WorkCreateRequestDTO request) {
user.updateUserStatus(UserStatus.PERMITTED);
}

if (Objects.equals(request.image(), "")) {
throw new WorkException(ExceptionMessage.WORK_NO_THUMBNAIL.getMessage(), HttpStatus.BAD_REQUEST);
}

val work = workRepository.save(Work.builder()
.title(request.title())
.detail(request.detail())
Expand Down Expand Up @@ -76,6 +81,10 @@ public WorkResponseDTO deleteWork(Long userId, WorkDeleteRequestDTO request) {

val photoUrl = work.getPhotoUrl();

if (Objects.equals(photoUrl, "")) {
throw new WorkException(ExceptionMessage.WORK_NO_THUMBNAIL.getMessage(), HttpStatus.BAD_REQUEST);
}

s3Service.deleteS3Image(photoUrl);

workRepository.deleteById(workId);
Expand Down

0 comments on commit 4848f3c

Please sign in to comment.