Skip to content

Commit

Permalink
validateAddSpaceId와 checkDuplicateShareURL 메서드에 FlagType 매개변수 추가 완료 (F…
Browse files Browse the repository at this point in the history
…astcampus-Final-Team3#221)

* fix : validateAddSpaceId 메서드에 FlagType 매개변수 추가하여 SAVED 상태일 때만 예외 처리하도록 수정 (Fastcampus-Final-Team3#220)

* fix :  checkDuplicateShareURL 메서드에 FlagType 매개변수 추가하여 SAVED 상태일 때만 예외 처리하도록 수정 (Fastcampus-Final-Team3#220)
  • Loading branch information
dpdmstjs authored Oct 27, 2023
1 parent 4b21668 commit 9a41edd
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ public SpaceWallSaveResponse save(final Long memberId, final SpaceWallStringRequ

validateSpaceOwnership(member, addSpace);

validateAddSpaceId(addSpace.getId());
validateAddSpaceId(addSpace.getId(), flagType);

checkDuplicateShareURL(data.getShareURL());
checkDuplicateShareURL(data.getShareURL(), flagType);

SpaceWallCategoryType spaceWallCategoryType = SpaceWallCategoryType.findSpaceWallCategoryTypeByString(data.getCategory());

Expand Down Expand Up @@ -100,16 +100,16 @@ private void validateSpaceOwnership(final Member member, final AddSpace addSpace
}
}

private void validateAddSpaceId (final Long spaceId) {
private void validateAddSpaceId (final Long spaceId, FlagType flagType) {
boolean existsSpaceId = spaceWallRepository.existsByAddSpaceId(spaceId);
if (existsSpaceId) {
if (existsSpaceId && flagType == FlagType.SAVED) {
throw new ApplicationException(ApiStatus.INVALID_DATA, "스페이스 하나당 공유페이지 하나만 생성 가능합니다.");
}
}

private void checkDuplicateShareURL(final String shareURL) {
private void checkDuplicateShareURL(final String shareURL, FlagType flagType) {
boolean existsShareURL = spaceWallRepository.existsByShareURLAndFlag(shareURL, FlagType.SAVED);
if (existsShareURL) {
if (existsShareURL && flagType == FlagType.SAVED) {
throw new ApplicationException(ApiStatus.ALREADY_EXIST, "이미 사용중인 shareURL입니다.");
}
}
Expand Down

0 comments on commit 9a41edd

Please sign in to comment.