Skip to content
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
47 changes: 47 additions & 0 deletions src/main/java/com/opendata/docs/MyPageControllerDocs.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,51 @@ ResponseEntity<com.opendata.global.response.ApiResponse<Void>> deleteTourSpot(
ResponseEntity<com.opendata.global.response.ApiResponse<UserResponse>> findUser(
@AuthenticationPrincipal CustomUserDetails customUserDetails
);



@Operation(summary = "관광지 선호 가능 여부 조회", description = "이미 선호관광지에 추가했으면 true 안 했으면 false 리턴")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "선호 가능 여부 조회 성공"),
@ApiResponse(
responseCode = "401",
description = "인증 실패",
content = @Content(
mediaType = "application/json",
examples = @ExampleObject(
name = "인증 실패 응답",
summary = "유효하지 않은 토큰 또는 로그인 필요",
value = """
{
"success": false,
"code": "COMMON_401",
"message": "인증이 필요합니다."
}
"""
)
)
),
@ApiResponse(
responseCode = "500",
description = "서버 에러",
content = @Content(
mediaType = "application/json",
examples = @ExampleObject(
name = "서버 에러 응답",
summary = "예상치 못한 서버 에러",
value = """
{
"success": false,
"code": "COMMON_500",
"message": "서버 에러, 관리자에게 문의 바랍니다."
}
"""
)
)
)
})
ResponseEntity<com.opendata.global.response.ApiResponse<Boolean>> CheckTourSpot(
@RequestParam Long tourSpotId,
@AuthenticationPrincipal CustomUserDetails customUserDetails
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ public ResponseEntity<ApiResponse<UserResponse>> findUser(
return ResponseEntity.ok(ApiResponse.onSuccess(mypageService.getUser(customUserDetails)));
}

@GetMapping("/preferences/check")
public ResponseEntity<ApiResponse<Boolean>> CheckTourSpot(
@RequestParam Long tourSpotId,
@AuthenticationPrincipal CustomUserDetails customUserDetails
){
return ResponseEntity.ok(ApiResponse.onSuccess(mypageService.isPreferenceTourSpot(customUserDetails, tourSpotId)));
}




Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.opendata.global.util.DateUtil;
import jakarta.transaction.Transactional;
import lombok.RequiredArgsConstructor;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.stereotype.Service;

import java.util.*;
Expand Down Expand Up @@ -116,4 +117,11 @@ public UserResponse getUser(CustomUserDetails customUserDetails)


}

public boolean isPreferenceTourSpot(@AuthenticationPrincipal CustomUserDetails customUserDetails, Long tourSpotId)
{
Long userId = customUserDetails.getUserId();
return tourSpotComponentRepository.existsByUserIdAndTourSpotId(userId, tourSpotId);
}

}