Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/PawWithU/ConnectDog-Server
Browse files Browse the repository at this point in the history
… into feat/181-mypage-main-api
  • Loading branch information
hojeong2747 committed May 5, 2024
2 parents 26fea1a + 1120585 commit c10354a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@

import java.time.LocalDate;

public record PostGetHomeResponse(Long postId, String mainImage, String departureLoc, String arrivalLoc,
public record PostGetHomeResponse(Long postId, String mainImage, String dogName, String departureLoc, String arrivalLoc,
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "Asia/Seoul")
LocalDate startDate,
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "Asia/Seoul")
LocalDate endDate,
String intermediaryName,
Boolean isKennel) {
String pickUpTime) {
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
package com.pawwithu.connectdog.domain.post.dto.response;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.pawwithu.connectdog.domain.dog.entity.DogSize;

import java.time.LocalDate;

public record PostSearchResponse(Long postId, String mainImage, String departureLoc, String arrivalLoc,
public record PostSearchResponse(Long postId, String mainImage, String dogName, String departureLoc, String arrivalLoc,
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "Asia/Seoul")
LocalDate startDate,
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "Asia/Seoul")
LocalDate endDate,
String intermediaryName,
String pickUpTime,
String dogSize,
Boolean isKennel) {

public PostSearchResponse(Long postId, String mainImage, String dogName, String departureLoc, String arrivalLoc,
LocalDate startDate, LocalDate endDate, String pickUpTime,
DogSize dogSize, Boolean isKennel) {
this(postId, mainImage, dogName, departureLoc, arrivalLoc, startDate, endDate, pickUpTime,
dogSize.getKey(), isKennel);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ public class CustomPostRepositoryImpl implements CustomPostRepository {
public List<PostGetHomeResponse> getHomePosts() {
return queryFactory
.select(Projections.constructor(PostGetHomeResponse.class,
post.id, postImage.image, post.departureLoc, post.arrivalLoc, post.startDate, post.endDate,
intermediary.name, post.isKennel))
post.id, postImage.image, dog.name, post.departureLoc, post.arrivalLoc,
post.startDate, post.endDate, post.pickUpTime))
.from(post)
.join(post.intermediary, intermediary)
.join(post.mainImage, postImage)
.join(post.dog, dog)
.where(post.status.eq(PostStatus.RECRUITING))
.orderBy(post.createdDate.desc())
.limit(5)
Expand All @@ -56,10 +56,10 @@ public List<PostSearchResponse> searchPosts(PostSearchRequest request, Pageable

return queryFactory
.select(Projections.constructor(PostSearchResponse.class,
post.id, postImage.image, post.departureLoc, post.arrivalLoc, post.startDate, post.endDate,
intermediary.name, post.isKennel))
post.id, postImage.image, dog.name, post.departureLoc, post.arrivalLoc,
post.startDate, post.endDate, post.pickUpTime, dog.size, post.isKennel))
.from(post)
.join(post.intermediary, intermediary)
.join(post.dog, dog)
.join(post.mainImage, postImage)
.where(allFilterSearch(request, pageable))
.orderBy(createOrderSpecifierEC(request.orderCondition()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ void setUp() {
List<PostGetHomeResponse> response = new ArrayList<>();
LocalDate startDate = LocalDate.of(2023, 10, 2);
LocalDate endDate = LocalDate.of(2023, 11, 7);
response.add(new PostGetHomeResponse(1L, "image1", "서울시 성북구", "서울시 중랑구",
startDate, endDate, "이동봉사 중개", true));
response.add(new PostGetHomeResponse(2L, "image2", "서울시 성북구", "서울시 중랑구",
startDate, endDate, "이동봉사 중개", false));
response.add(new PostGetHomeResponse(1L, "image1", "하늘이", "서울시 성북구", "서울시 중랑구",
startDate, endDate, "13:00"));
response.add(new PostGetHomeResponse(2L, "image2", "초코", "서울시 성북구", "서울시 중랑구",
startDate, endDate, "13:00"));

//when
given(postService.getHomePosts()).willReturn(response);
Expand All @@ -114,10 +114,10 @@ void setUp() {
List<PostSearchResponse> response = new ArrayList<>();
LocalDate startDate = LocalDate.of(2023, 10, 2);
LocalDate endDate = LocalDate.of(2023, 11, 7);
response.add(new PostSearchResponse(1L, "image1", "서울시 성북구", "서울시 중랑구",
startDate, endDate, "이동봉사 중개", true));
response.add(new PostSearchResponse(2L, "image2", "서울시 성북구", "서울시 중랑구",
startDate, endDate, "이동봉사 중개", false));
response.add(new PostSearchResponse(1L, "image1", "하늘이", "서울시 성북구", "서울시 중랑구",
startDate, endDate, "13:00", DogSize.MEDIUM, true));
response.add(new PostSearchResponse(2L, "image2", "하늘이", "서울시 성북구", "서울시 중랑구",
startDate, endDate, "12:00", DogSize.SMALL, false));


//when
Expand Down

0 comments on commit c10354a

Please sign in to comment.