From 16cb8c4981652487de4cfa5748ab9772b591bc0c Mon Sep 17 00:00:00 2001 From: Pol Pinol Castuera Date: Thu, 29 May 2025 22:40:34 +0200 Subject: [PATCH] Return no decimals --- .../event_publishers/GcpPubSubEventPublisher.java | 6 +----- .../java/io/autoinvestor/ui/GetAssetPriceController.java | 2 +- src/main/java/io/autoinvestor/ui/PriceDTO.java | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main/java/io/autoinvestor/infrastructure/event_publishers/GcpPubSubEventPublisher.java b/src/main/java/io/autoinvestor/infrastructure/event_publishers/GcpPubSubEventPublisher.java index 1f3dc68..691c04f 100644 --- a/src/main/java/io/autoinvestor/infrastructure/event_publishers/GcpPubSubEventPublisher.java +++ b/src/main/java/io/autoinvestor/infrastructure/event_publishers/GcpPubSubEventPublisher.java @@ -1,16 +1,12 @@ package io.autoinvestor.infrastructure.event_publishers; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.protobuf.ByteString; -import com.google.pubsub.v1.ProjectTopicName; -import com.google.pubsub.v1.PubsubMessage; import com.google.cloud.pubsub.v1.Publisher; +import com.google.pubsub.v1.ProjectTopicName; import io.autoinvestor.domain.Event; import io.autoinvestor.domain.EventPublisher; import jakarta.annotation.PreDestroy; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Component; diff --git a/src/main/java/io/autoinvestor/ui/GetAssetPriceController.java b/src/main/java/io/autoinvestor/ui/GetAssetPriceController.java index 4d40f4d..8ad76bc 100644 --- a/src/main/java/io/autoinvestor/ui/GetAssetPriceController.java +++ b/src/main/java/io/autoinvestor/ui/GetAssetPriceController.java @@ -31,7 +31,7 @@ public ResponseEntity getPrice( GetAssetPriceResponse response = handler.handle(new GetAssetPriceCommand(assetId, date)); PriceDTO dto = new PriceDTO( response.date(), - response.price() + Math.round(response.price() * 100) ); return ResponseEntity.ok(dto); } diff --git a/src/main/java/io/autoinvestor/ui/PriceDTO.java b/src/main/java/io/autoinvestor/ui/PriceDTO.java index 934a485..81aaa30 100644 --- a/src/main/java/io/autoinvestor/ui/PriceDTO.java +++ b/src/main/java/io/autoinvestor/ui/PriceDTO.java @@ -7,4 +7,4 @@ public record PriceDTO( @JsonFormat(shape = JsonFormat.Shape.STRING) Date date, - float price) { } + int priceWithCents) { }