Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: 북마크, 제안 에러코드 수정 #351

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading