Skip to content

Commit 3bf9b02

Browse files
authored
Fix/#171 fix history detail (#172)
* refactor: history가 매칭이 안됐을 때 오류 문구 수정 * fix: 공유받은 기도제목 일부 history가 매칭이 안되는 문제 해결 * fix: 보관함에 있는 기도제목 저장하기 할 시 startdate 저장 안되던 오류 해결 * fix: 공유 받은 기도제목 조회시 카테고리가 없는 경우 에러처리 * fix: custom exception 이용 방식 수정 및 기존 에러 처리 코드 수정
1 parent 57c4729 commit 3bf9b02

25 files changed

+66
-128
lines changed

src/main/java/com/uspray/uspray/domain/Group.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ public void kickMember(GroupMember groupMember) {
6565

6666
public void validateGroupName(String newName) {
6767
if (this.name.equals(newName)) {
68-
throw new CustomException(ErrorStatus.ALREADY_EXIST_GROUP_NAME_EXCEPTION,
69-
ErrorStatus.ALREADY_EXIST_GROUP_NAME_EXCEPTION.getMessage());
68+
throw new CustomException(ErrorStatus.ALREADY_EXIST_GROUP_NAME_EXCEPTION);
7069
}
7170
}
7271

@@ -75,8 +74,7 @@ public void checkLeaderAuthorization(Member member) {
7574
System.out.println(leader.getUserId());
7675
System.out.println(member.getUserId());
7776
if (!leader.equals(member)) {
78-
throw new CustomException(ErrorStatus.GROUP_UNAUTHORIZED_EXCEPTION,
79-
ErrorStatus.GROUP_UNAUTHORIZED_EXCEPTION.getMessage());
77+
throw new CustomException(ErrorStatus.GROUP_UNAUTHORIZED_EXCEPTION);
8078
}
8179
}
8280
}

src/main/java/com/uspray/uspray/domain/Pray.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ public void update(PrayUpdateRequestDto prayUpdateRequestDto,
105105

106106
private void handleUpdateContentSharedPray(boolean isShared, String content) {
107107
if (isShared && content != null) {
108-
throw new NotFoundException(ErrorStatus.ALREADY_SHARED_EXCEPTION,
109-
ErrorStatus.ALREADY_SHARED_EXCEPTION.getMessage());
108+
throw new NotFoundException(ErrorStatus.ALREADY_SHARED_EXCEPTION);
110109
}
111110
}
112111

src/main/java/com/uspray/uspray/exception/ErrorStatus.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public enum ErrorStatus {
3333
CANNOT_RECEIVE_SHARED_PRAY_EXCEPTION(HttpStatus.BAD_REQUEST,
3434
"이미 보관함에 있는 기도제목이거나 공유받을 수 없는 기도제목입니다."),
3535
ALREADY_EXIST_PHONE_EXCEPTION(HttpStatus.BAD_REQUEST, "이미 사용중인 핸드폰 번호입니다."),
36+
NO_CATEGORY_EXCEPTION(HttpStatus.BAD_REQUEST, "카테고리가 존재하지 않습니다."),
3637

3738
/*
3839
* 401 UNAUTHORIZED
@@ -44,10 +45,11 @@ public enum ErrorStatus {
4445
* 403 FORBIDDEN
4546
*/
4647
PRAY_UNAUTHORIZED_EXCEPTION(HttpStatus.FORBIDDEN, "해당 기도제목에 대한 권한이 없습니다."),
47-
SHARE_NOT_AUTHORIZED_EXCEPTION(HttpStatus.UNAUTHORIZED, "기도제목을 공유할 권한이 없습니다."),
48-
DELETE_NOT_AUTHORIZED_EXCEPTION(HttpStatus.UNAUTHORIZED, "기도제목을 삭제할 권한이 없습니다."),
49-
CATEGORY_UNAUTHORIZED_EXCEPTION(HttpStatus.UNAUTHORIZED, "해당 카테고리에 대한 권한이 없습니다."),
50-
GROUP_UNAUTHORIZED_EXCEPTION(HttpStatus.UNAUTHORIZED, "해당 모임에 대한 권한이 없습니다."),
48+
SHARE_NOT_AUTHORIZED_EXCEPTION(HttpStatus.FORBIDDEN, "기도제목을 공유할 권한이 없습니다."),
49+
DELETE_NOT_AUTHORIZED_EXCEPTION(HttpStatus.FORBIDDEN, "기도제목을 삭제할 권한이 없습니다."),
50+
CATEGORY_UNAUTHORIZED_EXCEPTION(HttpStatus.FORBIDDEN, "해당 카테고리에 대한 권한이 없습니다."),
51+
GROUP_UNAUTHORIZED_EXCEPTION(HttpStatus.FORBIDDEN, "해당 모임에 대한 권한이 없습니다."),
52+
HISTORY_MISS_MATCH_EXCEPTION(HttpStatus.FORBIDDEN, "해당 히스토리에 대한 접근 권한이 없습니다."),
5153

5254
/**
5355
* 404 NOT FOUND

src/main/java/com/uspray/uspray/exception/model/CustomException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
public class CustomException extends RuntimeException{
88
private final ErrorStatus errorStatus;
99

10-
public CustomException(ErrorStatus errorStatus, String message) {
11-
super(message);
10+
public CustomException(ErrorStatus errorStatus) {
11+
super(errorStatus.getMessage());
1212
this.errorStatus = errorStatus;
1313
}
1414

src/main/java/com/uspray/uspray/exception/model/ExistIdException.java

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/main/java/com/uspray/uspray/exception/model/NotFoundException.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
import com.uspray.uspray.exception.ErrorStatus;
44
public class NotFoundException extends CustomException{
55

6-
public NotFoundException(ErrorStatus errorStatus,
7-
String message) {
8-
super(errorStatus, message);
6+
public NotFoundException(ErrorStatus errorStatus) {
7+
super(errorStatus);
98
}
109
}

src/main/java/com/uspray/uspray/exception/model/TokenNotValidException.java

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/main/java/com/uspray/uspray/infrastructure/CategoryRepository.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,19 @@ default Category getCategoryByIdAndMember(Long categoryId, Member member) {
2626
Category category = findById(categoryId)
2727
.filter(c -> c.getMember().equals(member))
2828
.orElseThrow(() -> new NotFoundException(
29-
ErrorStatus.CATEGORY_NOT_FOUND_EXCEPTION,
30-
ErrorStatus.CATEGORY_NOT_FOUND_EXCEPTION.getMessage()
29+
ErrorStatus.CATEGORY_NOT_FOUND_EXCEPTION
3130
));
3231

3332
if (!category.getCategoryType().equals(CategoryType.PERSONAL)) {
34-
throw new CustomException(ErrorStatus.PRAY_CATEGORY_TYPE_MISMATCH,
35-
ErrorStatus.PRAY_CATEGORY_TYPE_MISMATCH.getMessage());
33+
throw new CustomException(ErrorStatus.PRAY_CATEGORY_TYPE_MISMATCH);
3634
}
3735

3836
return category;
3937
}
4038

4139
default void checkDuplicate(String name, Member member, CategoryType type) {
4240
if (existsByNameAndMemberAndCategoryType(name, member, type)) {
43-
throw new NotFoundException(ErrorStatus.CATEGORY_DUPLICATE_EXCEPTION,
44-
ErrorStatus.CATEGORY_DUPLICATE_EXCEPTION.getMessage());
41+
throw new NotFoundException(ErrorStatus.CATEGORY_DUPLICATE_EXCEPTION);
4542
}
4643
}
4744

@@ -59,8 +56,7 @@ default int checkDuplicateAndReturnMaxOrder(String name, Member member, Category
5956
default int getMaxCategoryOrder(Member member, CategoryType type) {
6057
Category category = getCategoriesByMemberAndCategoryTypeOrderByOrder(member, type).stream()
6158
.reduce((first, second) -> second)
62-
.orElseThrow(() -> new NotFoundException(ErrorStatus.CATEGORY_NOT_FOUND_EXCEPTION,
63-
ErrorStatus.CATEGORY_NOT_FOUND_EXCEPTION.getMessage()));
59+
.orElseThrow(() -> new NotFoundException(ErrorStatus.CATEGORY_NOT_FOUND_EXCEPTION));
6460
return category.getOrder();
6561
}
6662
}

src/main/java/com/uspray/uspray/infrastructure/GroupMemberRepository.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,12 @@ public interface GroupMemberRepository extends JpaRepository<GroupMember, Long>
2222

2323
default GroupMember getGroupMemberByGroupAndMember(Group group, Member member) {
2424
return this.findByGroupAndMember(group, member).orElseThrow(
25-
() -> new NotFoundException(ErrorStatus.NOT_FOUND_GROUP_MEMBER_EXCEPTION,
26-
ErrorStatus.NOT_FOUND_GROUP_MEMBER_EXCEPTION.getMessage()));
25+
() -> new NotFoundException(ErrorStatus.NOT_FOUND_GROUP_MEMBER_EXCEPTION));
2726
}
2827

2928
default GroupMember getGroupMemberByGroupIdAndMemberId(Long groupId, Long memberId) {
3029
return this.findByGroupIdAndMemberId(groupId, memberId).orElseThrow(
31-
() -> new NotFoundException(ErrorStatus.NOT_FOUND_GROUP_MEMBER_EXCEPTION,
32-
ErrorStatus.NOT_FOUND_GROUP_MEMBER_EXCEPTION.getMessage()));
30+
() -> new NotFoundException(ErrorStatus.NOT_FOUND_GROUP_MEMBER_EXCEPTION));
3331
}
3432

3533
GroupMember findGroupMemberByMemberAndGroupId(Member member, Long groupId);

src/main/java/com/uspray/uspray/infrastructure/GroupPrayRepository.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ public interface GroupPrayRepository extends JpaRepository<GroupPray, Long> {
2020

2121
default GroupPray getGroupPrayById(Long id) {
2222
return this.findById(id).orElseThrow(
23-
() -> new NotFoundException(ErrorStatus.NOT_FOUND_GROUP_PRAY_EXCEPTION,
24-
ErrorStatus.NOT_FOUND_GROUP_PRAY_EXCEPTION.getMessage()));
23+
() -> new NotFoundException(ErrorStatus.NOT_FOUND_GROUP_PRAY_EXCEPTION));
2524
}
2625

2726
default void deleteAllByGroup(Group group) {

0 commit comments

Comments
 (0)