Skip to content

Commit

Permalink
Merge pull request #246 from Juinjang/dev
Browse files Browse the repository at this point in the history
[deploy] dev > prod 변경사항 반영
  • Loading branch information
PicturePark1101 authored Oct 15, 2024
2 parents f7708b9 + a485903 commit e676198
Show file tree
Hide file tree
Showing 23 changed files with 262 additions and 244 deletions.
29 changes: 14 additions & 15 deletions src/main/java/umc/th/juinjang/controller/LimjangController.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@
import umc.th.juinjang.model.dto.limjang.request.LimjangPatchRequest;
import umc.th.juinjang.model.dto.limjang.request.LimjangPostRequest;
import umc.th.juinjang.model.dto.limjang.request.LimjangsDeleteRequest;
import umc.th.juinjang.model.dto.limjang.response.LimjangDetailResponseDTO;
import umc.th.juinjang.model.dto.limjang.response.LimjangDetailGetResponse;
import umc.th.juinjang.model.dto.limjang.response.LimjangPostResponse;
import umc.th.juinjang.model.dto.limjang.response.LimjangTotalListResponseDTO;
import umc.th.juinjang.model.dto.limjang.response.LimjangsGetByKeywordResponse;
import umc.th.juinjang.model.dto.limjang.response.LimjangsGetResponse;
import umc.th.juinjang.model.dto.limjang.response.LimjangsMainGetResponse;
import umc.th.juinjang.model.dto.limjang.response.LimjangsMainGetVersion2Response;
import umc.th.juinjang.model.entity.Member;
import umc.th.juinjang.service.LimjangService.LimjangCommandService;
import umc.th.juinjang.service.LimjangService.LimjangQueryService;
Expand Down Expand Up @@ -57,12 +58,17 @@ public ApiResponse<LimjangsGetResponse> getLimjangTotalList(@AuthenticationPrinc
@CrossOrigin
@Operation(summary = "임장 메인화면에서 최근 임장 조회 API", description = "가장 최근에 수정된 순으로 최대 5개까지 볼 수 있다.")
@GetMapping("/main")
public ApiResponse<LimjangsMainGetResponse> getRecentUpdateList(
@AuthenticationPrincipal Member member
){
public ApiResponse<LimjangsMainGetResponse> getRecentUpdateList(@AuthenticationPrincipal Member member) {
return ApiResponse.onSuccess((limjangQueryService.getLimjangsMain(member)));
}

@CrossOrigin
@Operation(summary = "임장 메인화면에서 최근 임장 조회 API version 2", description = "가장 최근에 수정된 순으로 최대 5개까지 볼 수 있다.")
@GetMapping("/v2/main")
public ApiResponse<LimjangsMainGetVersion2Response> getRecentUpdateListVersion2(@AuthenticationPrincipal Member member) {
return ApiResponse.onSuccess((limjangQueryService.getLimjangsMainVersion2(member)));
}

@CrossOrigin
@Operation(summary = "임장 선택 삭제", description = "임장 게시글을 여러 개 선택해서 삭제하는 api입니다.")
@DeleteMapping
Expand All @@ -74,22 +80,15 @@ public ApiResponse deleteLimjang(@RequestBody @Valid LimjangsDeleteRequest delet
@CrossOrigin
@Operation(summary = "임장 검색", description = "임장 게시글을 검색하는 api입니다. 집별명, 일반주소, 상세주소로 검색이 가능합니다.")
@GetMapping("/{keyword}")
public ApiResponse<LimjangTotalListResponseDTO.TotalListDto> searchLimjangs(
@AuthenticationPrincipal Member member,
@PathVariable(name = "keyword") @Valid String keyword
) {

public ApiResponse<LimjangsGetByKeywordResponse> searchLimjangs(@AuthenticationPrincipal Member member, @PathVariable(name = "keyword") String keyword) {
return ApiResponse.onSuccess(limjangQueryService.getLimjangSearchList(member, keyword));
}

@CrossOrigin
@Operation(summary = "임장 상세보기", description = "임장 상세보기 api입니다. 임장 id를 전달해주세요.")
@GetMapping("/detail/{limjangId}")
public ApiResponse<LimjangDetailResponseDTO.DetailDto> getDetailLimjang(
@PathVariable(name = "limjangId") @Valid Long limjangId,
@AuthenticationPrincipal Member member
) {
return ApiResponse.onSuccess(limjangQueryService.getLimjangDetail(limjangId));
public ApiResponse<LimjangDetailGetResponse> getLimjang(@PathVariable(name = "limjangId") @Valid Long id, @AuthenticationPrincipal Member member) {
return ApiResponse.onSuccess(limjangQueryService.getDetail(id, member));
}

@CrossOrigin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.util.Comparator;
import java.util.List;
import umc.th.juinjang.model.dto.limjang.response.LimjangDetailResponseDTO;
import umc.th.juinjang.model.dto.limjang.enums.LimjangCheckListVersionEnum;
import umc.th.juinjang.model.entity.enums.LimjangCheckListVersion;
import umc.th.juinjang.model.entity.Image;
import umc.th.juinjang.model.entity.Limjang;
import umc.th.juinjang.model.entity.LimjangPrice;
Expand All @@ -28,14 +28,14 @@ public static LimjangDetailResponseDTO.DetailDto toDetail(
LimjangPropertyType propertyType = limjang.getPropertyType();
LimjangPriceType priceType = limjang.getPriceType();

LimjangCheckListVersionEnum checkListVersion;
LimjangCheckListVersion checkListVersion;
if (purposeType == LimjangPurpose.RESIDENTIAL_PURPOSE &&
(propertyType == LimjangPropertyType.VILLA||
propertyType == LimjangPropertyType.OFFICE_TEL)
){
checkListVersion = LimjangCheckListVersionEnum.NON_LIMJANG;
checkListVersion = LimjangCheckListVersion.NON_LIMJANG;
} else {
checkListVersion = LimjangCheckListVersionEnum.LIMJANG;
checkListVersion = LimjangCheckListVersion.LIMJANG;
}

List<String> priceList = makePriceListVersion2(priceType, purposeType,limjangPrice);
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package umc.th.juinjang.converter.limjang;

import static umc.th.juinjang.service.LimjangService.LimjangPriceBridge.makePriceListVersion2;
import static umc.th.juinjang.service.LimjangService.LimjangPriceBridge.getPriceToString;

import java.util.List;
import java.util.Optional;
import umc.th.juinjang.model.dto.limjang.response.LimjangsMainGetResponse.LimjangMainResponse;
import umc.th.juinjang.model.entity.Image;
Expand All @@ -20,11 +19,6 @@ public static LimjangMainResponse toLimjangMainResponse(final Limjang limjang) {
limjang.getAddress());
}

private static String getPriceToString(final Limjang limjang) {
List<String> priceList = makePriceListVersion2(limjang.getPriceType(),limjang.getPurpose(), limjang.getLimjangPrice());
return (limjang.getPriceType().getValue() == 2) ? priceList.get(1) : priceList.get(0);
}

private static String getTotalAverageOrElse(final Limjang limjang) {
return Optional.ofNullable(limjang.getReport()).map(Report::getTotalRate).map(Object::toString).orElse(null);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package umc.th.juinjang.model.dto.limjang.response;

import static umc.th.juinjang.service.LimjangService.LimjangPriceBridge.makePriceListVersion2;

import java.time.LocalDateTime;
import java.util.List;
import lombok.Builder;
import umc.th.juinjang.model.entity.Image;
import umc.th.juinjang.model.entity.enums.LimjangCheckListVersion;
import umc.th.juinjang.model.entity.Limjang;

@Builder
public record LimjangDetailGetResponse(
long limjangId,
LimjangCheckListVersion checkListVersion,
List<String> images,
int purposeCode,
String nickname,
int priceType,
List<String> priceList,
String address,
String addressDetail,
LocalDateTime createdAt,
LocalDateTime updatedAt
) {
public static LimjangDetailGetResponse of(Limjang limjang){
return LimjangDetailGetResponse.builder()
.limjangId(limjang.getLimjangId())
.checkListVersion(LimjangCheckListVersion.getByLimjangType(limjang))
.images(limjang.getImageList().stream().map(Image::getImageUrl).toList())
.purposeCode(limjang.getPurpose().getValue())
.nickname(limjang.getNickname())
.priceType(limjang.getPriceType().getValue())
.priceList(makePriceListVersion2(limjang.getPriceType(), limjang.getPurpose(), limjang.getLimjangPrice()))
.address(limjang.getAddress())
.addressDetail(limjang.getAddressDetail())
.createdAt(limjang.getCreatedAt())
.updatedAt(limjang.getUpdatedAt())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import umc.th.juinjang.model.dto.limjang.enums.LimjangCheckListVersionEnum;
import umc.th.juinjang.model.entity.enums.LimjangCheckListVersion;

public class LimjangDetailResponseDTO {

Expand All @@ -16,7 +16,7 @@ public class LimjangDetailResponseDTO {
@AllArgsConstructor
public static class DetailDto {
private Long limjangId;
private LimjangCheckListVersionEnum checkListVersion;
private LimjangCheckListVersion checkListVersion;
private List<String> images;
private Integer purposeCode;
private String nickname;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package umc.th.juinjang.model.dto.limjang.response;

import static umc.th.juinjang.service.LimjangService.LimjangPriceBridge.makePriceListVersion2;

import java.util.List;
import java.util.Map;
import umc.th.juinjang.model.entity.Image;
import umc.th.juinjang.model.entity.Limjang;

public record LimjangsGetByKeywordResponse(List<LimjangByKeywordResponse> limjangList) {
record LimjangByKeywordResponse(
long limjangId,
List<String> images,
int purposeCode,
boolean isScraped,
String nickname,
int priceType,
List<String> priceList,
String totalAverage,
String address
) {
static LimjangByKeywordResponse of(Limjang limjang, boolean isScraped) {
return new LimjangByKeywordResponse(
limjang.getLimjangId(),
limjang.getImageList().stream().map(Image::getImageUrl).toList(),
limjang.getPurpose().getValue(),
isScraped,
limjang.getNickname(),
limjang.getPriceType().getValue(),
makePriceListVersion2(limjang.getPriceType(), limjang.getPurpose(), limjang.getLimjangPrice()),
limjang.getReport() == null ? null : limjang.getReport().getTotalRate().toString(),
limjang.getAddress()
);
}
}

public static LimjangsGetByKeywordResponse of(List<Limjang> limjangList, Map<Long, Boolean> mapLimjangToScrapStatus) {
return new LimjangsGetByKeywordResponse(limjangList.stream().map(it -> LimjangByKeywordResponse.of(it, mapLimjangToScrapStatus.get(it.getLimjangId()))).toList());
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package umc.th.juinjang.model.dto.limjang.response;

import static umc.th.juinjang.service.LimjangService.LimjangPriceBridge.makePriceListVersion2;

import java.util.Comparator;
import java.util.List;
import java.util.Map;
import lombok.Builder;
import umc.th.juinjang.converter.limjang.LimjangsGetResponseConverter;
import umc.th.juinjang.model.entity.Image;
import umc.th.juinjang.model.entity.Limjang;
import umc.th.juinjang.model.entity.LimjangPrice;

public record LimjangsGetResponse(
List<LimjangsResponse> limjangList
) {
public record LimjangsGetResponse(List<LimjangsResponse> limjangList) {
@Builder
public record LimjangsResponse(
record LimjangsResponse(
long limjangId,
List<String> images,
int purposeCode,
Expand All @@ -20,12 +22,26 @@ public record LimjangsResponse(
List<String> priceList,
String totalAverage,
String address) {
public static LimjangsResponse of(Limjang limjang, LimjangPrice limjangPrice) {
return LimjangsGetResponseConverter.convertToLimjangsResponse(limjang, limjangPrice);
static LimjangsResponse of(Limjang limjang, LimjangPrice limjangPrice, boolean isScraped) {
return LimjangsResponse.builder()
.limjangId(limjang.getLimjangId())
.images(getUrlListByScrap(limjang, isScraped))
.nickname(limjang.getNickname())
.isScraped(isScraped)
.purposeCode(limjang.getPurpose().getValue())
.priceType(limjang.getPriceType().getValue())
.priceList(makePriceListVersion2(limjang.getPriceType(), limjang.getPurpose(), limjangPrice))
.totalAverage(limjang.getReport() == null ? null : limjang.getReport().getTotalRate().toString())
.address(limjang.getAddress())
.build();
}
}

public static LimjangsGetResponse of(final List<Limjang> limjangList) {
return new LimjangsGetResponse(limjangList.stream().map(limjang -> LimjangsResponse.of(limjang, limjang.getLimjangPrice())).toList());
public static LimjangsGetResponse of(List<Limjang> limjangList, Map<Long, Boolean> mapLimjangToScrapStatus) {
return new LimjangsGetResponse(limjangList.stream().map(limjang -> LimjangsResponse.of(limjang, limjang.getLimjangPrice(), mapLimjangToScrapStatus.get(limjang.getLimjangId()))).toList());
}

private static List<String> getUrlListByScrap(Limjang limjang, boolean isScraped) {
return limjang.getImageList().stream().map(Image::getImageUrl).limit(!isScraped ? 1 : 3).toList();
}
}
Loading

0 comments on commit e676198

Please sign in to comment.