[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 javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ -16,7 +17,7 @@ public class CryptoPriceModel {
|
||||
private int id;
|
||||
|
||||
@Column(name = "timestamp", nullable = false)
|
||||
private String timestamp;
|
||||
private Date timestamp;
|
||||
|
||||
@Column(name = "symbol", nullable = false)
|
||||
private String type;
|
||||
|
||||
@ -7,13 +7,15 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import cryptosky.me.graphql.pricing.service.BtcPriceService;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Component
|
||||
public class BtcPriceMutation implements GraphQLMutationResolver {
|
||||
|
||||
@Autowired
|
||||
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 c_price, final float 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();
|
||||
}
|
||||
|
||||
public Optional<BtcPriceModel> getPriceForCreatedDate( final String createdDate ) {
|
||||
return this.btcPriceService.getPriceForCreatedDate(createdDate);
|
||||
}
|
||||
|
||||
public List<BtcPriceModel> getPriceBetweenDates(final String startDate, final String endDate ) {
|
||||
return this.btcPriceService.getPriceBetweenDates(startDate, endDate);
|
||||
}
|
||||
// public Optional<BtcPriceModel> getPriceForCreatedDate( final String createdDate ) {
|
||||
// return this.btcPriceService.getPriceForCreatedDate(createdDate);
|
||||
// }
|
||||
//
|
||||
// public List<BtcPriceModel> getPriceBetweenDates(final String startDate, final String 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.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
@ -21,12 +22,12 @@ public class BtcPriceService {
|
||||
}
|
||||
|
||||
@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 c_price, final float volume ) {
|
||||
|
||||
final BtcPriceModel btcPrice = new BtcPriceModel();
|
||||
btcPrice.setTimestamp(format(createdDate).toString());
|
||||
btcPrice.setTimestamp(createdDate);
|
||||
btcPrice.setType(type);
|
||||
btcPrice.setAverage_price(av_price);
|
||||
btcPrice.setHigh_price(h_price);
|
||||
@ -58,20 +59,20 @@ public class BtcPriceService {
|
||||
return this.btcPriceRepository.findAll().stream().findFirst();
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public Optional<BtcPriceModel> getPriceForCreatedDate( final String createdDate ) {
|
||||
return this.btcPriceRepository.findAll().stream()
|
||||
.filter(createdDateList -> createdDateList.getTimestamp().equals(format(createdDate)))
|
||||
.findFirst();
|
||||
}
|
||||
// @Transactional(readOnly = true)
|
||||
// public Optional<BtcPriceModel> getPriceForCreatedDate( final String createdDate ) {
|
||||
// return this.btcPriceRepository.findAll().stream()
|
||||
// .filter(createdDateList -> createdDateList.getTimestamp().equals(format(createdDate)))
|
||||
// .findFirst();
|
||||
// }
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public List<BtcPriceModel> getPriceBetweenDates( final String startDate, final String endDate ) {
|
||||
return this.btcPriceRepository.findAll().stream()
|
||||
.filter(createdDateList -> format(createdDateList.getTimestamp()).isBefore(format(endDate)))
|
||||
.filter(createdDateList -> format(createdDateList.getTimestamp()).isAfter(format(startDate)))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
// @Transactional(readOnly = true)
|
||||
// public List<BtcPriceModel> getPriceBetweenDates( final String startDate, final String endDate ) {
|
||||
// return this.btcPriceRepository.findAll().stream()
|
||||
// .filter(createdDateList -> format(createdDateList.getTimestamp()).isBefore(format(endDate)))
|
||||
// .filter(createdDateList -> format(createdDateList.getTimestamp()).isAfter(format(startDate)))
|
||||
// .collect(Collectors.toList());
|
||||
// }
|
||||
|
||||
// @Transactional(readOnly = true)
|
||||
// public List<BtcPriceModel> getAllLatest() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user