-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: 복덕방 단일 조회 #156
Merged
Merged
feat: 복덕방 단일 조회 #156
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
3856f54
feat : controller 구현
daheeParkk b8f548b
feat : repository에 id로 조회 기능 생성
daheeParkk 8d6a74c
feat : service에 조회 기능 구현
daheeParkk f9c5962
feat : 응답 DTO 구현
daheeParkk 36b4504
refactor : domain 필드 자료형 변경
daheeParkk 2e122f4
refactor : stream 라인 변경
daheeParkk 3f0bdac
refactor : 코드 축약
daheeParkk 676d359
test : 단일 조회 테스트 작성
daheeParkk f9b92bf
refactor : 에러 메시지 구체적으로 수정
daheeParkk a478c54
refactor : 기존 응답 구조와 동일하도록 수정
daheeParkk 4844a2a
test : 테스트에 이미지 추가
daheeParkk bf7f785
fix : 충돌 해결
daheeParkk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
src/main/java/in/koreatech/koin/domain/land/dto/LandResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package in.koreatech.koin.domain.land.dto; | ||
|
||
import static com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import com.fasterxml.jackson.databind.annotation.JsonNaming; | ||
|
||
import in.koreatech.koin.domain.land.model.Land; | ||
|
||
@JsonNaming(value = SnakeCaseStrategy.class) | ||
public record LandResponse( | ||
Boolean optElectronicDoorLocks, | ||
Boolean optTv, | ||
String monthlyFee, | ||
Boolean optElevator, | ||
Boolean optWaterPurifier, | ||
Boolean optWasher, | ||
Double latitude, | ||
String charterFee, | ||
Boolean optVeranda, | ||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime createdAt, | ||
String description, | ||
List<String> imageUrls, | ||
Boolean optGasRange, | ||
Boolean optInduction, | ||
String internalName, | ||
Boolean isDeleted, | ||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime updatedAt, | ||
Boolean optBidet, | ||
Boolean optShoeCloset, | ||
Boolean optRefrigerator, | ||
Long id, | ||
Long floor, | ||
String managementFee, | ||
Boolean optDesk, | ||
Boolean optCloset, | ||
Double longitude, | ||
String address, | ||
Boolean optBed, | ||
Double size, | ||
String phone, | ||
Boolean optAirConditioner, | ||
String name, | ||
String deposit, | ||
Boolean optMicrowave, | ||
String permalink, | ||
String roomType) { | ||
|
||
public static LandResponse of(Land land, List<String> imageUrls, String permalink) { | ||
return new LandResponse( | ||
land.getOptElectronicDoorLocks(), | ||
land.getOptTv(), | ||
land.getMonthlyFee(), | ||
land.getOptElevator(), | ||
land.getOptWaterPurifier(), | ||
land.getOptWasher(), | ||
land.getLatitude(), | ||
land.getCharterFee(), | ||
land.getOptVeranda(), | ||
land.getCreatedAt(), | ||
land.getDescription(), | ||
imageUrls, | ||
land.getOptGasRange(), | ||
land.getOptInduction(), | ||
land.getInternalName(), | ||
land.getIsDeleted(), | ||
land.getUpdatedAt(), | ||
land.getOptBidet(), | ||
land.getOptShoeCloset(), | ||
land.getOptRefrigerator(), | ||
land.getId(), | ||
land.getFloor(), | ||
land.getManagementFee(), | ||
land.getOptDesk(), | ||
land.getOptCloset(), | ||
land.getLongitude(), | ||
land.getAddress(), | ||
land.getOptBed(), | ||
land.getSize(), | ||
land.getPhone(), | ||
land.getOptAirConditioner(), | ||
land.getName(), | ||
land.getDeposit(), | ||
land.getOptMicrowave(), | ||
permalink, | ||
land.getRoomType() | ||
); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/in/koreatech/koin/domain/land/exception/LandNotFoundException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package in.koreatech.koin.domain.land.exception; | ||
|
||
public class LandNotFoundException extends RuntimeException { | ||
private static final String DEFAULT_MESSAGE = "복덕방이 존재하지 않습니다."; | ||
|
||
public LandNotFoundException(String message) { | ||
super(message); | ||
} | ||
|
||
public static LandNotFoundException withDetail(String detail) { | ||
String message = String.format("%s %s", DEFAULT_MESSAGE, detail); | ||
return new LandNotFoundException(message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
package in.koreatech.koin.domain.land.service; | ||
|
||
import java.net.URLEncoder; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.List; | ||
|
||
import org.json.JSONArray; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import in.koreatech.koin.domain.land.dto.LandListItemResponse; | ||
import in.koreatech.koin.domain.land.dto.LandResponse; | ||
import in.koreatech.koin.domain.land.exception.LandNotFoundException; | ||
import in.koreatech.koin.domain.land.model.Land; | ||
import in.koreatech.koin.domain.land.repository.LandRepository; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
|
@@ -22,4 +28,22 @@ public List<LandListItemResponse> getLands() { | |
.map(LandListItemResponse::from) | ||
.toList(); | ||
} | ||
|
||
public LandResponse getLand(Long id) { | ||
Land land = landRepository.findById(id) | ||
.orElseThrow(() -> LandNotFoundException.withDetail("id: " + id)); | ||
|
||
String image = land.getImageUrls(); | ||
List<String> imageUrls = null; | ||
|
||
if (image != null) { | ||
imageUrls = new JSONArray(image) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. JSONArray는 처음보는데 이런 것도 있었네요 👍 |
||
.toList() | ||
.stream() | ||
.map(Object::toString) | ||
.toList(); | ||
} | ||
|
||
return LandResponse.of(land, imageUrls, URLEncoder.encode(land.getInternalName(), StandardCharsets.UTF_8)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
R
여기 사이에 comments가 빠져있습니다!
참고)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
기존 코인을 찾아봤을 때 comments와 관련된 api를 사용하고 있지 않았고,
프론트쪽에 물어보니 comments를 사용하지 않는다는 답변을 받았습니다!