Skip to content

Commit 026f92b

Browse files
authored
Merge pull request #154 from CorkCharge/fix/#153-bookmark-group
[FIX] 그룹명 기존과 같아도 색상 및 공개여부만 변경 가능하도록 로직 수정
2 parents 2235dfa + 184e815 commit 026f92b

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

src/main/java/konkuk/corkCharge/domain/bookmark/repository/RestaurantBookmarkGroupRepository.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
public interface RestaurantBookmarkGroupRepository extends JpaRepository<RestaurantBookmarkGroup, Long> {
1111
List<RestaurantBookmarkGroup> findAllByIdIn(List<Long> ids);
1212
boolean existsByUser_UserIdAndName(Long userId, String name);
13+
boolean existsByUser_UserIdAndNameAndIdNot(Long userId, String name, Long groupId);
1314
int countByUser_UserId(Long userId);
1415
List<RestaurantBookmarkGroup> findAllByUser_UserIdOrderByDisplayOrderAsc(Long userId);
1516
@Query("""

src/main/java/konkuk/corkCharge/domain/bookmark/service/BookmarkGroupService.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,15 @@ public PutBookmarkGroupResponse updateGroup(
9595
throw new CustomException(BAD_REQUEST);
9696
}
9797

98-
// 기존 이름과 완전히 동일한 경우
99-
if (group.getName().equals(request.name())) {
100-
throw new CustomException(GROUP_NAME_SAME_AS_BEFORE);
98+
// 기존의 내용과 전체 동일할 경우에만 예외 터뜨릴 것(name, color, visibility)
99+
if (group.getName().equals(request.name())
100+
&& group.getColor().equals(request.color())
101+
&& group.getVisibility() == request.visibility()) {
102+
throw new CustomException(GROUP_CONTENTS_SAME_AS_BEFORE);
101103
}
102104

103105
// 다른 그룹이 이미 사용 중인 이름인 경우
104-
if (groupRepository.existsByUser_UserIdAndName(userId, request.name())) {
106+
if (groupRepository.existsByUser_UserIdAndNameAndIdNot(userId, request.name(), groupId)) {
105107
throw new CustomException(GROUP_NAME_ALREADY_EXISTS);
106108
}
107109

src/main/java/konkuk/corkCharge/global/response/status/BaseExceptionResponseStatus.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public enum BaseExceptionResponseStatus implements ResponseStatus {
6969
GROUP_NOT_FOUND(120001, "해당 북마크 그룹을 찾을 수 없습니다."),
7070
GROUP_FORBIDDEN(120002, "해당 북마크 그룹에 대한 권한이 없습니다."),
7171
BOOKMARK_ALREADY_EXISTS(120003, "이미 저장된 매장입니다."),
72-
GROUP_NAME_SAME_AS_BEFORE(120004, "기존 그룹명과 동일합니다."),
72+
GROUP_CONTENTS_SAME_AS_BEFORE(120004, "기존 그룹 내용과 동일합니다."),
7373
GROUP_NAME_ALREADY_EXISTS(120005, "이미 존재하는 그룹명입니다."),
7474

7575
/**

0 commit comments

Comments
 (0)