diff --git a/pom.xml b/pom.xml
index 0cfa4ee..15a68f8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -67,6 +67,23 @@
4.3.8.Final
+
+
+ com.graphql-java
+ graphql-spring-boot-starter
+ 5.0.2
+
+
+ com.graphql-java
+ graphql-java-tools
+ 5.2.4
+
+
+ com.graphql-java
+ graphiql-spring-boot-starter
+ 5.0.2
+
+
org.springframework.boot
diff --git a/src/main/java/cryptosky/me/pricing/graphql/queries/BtcPriceQuery.java b/src/main/java/cryptosky/me/pricing/graphql/queries/BtcPriceQuery.java
new file mode 100644
index 0000000..7400de8
--- /dev/null
+++ b/src/main/java/cryptosky/me/pricing/graphql/queries/BtcPriceQuery.java
@@ -0,0 +1,37 @@
+package cryptosky.me.pricing.graphql.queries;
+
+import com.coxautodev.graphql.tools.GraphQLQueryResolver;
+import cryptosky.me.pricing.models.entities.BtcPriceModel;
+import cryptosky.me.pricing.service.PriceService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.Optional;
+
+@Component
+public class BtcPriceQuery implements GraphQLQueryResolver {
+
+ @Autowired
+ private PriceService priceService;
+
+ public List getAllPrices(final int count ) {
+ return this.priceService.getAllPrices(count);
+ }
+
+ public List getPricesBetweenCounts( final int startCount, final int endCount ) {
+ return this.priceService.getPricesBetweenCounts(startCount, endCount);
+ }
+
+ public Optional getLatest() {
+ return this.priceService.getLatest();
+ }
+
+ public Optional getPriceForCreatedDate( final String createdDate ) {
+ return this.priceService.getPriceForCreatedDate(createdDate);
+ }
+
+ public List getPriceBetweenDates(final String startDate, final String endDate ) {
+ return this.priceService.getPriceBetweenDates(startDate, endDate);
+ }
+}
diff --git a/src/main/java/cryptosky/me/pricing/service/PriceService.java b/src/main/java/cryptosky/me/pricing/service/PriceService.java
index 4b24690..fdc3c04 100644
--- a/src/main/java/cryptosky/me/pricing/service/PriceService.java
+++ b/src/main/java/cryptosky/me/pricing/service/PriceService.java
@@ -9,7 +9,6 @@ import cryptosky.me.pricing.models.entities.CryptoPriceModel;
import cryptosky.me.pricing.models.repositories.BtcPriceRepository;
import cryptosky.me.exceptions.NotSupportedCurrencyTypeException;
-import cryptosky.me.exceptions.DatabaseViolationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -22,11 +21,9 @@ import org.springframework.transaction.annotation.Transactional;
import javax.jms.JMSException;
import javax.jms.TextMessage;
import java.util.ArrayList;
-import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
-import java.time.LocalDateTime;
import static cryptosky.me.ArtemisSyncMessaging.*;
import static cryptosky.me.SupportedCurrencies.*;
@@ -55,29 +52,6 @@ public class PriceService {
this.dlqName = dlqName;
}
- @Transactional
- public BtcPriceModel createBtc(final String createdDate, final String type,
- final float av_price,
- final float h_price,
- final float l_price,
- final float o_price,
- final float c_price,
- final float volume ) {
-
- final BtcPriceModel btcPrice = new BtcPriceModel();
- btcPrice.setTimestamp(LocalDateTime.parse((createdDate)));
- btcPrice.setType(type);
- btcPrice.setAverage_price(av_price);
- btcPrice.setHigh_price(h_price);
- btcPrice.setLow_price(l_price);
- btcPrice.setOpen_price(o_price);
- btcPrice.setClose_price(c_price);
- btcPrice.setVolume(volume);
-
- return btcPrice;
-// return this.btcPriceRepository.save(btcPrice);
- }
-
@Transactional
public void createRecord(CryptoPriceModel cryptoPriceModel, String correlationId, TextMessage message) {
String syncId = randomUUID().toString();
diff --git a/src/main/resources/graphql/configQL.graphqls b/src/main/resources/graphql/configQL.graphqls
new file mode 100644
index 0000000..65a4378
--- /dev/null
+++ b/src/main/resources/graphql/configQL.graphqls
@@ -0,0 +1,35 @@
+type BtcPrice {
+ id: ID!,
+ timestamp: String!,
+ type: String,
+ average_price: Float!,
+ high_price: Float,
+ low_price: Float,
+ open_price: Float,
+ close_price: Float,
+ volume: Float
+}
+
+type sentimentModel {
+ id: ID!,
+ timestamp: String!,
+ rawTweet: String,
+ sentimentScore: Float!,
+ positiveScore: Float,
+ neutralScore: Float,
+ negativeScore: Float,
+ compoundScore: Float!
+}
+
+type Query {
+ allPrices(count: Int):[BtcPrice],
+ pricesBetweenCounts(startCount: Int, endCount: Int):[BtcPrice]
+ latest:BtcPrice,
+ priceForCreatedDate(createdDate: String):BtcPrice,
+ priceBetweenDates(startDate: String, endDate: String):[BtcPrice],
+ ################################################################
+ currentTweet:sentimentModel,
+ allTweets(count: Int):[sentimentModel],
+ tweetsForDay(startDate: String, endDate: String):[sentimentModel],
+ tweetsForPeriod(startDate: String, endDate: String):[sentimentModel]
+}
\ No newline at end of file