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

fix : 내 지역 설정 필수 에러 메시지 추가 #81

Merged
merged 1 commit into from
Aug 22, 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 @@ -41,6 +41,7 @@ public enum ErrorStatus implements BaseErrorCode {
//유저
USER_NOT_FOUND(HttpStatus.NOT_FOUND, "USER4001","해당 유저가 존재하지 않습니다."),
USER_SAME(HttpStatus.BAD_REQUEST,"USER4002","본인입니다."),
USER_REGION_NOT_FOUND(HttpStatus.NOT_FOUND, "USER4003", "내 지역 설정은 필수 입니다. 설정 후 다시 시도해주세요."),

//팔로우
FOLLOWING_NOT_FOUND(HttpStatus.NOT_FOUND, "FOLLOW4001","팔로우 중이 아닙니다."),
Expand Down
17 changes: 12 additions & 5 deletions src/main/java/com/example/locavel/domain/enums/Traveler.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.example.locavel.domain.enums;

import com.example.locavel.apiPayload.code.status.ErrorStatus;
import com.example.locavel.apiPayload.exception.handler.UserHandler;
import com.example.locavel.domain.Places;
import com.example.locavel.domain.User;
import com.fasterxml.jackson.annotation.JsonCreator;
Expand All @@ -15,12 +17,17 @@ public enum Traveler {

// 유저의 현지인/여행객 판단
public static Traveler of(Places place, User user) {
Long userRegion = user.getMy_area().getId();
Long placeRegion = place.getRegion().getId();
if (userRegion == placeRegion || userRegion.equals(placeRegion)) {
return NO; // 현지인
if(user.getMy_area() == null) {
throw new UserHandler(ErrorStatus.USER_REGION_NOT_FOUND);
}
else {
Long userRegion = user.getMy_area().getId();
Long placeRegion = place.getRegion().getId();
if (userRegion == placeRegion || userRegion.equals(placeRegion)) {
return NO; // 현지인
}
else return YES; //여행객
}
else return YES; //여행객
}
@JsonValue
public String getViewName() {
Expand Down