Skip to content

Commit

Permalink
refactor: 북마크, 제안 에러코드 수정 (#351)
Browse files Browse the repository at this point in the history
  • Loading branch information
xxoznge authored Jul 4, 2024
1 parent 9b63a38 commit 29c251d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
@AllArgsConstructor
public enum BookmarkErrorCode implements BaseErrorCode {

BOOKMARK_ERROR(HttpStatus.BAD_REQUEST, "BMK4000", "북마크 관련 에러");
BOOKMARK_ERROR(HttpStatus.BAD_REQUEST, "BMK4000", "북마크 관련 에러"),
CANNOT_BOOKMARK_TO_SELF(HttpStatus.BAD_REQUEST, "PROP4011", "본인에게는 북마크할 수 없습니다.");

private final HttpStatus httpStatus;
private final String code;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class BookmarkService {
public BookmarkToggleResponse bookmarkToggle(Organization organization, BookmarkToggleRequest request) {

if (organization.getId().equals(request.target()))
throw new BookmarkException(BookmarkErrorCode.BOOKMARK_ERROR);
throw new BookmarkException(BookmarkErrorCode.CANNOT_BOOKMARK_TO_SELF);

final Organization target = organizationRepository.findById(request.target())
.orElseThrow(() -> new OrganizationException(OrganizationErrorCode.ORGANIZATION_NOT_FOUND));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public enum ProposeErrorCode implements BaseErrorCode {
INVALID_PROPOSE_STATUS(HttpStatus.BAD_REQUEST, "PROP4005", "유효하지 않은 제안 상태입니다."),
PROPOSE_LIMIT_ERROR(HttpStatus.CONFLICT, "PROP4009", "하루 제안 5회 초과하였습니다."),
PROFILE_NOT_COMPLETED(HttpStatus.BAD_REQUEST, "PROP4010", "프로필이 작성되지 않았습니다."),
CANNOT_PROPOSE_TO_SELF(HttpStatus.BAD_REQUEST, "PROP4011", "본인에게는 제안할 수 없습니다."),
PROPOSE_NOT_FOUND(HttpStatus.NOT_FOUND, "PROP4040", "해당 제안이 존재하지 않습니다.");

private final HttpStatus httpStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ public class ProposeService {
public ProposeCreateResponse createPropose(Organization organization, ProposeCreateRequest request) {

if (organization.getId().equals(request.target()))
throw new ProposeException(ProposeErrorCode.PROPOSE_ERROR);
throw new ProposeException(ProposeErrorCode.CANNOT_PROPOSE_TO_SELF);

final Organization target = organizationRepository.findById(request.target())
.orElseThrow(() -> new OrganizationException(OrganizationErrorCode.ORGANIZATION_NOT_FOUND));

if (organization.getImageUrl() == null || organization.getImageUrl().isEmpty())
throw new ProposeException(ProposeErrorCode.PROFILE_NOT_COMPLETED);

final Long count = proposeRepository.countProposesByOrganizationToday(organization,
LocalDateTime.now().toLocalDate().atStartOfDay());

Expand Down

0 comments on commit 29c251d

Please sign in to comment.