-
Notifications
You must be signed in to change notification settings - Fork 3
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 #39 from AlongTheBlue/develop
[Feat] CustomPage 사용해서 category 정보 추가
- Loading branch information
Showing
9 changed files
with
113 additions
and
5 deletions.
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
18 changes: 18 additions & 0 deletions
18
src/main/java/org/alongtheblue/alongtheblue_server/global/config/JacksonConfig.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,18 @@ | ||
package org.alongtheblue.alongtheblue_server.global.config; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.alongtheblue.alongtheblue_server.global.data.global.CustomPage; | ||
import org.alongtheblue.alongtheblue_server.global.data.global.CustomPageMixIn; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class JacksonConfig { | ||
@Bean | ||
public ObjectMapper objectMapper() { | ||
ObjectMapper mapper = new ObjectMapper(); | ||
// MixIn 등록 | ||
mapper.addMixIn(CustomPage.class, CustomPageMixIn.class); | ||
return mapper; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/org/alongtheblue/alongtheblue_server/global/data/global/Category.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,19 @@ | ||
package org.alongtheblue.alongtheblue_server.global.data.global; | ||
|
||
public enum Category { | ||
RESTAURANT("restaurant"), | ||
CAFE("cafe"), | ||
ACCOMMODATION("accommodation"), | ||
TOURDATA("tourData"); | ||
|
||
private final String value; | ||
|
||
Category(String value) { | ||
this.value = value; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/org/alongtheblue/alongtheblue_server/global/data/global/CustomPage.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,30 @@ | ||
package org.alongtheblue.alongtheblue_server.global.data.global; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import org.springframework.data.domain.PageImpl; | ||
import org.springframework.data.domain.Pageable; | ||
|
||
import java.util.List; | ||
|
||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class CustomPage<T> extends PageImpl<T> { | ||
@JsonProperty("category") | ||
private String category; | ||
|
||
public CustomPage() { | ||
super(List.of()); | ||
} | ||
public CustomPage(List<T> content, Pageable pageable, long total, String category) { | ||
super(content, pageable, total); | ||
this.category = category; | ||
} | ||
|
||
public String getCategory() { | ||
return category; | ||
} | ||
|
||
public void setCategory(String category) { | ||
this.category = category; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/org/alongtheblue/alongtheblue_server/global/data/global/CustomPageMixIn.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,16 @@ | ||
package org.alongtheblue.alongtheblue_server.global.data.global; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import org.springframework.data.domain.PageImpl; | ||
import org.springframework.data.domain.Pageable; | ||
|
||
import java.util.List; | ||
|
||
public abstract class CustomPageMixIn<T> extends PageImpl<T> { | ||
@JsonProperty("category") | ||
private String category; | ||
|
||
public CustomPageMixIn(List<T> content, Pageable pageable, long total) { | ||
super(content, pageable, total); | ||
} | ||
} |
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
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