Skip to content

Commit e7a8f9d

Browse files
author
nimuy99
committed
#131 Fix: 차트데이터 호출 관련 api response 자료형 수정
1 parent f7671ba commit e7a8f9d

File tree

10 files changed

+113
-81
lines changed

10 files changed

+113
-81
lines changed

src/main/java/com/memesphere/domain/collection/converter/CollectionConverter.java

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.springframework.data.domain.Page;
1313

1414
import java.math.BigDecimal;
15+
import java.math.RoundingMode;
1516
import java.util.List;
1617
import java.util.stream.Collectors;
1718

@@ -56,11 +57,21 @@ private static CollectionGridPreviewResponse toCollectionGridPreviewDTO(Collecti
5657
.name(memeCoin.getName())
5758
.symbol(memeCoin.getSymbol())
5859
.image(memeCoin.getImage())
59-
.currentPrice(chartData.getPrice())
60-
.highPrice(chartData.getHigh_price())
61-
.lowPrice(chartData.getLow_price())
62-
.priceChange(chartData.getPriceChange())
63-
.priceChangeRate(chartData.getPriceChangeRate())
60+
.currentPrice(BigDecimal.valueOf(chartData.getPrice())
61+
.setScale(8, RoundingMode.HALF_UP)
62+
.toPlainString())
63+
.highPrice(BigDecimal.valueOf(chartData.getHigh_price())
64+
.setScale(8, RoundingMode.HALF_UP)
65+
.toPlainString())
66+
.lowPrice(BigDecimal.valueOf(chartData.getLow_price())
67+
.setScale(8, RoundingMode.HALF_UP)
68+
.toPlainString())
69+
.priceChange(BigDecimal.valueOf(chartData.getPriceChange())
70+
.setScale(8, RoundingMode.HALF_UP)
71+
.toPlainString())
72+
.priceChangeRate(BigDecimal.valueOf(chartData.getPriceChangeRate())
73+
.setScale(8, RoundingMode.HALF_UP)
74+
.toPlainString())
6475
.build();
6576
}
6677

@@ -72,9 +83,15 @@ public static CollectionListPreviewResponse toCollectionListPreviewDTO(Collectio
7283
.coinId(memeCoin.getId())
7384
.name(memeCoin.getName())
7485
.symbol(memeCoin.getSymbol())
75-
.currentPrice(chartData.getPrice())
76-
.priceChangeRate(chartData.getPriceChangeRate())
77-
.weightedAveragePrice(chartData.getWeighted_average_price())
86+
.currentPrice(BigDecimal.valueOf(chartData.getPrice())
87+
.setScale(8, RoundingMode.HALF_UP)
88+
.toPlainString())
89+
.priceChangeRate(BigDecimal.valueOf(chartData.getPriceChangeRate())
90+
.setScale(8, RoundingMode.HALF_UP)
91+
.toPlainString())
92+
.weightedAveragePrice(BigDecimal.valueOf(chartData.getWeighted_average_price())
93+
.setScale(8, RoundingMode.HALF_UP)
94+
.toPlainString())
7895
.volume(chartData.getVolume())
7996
.build();
8097
}

src/main/java/com/memesphere/domain/collection/dto/response/CollectionGridPreviewResponse.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,17 @@ public class CollectionGridPreviewResponse {
2727
String image;
2828

2929
@Schema(description = "차트 데이터의 price", example = "2000")
30-
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.00000000")
31-
Double currentPrice;
30+
String currentPrice;
3231

3332
@Schema(description = "차트 데이터의 high_price", example = "2500")
34-
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.00000000")
35-
Double highPrice;
33+
String highPrice;
3634

3735
@Schema(description = "차트 데이터의 low_price", example = "1500")
38-
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.00000000")
39-
Double lowPrice;
36+
String lowPrice;
4037

4138
@Schema(description = "차트 데이터의 price_change", example = "500")
42-
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.00000000")
43-
Double priceChange;
39+
String priceChange;
4440

4541
@Schema(description = "차트 데이터의 price_change_rate", example = "2.4")
46-
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.00000000")
47-
Double priceChangeRate;
42+
String priceChangeRate;
4843
}

src/main/java/com/memesphere/domain/collection/dto/response/CollectionListPreviewResponse.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,13 @@ public class CollectionListPreviewResponse {
2424
String symbol;
2525

2626
@Schema(description = "차트 데이터의 price", example = "2000")
27-
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.00000000")
28-
Double currentPrice;
27+
String currentPrice;
2928

3029
@Schema(description = "차트 데이터의 price_change_rate", example = "+2.4%")
31-
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.00000000")
32-
Double priceChangeRate;
30+
String priceChangeRate;
3331

3432
@Schema(description = "차트 데이터의 weighted average price", example = "10000")
35-
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.00000000")
36-
Double weightedAveragePrice; // market cap 대신 사용
33+
String weightedAveragePrice; // market cap 대신 사용
3734

3835
@Schema(description = "차트 데이터의 volume", example = "5")
3936
BigDecimal volume;

src/main/java/com/memesphere/domain/dashboard/converter/DashboardConverter.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99

1010
import java.math.BigDecimal;
11+
import java.math.RoundingMode;
1112
import java.time.LocalDateTime;
1213
import java.util.ArrayList;
1314
import java.util.List;
@@ -68,11 +69,19 @@ public static DashboardTrendResponse toTrend(ChartData data,
6869
.name(memeCoin.getName())
6970
.symbol(memeCoin.getSymbol())
7071
.volume(data.getVolume())
71-
.price(data.getPrice())
72-
.priceChange(data.getPriceChange())
73-
.priceChangeAbsolute(Math.abs(data.getPriceChange()))
72+
.price(BigDecimal.valueOf(data.getPrice())
73+
.setScale(8, RoundingMode.HALF_UP)
74+
.toPlainString())
75+
.priceChange(BigDecimal.valueOf(data.getPriceChange())
76+
.setScale(8, RoundingMode.HALF_UP)
77+
.toPlainString())
78+
.priceChangeAbsolute(BigDecimal.valueOf(Math.abs(data.getPriceChange()))
79+
.setScale(8, RoundingMode.HALF_UP)
80+
.toPlainString())
7481
.priceChangeDirection(data.getPriceChangeRate() < 0 ? "down" : "up")
75-
.priceChangeRate(data.getPriceChangeRate())
82+
.priceChangeRate(BigDecimal.valueOf(data.getPriceChangeRate())
83+
.setScale(8, RoundingMode.HALF_UP)
84+
.toPlainString())
7685
.rankChangeDirection(rankDirection)
7786
.build();
7887
}

src/main/java/com/memesphere/domain/dashboard/dto/response/DashboardTrendResponse.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,19 @@ public class DashboardTrendResponse {
2626
private BigDecimal volume;
2727

2828
@Schema(description = "현재가", example = "0.20")
29-
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.00000000")
30-
private Double price;
29+
private String price;
3130

3231
@Schema(description = "가격 변화량", example = "-0.03")
33-
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.00000000")
34-
private Double priceChange;
32+
private String priceChange;
3533

3634
@Schema(description = "가격 변화량 절대값", example = "0.03")
37-
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.00000000")
38-
private Double priceChangeAbsolute;
35+
private String priceChangeAbsolute;
3936

4037
@Schema(description = "가격 변화 방향", example = "down")
4138
private String priceChangeDirection;
4239

4340
@Schema(description = "가격 변화율", example = "-6.35")
44-
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.00000000")
45-
private Double priceChangeRate;
41+
private String priceChangeRate;
4642

4743
@Schema(description = "순위 변화 방향", example = "down")
4844
private String rankChangeDirection;

src/main/java/com/memesphere/domain/detail/converter/DetailConverter.java

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.memesphere.domain.detail.dto.response.DetailGetResponse;
77

88
import java.math.BigDecimal;
9+
import java.math.RoundingMode;
910

1011
public class DetailConverter {
1112

@@ -26,14 +27,28 @@ public static DetailGetResponse toDetailGetResponse(MemeCoin memeCoin) {
2627
public static PriceInfoResponse toPriceInfoResponse(MemeCoin memeCoin, ChartData data) {
2728
return PriceInfoResponse.builder()
2829
.coinId(memeCoin.getId())
29-
.price(data.getPrice())
30-
.priceChange(data.getPriceChange())
31-
.priceChangeAbsolute(Math.abs(data.getPriceChange()))
30+
.price(BigDecimal.valueOf(data.getPrice())
31+
.setScale(8, RoundingMode.HALF_UP)
32+
.toPlainString())
33+
.priceChange(BigDecimal.valueOf(data.getPriceChange())
34+
.setScale(8, RoundingMode.HALF_UP)
35+
.toPlainString())
36+
.priceChangeAbsolute(BigDecimal.valueOf(Math.abs(data.getPriceChange()))
37+
.setScale(8, RoundingMode.HALF_UP)
38+
.toPlainString())
3239
.priceChangeDirection(data.getPriceChangeRate() < 0 ? "down" : "up")
33-
.priceChangeRate(data.getPriceChangeRate())
34-
.weightedAveragePrice(data.getWeighted_average_price())
35-
.highPrice(data.getHigh_price())
36-
.lowPrice(data.getLow_price())
40+
.priceChangeRate(BigDecimal.valueOf(data.getPriceChangeRate())
41+
.setScale(8, RoundingMode.HALF_UP)
42+
.toPlainString())
43+
.weightedAveragePrice(BigDecimal.valueOf(data.getWeighted_average_price())
44+
.setScale(8, RoundingMode.HALF_UP)
45+
.toPlainString())
46+
.highPrice(BigDecimal.valueOf(data.getHigh_price())
47+
.setScale(8, RoundingMode.HALF_UP)
48+
.toPlainString())
49+
.lowPrice(BigDecimal.valueOf(data.getLow_price())
50+
.setScale(8, RoundingMode.HALF_UP)
51+
.toPlainString())
3752
.build();
3853
}
3954
}

src/main/java/com/memesphere/domain/detail/dto/response/PriceInfoResponse.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,26 @@ public class PriceInfoResponse {
1414
private Long coinId;
1515

1616
@Schema(description = "현재가", example = "0.20")
17-
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.00000000")
18-
private Double price;
17+
private String price;
1918

2019
@Schema(description = "가격 변화량", example = "-0.03")
21-
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.00000000")
22-
private Double priceChange;
20+
private String priceChange;
2321

2422
@Schema(description = "가격 변화량 절대값", example = "0.03")
25-
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.00000000")
26-
private Double priceChangeAbsolute;
23+
private String priceChangeAbsolute;
2724

2825
@Schema(description = "가격 변화 방향", example = "down")
2926
private String priceChangeDirection;
3027

3128
@Schema(description = "가격 변화율", example = "-6.35")
32-
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.00000000")
33-
private Double priceChangeRate;
29+
private String priceChangeRate;
3430

3531
@Schema(description = "거래량 가중 평균 가격", example = "-942.38")
36-
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.00000000")
37-
private Double weightedAveragePrice;
32+
private String weightedAveragePrice;
3833

3934
@Schema(description = "24h 최고가", example = "2500")
40-
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.00000000")
41-
private Double highPrice;
35+
private String highPrice;
4236

4337
@Schema(description = "24h 최저가", example = "1500")
44-
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.00000000")
45-
private Double lowPrice;
38+
private String lowPrice;
4639
}

src/main/java/com/memesphere/domain/search/converter/SearchConverter.java

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import com.memesphere.domain.search.dto.response.SearchPageResponse;
99
import org.springframework.data.domain.Page;
1010

11+
import java.math.BigDecimal;
12+
import java.math.RoundingMode;
1113
import java.util.List;
1214
import java.util.stream.Collectors;
1315

@@ -45,11 +47,21 @@ public static SearchGridPreviewResponse toSearchGridPreviewDTO(MemeCoin memeCoin
4547
.name(memeCoin.getName())
4648
.symbol(memeCoin.getSymbol())
4749
.image(memeCoin.getImage())
48-
.currentPrice(chartData.getPrice())
49-
.highPrice(chartData.getHigh_price())
50-
.lowPrice(chartData.getLow_price())
51-
.priceChange(chartData.getPriceChange())
52-
.priceChangeRate(chartData.getPriceChangeRate())
50+
.currentPrice(BigDecimal.valueOf(chartData.getPrice())
51+
.setScale(8, RoundingMode.HALF_UP)
52+
.toPlainString())
53+
.highPrice(BigDecimal.valueOf(chartData.getHigh_price())
54+
.setScale(8, RoundingMode.HALF_UP)
55+
.toPlainString())
56+
.lowPrice(BigDecimal.valueOf(chartData.getLow_price())
57+
.setScale(8, RoundingMode.HALF_UP)
58+
.toPlainString())
59+
.priceChange(BigDecimal.valueOf(chartData.getPriceChange())
60+
.setScale(8, RoundingMode.HALF_UP)
61+
.toPlainString())
62+
.priceChangeRate(BigDecimal.valueOf(chartData.getPriceChangeRate())
63+
.setScale(8, RoundingMode.HALF_UP)
64+
.toPlainString())
5365
.isCollected(isCollected)
5466
.build();
5567
}
@@ -61,9 +73,15 @@ public static SearchListPreviewResponse toSearchListPreviewDTO(MemeCoin memeCoin
6173
.coinId(memeCoin.getId())
6274
.name(memeCoin.getName())
6375
.symbol(memeCoin.getSymbol())
64-
.currentPrice(chartData.getPrice())
65-
.priceChangeRate(chartData.getPriceChangeRate())
66-
.weightedAveragePrice(chartData.getWeighted_average_price())
76+
.currentPrice(BigDecimal.valueOf(chartData.getPrice())
77+
.setScale(8, RoundingMode.HALF_UP)
78+
.toPlainString())
79+
.priceChangeRate(BigDecimal.valueOf(chartData.getPriceChangeRate())
80+
.setScale(8, RoundingMode.HALF_UP)
81+
.toPlainString())
82+
.weightedAveragePrice(BigDecimal.valueOf(chartData.getWeighted_average_price())
83+
.setScale(8, RoundingMode.HALF_UP)
84+
.toPlainString())
6785
.volume(chartData.getVolume())
6886
.isCollected(isCollected)
6987
.build();

src/main/java/com/memesphere/domain/search/dto/response/SearchGridPreviewResponse.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,19 @@ public class SearchGridPreviewResponse {
2727
String image;
2828

2929
@Schema(description = "차트 데이터의 price", example = "2000")
30-
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.00000000")
31-
Double currentPrice;
30+
String currentPrice;
3231

3332
@Schema(description = "차트 데이터의 high_price", example = "2500")
34-
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.00000000")
35-
Double highPrice;
33+
String highPrice;
3634

3735
@Schema(description = "차트 데이터의 low_price", example = "1500")
38-
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.00000000")
39-
Double lowPrice;
36+
String lowPrice;
4037

4138
@Schema(description = "차트 데이터의 price_change", example = "500")
42-
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.00000000")
43-
Double priceChange;
39+
String priceChange;
4440

4541
@Schema(description = "차트 데이터의 price_change_rate", example = "+2.4%")
46-
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.00000000")
47-
Double priceChangeRate;
42+
String priceChangeRate;
4843

4944
@Schema(description = "collection에 해당 밈코인 유무", example = "true / false")
5045
Boolean isCollected;

src/main/java/com/memesphere/domain/search/dto/response/SearchListPreviewResponse.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,16 @@ public class SearchListPreviewResponse {
2424
String symbol;
2525

2626
@Schema(description = "차트 데이터의 price", example = "2000")
27-
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.00000000")
28-
Double currentPrice;
27+
String currentPrice;
2928

3029
@Schema(description = "차트 데이터의 weighted average price", example = "10000")
31-
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.00000000")
32-
Double weightedAveragePrice;
30+
String weightedAveragePrice;
3331

3432
@Schema(description = "차트 데이터의 volume", example = "5")
3533
BigDecimal volume;
3634

3735
@Schema(description = "차트 데이터의 price_change_rate", example = "+2.4%")
38-
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.00000000")
39-
Double priceChangeRate;
36+
String priceChangeRate;
4037

4138
@Schema(description = "collection에 해당 밈코인 유무", example = "true / false")
4239
Boolean isCollected;

0 commit comments

Comments
 (0)