-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from PawWithU/feat/42-posts-filter-search-api
[Feature] 이동봉사 공고 필터 검색 API 구현
- Loading branch information
Showing
11 changed files
with
223 additions
and
3 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
src/main/java/com/pawwithu/connectdog/common/converter/DogSizeConverter.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,13 @@ | ||
package com.pawwithu.connectdog.common.converter; | ||
|
||
import com.pawwithu.connectdog.domain.dog.entity.DogSize; | ||
import org.springframework.core.convert.converter.Converter; | ||
import org.springframework.util.StringUtils; | ||
|
||
public class DogSizeConverter implements Converter<String, DogSize> { | ||
@Override | ||
public DogSize convert(String source) { | ||
if (!StringUtils.hasText(source)) return null; | ||
return DogSize.create(source); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/pawwithu/connectdog/common/converter/PostStatusConverter.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 com.pawwithu.connectdog.common.converter; | ||
|
||
import com.pawwithu.connectdog.domain.post.entity.PostStatus; | ||
import org.springframework.core.convert.converter.Converter; | ||
import org.springframework.util.StringUtils; | ||
|
||
public class PostStatusConverter implements Converter<String, PostStatus> { | ||
@Override | ||
public PostStatus convert(String source) { | ||
if (!StringUtils.hasText(source)) return null; | ||
return PostStatus.create(source); | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/pawwithu/connectdog/config/WebConfig.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,17 @@ | ||
package com.pawwithu.connectdog.config; | ||
|
||
import com.pawwithu.connectdog.common.converter.DogSizeConverter; | ||
import com.pawwithu.connectdog.common.converter.PostStatusConverter; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.format.FormatterRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
||
@Configuration | ||
public class WebConfig implements WebMvcConfigurer { | ||
|
||
@Override | ||
public void addFormatters(FormatterRegistry registry) { | ||
registry.addConverter(new DogSizeConverter()); | ||
registry.addConverter(new PostStatusConverter()); | ||
} | ||
} |
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
21 changes: 21 additions & 0 deletions
21
src/main/java/com/pawwithu/connectdog/domain/post/dto/request/PostSearchRequest.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,21 @@ | ||
package com.pawwithu.connectdog.domain.post.dto.request; | ||
|
||
import com.pawwithu.connectdog.domain.dog.entity.DogSize; | ||
import com.pawwithu.connectdog.domain.post.entity.PostStatus; | ||
import org.springframework.format.annotation.DateTimeFormat; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
|
||
import java.time.LocalDate; | ||
|
||
public record PostSearchRequest(@RequestParam(value = "postStatus", required = false) PostStatus postStatus, | ||
String departureLoc, | ||
String arrivalLoc, | ||
@DateTimeFormat(pattern = "yyyy-MM-dd") | ||
LocalDate startDate, | ||
@DateTimeFormat(pattern = "yyyy-MM-dd") | ||
LocalDate endDate, | ||
@RequestParam(value = "dogSize", required = false) DogSize dogSize, | ||
Boolean isKennel, | ||
String intermediaryName) { | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/pawwithu/connectdog/domain/post/dto/response/PostSearchResponse.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 com.pawwithu.connectdog.domain.post.dto.response; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
|
||
import java.time.LocalDate; | ||
|
||
public record PostSearchResponse(String mainImage, 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) { | ||
} |
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
4 changes: 4 additions & 0 deletions
4
src/main/java/com/pawwithu/connectdog/domain/post/repository/CustomPostRepository.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 |
---|---|---|
@@ -1,10 +1,14 @@ | ||
package com.pawwithu.connectdog.domain.post.repository; | ||
|
||
import com.pawwithu.connectdog.domain.post.dto.request.PostSearchRequest; | ||
import com.pawwithu.connectdog.domain.post.dto.response.PostGetHomeResponse; | ||
import com.pawwithu.connectdog.domain.post.dto.response.PostSearchResponse; | ||
import org.springframework.data.domain.Pageable; | ||
|
||
import java.util.List; | ||
|
||
public interface CustomPostRepository { | ||
|
||
List<PostGetHomeResponse> getHomePosts(); | ||
List<PostSearchResponse> searchPosts(PostSearchRequest request, Pageable pageable); | ||
} |
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