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
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public enum SuccessCode {
LOGOUT_SUCCESS(20012, "로그아웃 성공"),
USER_DELETE_SUCCESS(20013, "회원 탈퇴 성공"),
USER_UPDATE_REJECT(20014, "회원 정보 수정 거절(서울지역이 아닙니다)"),
MAP_SEARCH_SUCCESS(20015, "지도 검색 성공"),
MAP_SEARCH_REJECT(20016, "지도 검색 거절(서울지역이 아닙니다)"),
//201 CREATED
ROOM_REQUEST_POST_SUCCESS(20101, "입주 신청 성공"),
SOCIAL_SIGNUP_SUCCESS(20102, "소셜 회원가입 성공");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import server.producer.domain.dto.request.FilterRequestDto;
import server.producer.domain.dto.response.FilterResponseDto;
import server.producer.domain.service.MapService;
import java.util.ArrayList;

@RestController
@RequestMapping("/v1/maps")
Expand All @@ -22,7 +23,14 @@ public ApiResponseDto<FilterResponseDto> searchPropertiesOnMap(@RequestBody Filt
try {
Long userId = SecurityUtil.getCurrentUserId();
FilterResponseDto responseDto = mapService.searchProperties(requestDto, userId);
return ApiResponseDto.success(SuccessCode.HOUSE_GET_SUCCESS, responseDto);
return ApiResponseDto.success(SuccessCode.MAP_SEARCH_SUCCESS, responseDto);
} catch (IllegalArgumentException e) {
FilterResponseDto responseDto = FilterResponseDto.builder()
.houses(new ArrayList<>())
.latitude(37.55348)
.longitude(126.9381)
.build();
return ApiResponseDto.success(SuccessCode.MAP_SEARCH_REJECT, responseDto);
} catch (InvalidRequestException invalidRequestException) {
return ApiResponseDto.fail(ErrorCode.MISSING_REQUIRED_PARAMETER);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public List<House> findFilteredHouses(FilterRequestDto filter) {
filter.getMonthlyRentRange().getMin() * TENTHOUSAND,
filter.getMonthlyRentRange().getMax() * TENTHOUSAND));

predicates.add(cb.notEqual(room.get("status"), room.get("occupancyType")));
// predicates.add(cb.notEqual(room.get("status"), room.get("occupancyType")));

// Optional 조건: moodTags (리스트, OR 조건)
if (filter.getMoodTags() != null && !filter.getMoodTags().isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,18 @@ public class MapService {
public FilterResponseDto searchProperties(FilterRequestDto requestDto, Long userId){
User user = userRepository.findById(userId)
.orElseThrow(() -> new EntityNotFoundException("User not found"));
if (requestDto.getLatitude() == null || requestDto.getLongitude() == null) {

if (requestDto.getLocation() != null) {
String[] locationsStrings = requestDto.getLocation().split(" ");
if (locationsStrings.length >= 3) {
requestDto.setLocation(locationsStrings[0] + " " + locationsStrings[1] + " " + locationsStrings[2]);
if (!locationsStrings[0].contains("서울")) {
throw new IllegalArgumentException("Invalid location");
}
}
}
if (requestDto.getLatitude() == null || requestDto.getLongitude() == null || requestDto.getLocation() == null) {
requestDto.setLocation(user.getLocation());
requestDto.setLatitude(user.getLatitude());
requestDto.setLongitude(user.getLongitude());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public LocationUpdateResponseDto updateLocation(Long userId, LocationUpdateReque
try {
String[] locationParts = requestDto.getLocation().split(" ");
if (locationParts.length >= 3) {
if (locationParts[0].equals("서울특별시")) {
if (locationParts[0].contains("서울")) {
User user = userRepository.findById(userId)
.orElseThrow(() -> new EntityNotFoundException("User not found"));
user.setLatitude(requestDto.getLatitude());
Expand Down
120 changes: 0 additions & 120 deletions producer/src/test/java/domain/repository/FilterRepositoryTest.java

This file was deleted.

Loading