[24.02.20] String to Date change
This commit is contained in:
parent
0a84900bf1
commit
1d4a0d12a7
@ -3,6 +3,7 @@ package cryptosky.me.graphql.pricing.models.entities;
|
|||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@ -16,7 +17,7 @@ public class CryptoPriceModel {
|
|||||||
private int id;
|
private int id;
|
||||||
|
|
||||||
@Column(name = "timestamp", nullable = false)
|
@Column(name = "timestamp", nullable = false)
|
||||||
private String timestamp;
|
private Date timestamp;
|
||||||
|
|
||||||
@Column(name = "symbol", nullable = false)
|
@Column(name = "symbol", nullable = false)
|
||||||
private String type;
|
private String type;
|
||||||
|
|||||||
@ -7,13 +7,15 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
import cryptosky.me.graphql.pricing.service.BtcPriceService;
|
import cryptosky.me.graphql.pricing.service.BtcPriceService;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class BtcPriceMutation implements GraphQLMutationResolver {
|
public class BtcPriceMutation implements GraphQLMutationResolver {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private BtcPriceService btcPriceService;
|
private BtcPriceService btcPriceService;
|
||||||
|
|
||||||
public BtcPriceModel createBtc(final String createdDate, final String type, final float av_price,
|
public BtcPriceModel createBtc(final Date createdDate, final String type, final float av_price,
|
||||||
final float h_price, final float l_price, final float o_price,
|
final float h_price, final float l_price, final float o_price,
|
||||||
final float c_price, final float volume ) {
|
final float c_price, final float volume ) {
|
||||||
return this.btcPriceService.createBtc(createdDate, type, av_price, h_price, l_price, o_price, c_price, volume);
|
return this.btcPriceService.createBtc(createdDate, type, av_price, h_price, l_price, o_price, c_price, volume);
|
||||||
|
|||||||
@ -27,11 +27,11 @@ public class BtcPriceQuery implements GraphQLQueryResolver {
|
|||||||
return this.btcPriceService.getLatest();
|
return this.btcPriceService.getLatest();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<BtcPriceModel> getPriceForCreatedDate( final String createdDate ) {
|
// public Optional<BtcPriceModel> getPriceForCreatedDate( final String createdDate ) {
|
||||||
return this.btcPriceService.getPriceForCreatedDate(createdDate);
|
// return this.btcPriceService.getPriceForCreatedDate(createdDate);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public List<BtcPriceModel> getPriceBetweenDates(final String startDate, final String endDate ) {
|
// public List<BtcPriceModel> getPriceBetweenDates(final String startDate, final String endDate ) {
|
||||||
return this.btcPriceService.getPriceBetweenDates(startDate, endDate);
|
// return this.btcPriceService.getPriceBetweenDates(startDate, endDate);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import cryptosky.me.graphql.pricing.models.repositories.BtcPriceRepository;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -21,12 +22,12 @@ public class BtcPriceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public BtcPriceModel createBtc(final String createdDate, final String type, final float av_price,
|
public BtcPriceModel createBtc(final Date createdDate, final String type, final float av_price,
|
||||||
final float h_price, final float l_price, final float o_price,
|
final float h_price, final float l_price, final float o_price,
|
||||||
final float c_price, final float volume ) {
|
final float c_price, final float volume ) {
|
||||||
|
|
||||||
final BtcPriceModel btcPrice = new BtcPriceModel();
|
final BtcPriceModel btcPrice = new BtcPriceModel();
|
||||||
btcPrice.setTimestamp(format(createdDate).toString());
|
btcPrice.setTimestamp(createdDate);
|
||||||
btcPrice.setType(type);
|
btcPrice.setType(type);
|
||||||
btcPrice.setAverage_price(av_price);
|
btcPrice.setAverage_price(av_price);
|
||||||
btcPrice.setHigh_price(h_price);
|
btcPrice.setHigh_price(h_price);
|
||||||
@ -58,20 +59,20 @@ public class BtcPriceService {
|
|||||||
return this.btcPriceRepository.findAll().stream().findFirst();
|
return this.btcPriceRepository.findAll().stream().findFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
// @Transactional(readOnly = true)
|
||||||
public Optional<BtcPriceModel> getPriceForCreatedDate( final String createdDate ) {
|
// public Optional<BtcPriceModel> getPriceForCreatedDate( final String createdDate ) {
|
||||||
return this.btcPriceRepository.findAll().stream()
|
// return this.btcPriceRepository.findAll().stream()
|
||||||
.filter(createdDateList -> createdDateList.getTimestamp().equals(format(createdDate)))
|
// .filter(createdDateList -> createdDateList.getTimestamp().equals(format(createdDate)))
|
||||||
.findFirst();
|
// .findFirst();
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
// @Transactional(readOnly = true)
|
||||||
public List<BtcPriceModel> getPriceBetweenDates( final String startDate, final String endDate ) {
|
// public List<BtcPriceModel> getPriceBetweenDates( final String startDate, final String endDate ) {
|
||||||
return this.btcPriceRepository.findAll().stream()
|
// return this.btcPriceRepository.findAll().stream()
|
||||||
.filter(createdDateList -> format(createdDateList.getTimestamp()).isBefore(format(endDate)))
|
// .filter(createdDateList -> format(createdDateList.getTimestamp()).isBefore(format(endDate)))
|
||||||
.filter(createdDateList -> format(createdDateList.getTimestamp()).isAfter(format(startDate)))
|
// .filter(createdDateList -> format(createdDateList.getTimestamp()).isAfter(format(startDate)))
|
||||||
.collect(Collectors.toList());
|
// .collect(Collectors.toList());
|
||||||
}
|
// }
|
||||||
|
|
||||||
// @Transactional(readOnly = true)
|
// @Transactional(readOnly = true)
|
||||||
// public List<BtcPriceModel> getAllLatest() {
|
// public List<BtcPriceModel> getAllLatest() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user