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

[BE] 체크리스트 지하철 정보 저장 시 위도, 경도가 NULL 인 경우도 허용한다. #1065

Merged
merged 3 commits into from
Dec 10, 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 @@ -349,8 +349,8 @@ private void updateChecklistMaintenances(ChecklistRequest checklistRequest, Chec
}

private void updateChecklistStations(RoomRequest roomRequest, Checklist checklist) {
double latitude = roomRequest.latitude();
double longitude = roomRequest.longitude();
Double latitude = roomRequest.latitude();
Double longitude = roomRequest.longitude();
checklistStationService.updateChecklistStation(checklist, latitude, longitude);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class ChecklistStationService {
private final SubwayStationService subwayStationService;

@Transactional
public void createChecklistStations(Checklist checklist, double latitude, double longitude) {
public void createChecklistStations(Checklist checklist, Double latitude, Double longitude) {
saveChecklistStations(checklist, latitude, longitude);
}

Expand All @@ -28,7 +28,7 @@ public List<ChecklistStation> readChecklistStationsByChecklist(Checklist checkli
}

@Transactional
public void updateChecklistStation(Checklist checklist, double latitude, double longitude) {
public void updateChecklistStation(Checklist checklist, Double latitude, Double longitude) {
checklistStationRepository.deleteAllByChecklistId(checklist.getId());
saveChecklistStations(checklist, latitude, longitude);
}
Expand All @@ -38,7 +38,10 @@ public void deleteChecklistStation(Long checklistId) {
checklistStationRepository.deleteAllByChecklistId(checklistId);
}

private void saveChecklistStations(Checklist checklist, double latitude, double longitude) {
private void saveChecklistStations(Checklist checklist, Double latitude, Double longitude) {
if (latitude == null || longitude == null) {
return;
}
Comment on lines +42 to +44
Copy link
Contributor

@JINU-CHANG JINU-CHANG Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수정 API에서는 여기서 null로 저장되어야하지 않을까요?? 지금은 그냥 return되고 있어 수정사항이 반영되지 않을 것 같아요!

Copy link
Contributor Author

@tkdgur0906 tkdgur0906 Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

확인해봤는데 체크리스트 수정할 때 updateChecklistByIdV1 메서드에서 이미 room 정보를 통째로 수정해서 위도, 경도가 변경된 값으로 초기화 되더라고요! 그래서 처리하지 않아도 될 것 같습니다!

Copy link
Contributor

@JINU-CHANG JINU-CHANG Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

room 정보말고 지하철 정보를 말한 거였어요! checklist_station은 그대로이지 않나요 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checklistStation도 다시 새로운 지하철 정보 저장하기 전에 32번째 줄에 checklistStationRepository.deleteAllByChecklistId(checklist.getId()) 호출해 초기화해줘서
새로운 지하철 정보로 바뀌어서 문제 없을 것 같습니다!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

테스트 결과를 잘못보고 있엇네요,,ㅎㅎ 고생하셨습니다 👍

List<SubwayStationResponse> responses = subwayStationService.readNearestStation(latitude, longitude)
.getStations();
List<ChecklistStation> checklistStations = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ public static ChecklistRequestV1 CHECKLIST_CREATE_REQUEST_V1() {
);
}

public static ChecklistRequestV1 CHECKLIST_CREATE_REQUEST_V1_EMPTY_LOCATION() {
return new ChecklistRequestV1(
RoomFixture.ROOM_CREATE_REQUEST_EMPTY_LOCATION(),
List.of(Option.REFRIGERATOR.getId(), Option.SINK.getId(), Option.INDUCTION.getId(),
Option.SHOE_RACK.getId()),
List.of(QUESTION_1_CREATE_REQUEST(), QUESTION_2_CREATE_REQUEST(),
QUESTION_3_CREATE_REQUEST(), QUESTION_5_CREATE_REQUEST())
);
}

public static ChecklistRequest CHECKLIST_CREATE_REQUEST2() {
return new ChecklistRequest(
RoomFixture.ROOM_CREATE_REQUEST(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,20 @@ void createChecklistV1() {
assertThat(checklistId).isGreaterThan(0);
}

@DisplayName("체크리스트 작성 v1 성공 : 위도, 경도가 null 인 경우")
@Test
void createChecklistV1_emptyLocation() {
//given
User user = userRepository.save(UserFixture.USER1());
ChecklistRequestV1 checklistRequestV1 = ChecklistFixture.CHECKLIST_CREATE_REQUEST_V1_EMPTY_LOCATION();

// when
long checklistId = checklistManageService.createChecklistV1(user, checklistRequestV1);

//then
assertThat(checklistId).isGreaterThan(0);
}

@DisplayName("작성된 체크리스트 조회 성공")
@Test
void readChecklist() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ public static RoomRequest ROOM_CREATE_REQUEST() {
);
}

public static RoomRequest ROOM_CREATE_REQUEST_EMPTY_LOCATION() {
return new RoomRequest(
"방이름", "부산광역시 북구", "루터회관", "잠실",
10, 1000, 50, 5,
List.of(1, 3), FloorLevel.GROUND.getName(), 10,
Structure.TWO_ROOM.getName(), 3.3, null, null,
12, OccupancyMonth.APRIL.getMonth(),
OccupancyPeriod.EARLY.getPeriod(),
"방끗공인중개사", "메모", "한줄평"
);
}

public static RoomRequest ROOM_UPDATE_REQUEST() {
return new RoomRequest(
"방이름", "부산광역시 루터회관", "잠실역", "루터회관",
Expand Down
Loading