feat: 增加年线行情更新
This commit is contained in:
@@ -29,6 +29,7 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
@Table(name = Constants.DATABASE_PREFIX + "daily")
|
||||
public class Daily extends SimpleEntity {
|
||||
@Column(nullable = false)
|
||||
@Comment("交易日")
|
||||
private LocalDate tradeDate;
|
||||
@Comment("开盘价")
|
||||
private Double open;
|
||||
|
||||
@@ -61,6 +61,10 @@ public class Stock extends SimpleEntity {
|
||||
@ToString.Exclude
|
||||
private Set<Daily> dailies;
|
||||
|
||||
@OneToMany(mappedBy = "stock", cascade = CascadeType.REMOVE)
|
||||
@ToString.Exclude
|
||||
private Set<Yearly> yearlies;
|
||||
|
||||
@OneToMany(mappedBy = "stock", cascade = CascadeType.REMOVE)
|
||||
@ToString.Exclude
|
||||
private Set<FinanceIndicator> indicators;
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.lanyuanxiaoyao.leopard.core.entity;
|
||||
|
||||
import com.lanyuanxiaoyao.leopard.core.Constants;
|
||||
import com.lanyuanxiaoyao.service.template.entity.SimpleEntity;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.EntityListeners;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.FieldNameConstants;
|
||||
import org.hibernate.annotations.Comment;
|
||||
import org.hibernate.annotations.DynamicInsert;
|
||||
import org.hibernate.annotations.DynamicUpdate;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
|
||||
/**
|
||||
* 年线行情,后复权
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
@ToString(callSuper = true)
|
||||
@FieldNameConstants
|
||||
@Entity
|
||||
@DynamicUpdate
|
||||
@DynamicInsert
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
@Table(name = Constants.DATABASE_PREFIX + "yearly")
|
||||
public class Yearly extends SimpleEntity {
|
||||
@Column(nullable = false)
|
||||
@Comment("年份")
|
||||
private Integer year;
|
||||
@Comment("开盘价")
|
||||
private Double open;
|
||||
@Comment("最高价")
|
||||
private Double high;
|
||||
@Comment("最低价")
|
||||
private Double low;
|
||||
@Comment("收盘价")
|
||||
private Double close;
|
||||
@Comment("涨跌额")
|
||||
private Double priceChangeAmount;
|
||||
@Comment("涨跌幅")
|
||||
private Double priceFluctuationRange;
|
||||
@Comment("成交量")
|
||||
private Double volume;
|
||||
@Comment("成交额")
|
||||
private Double turnover;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(nullable = false)
|
||||
@ToString.Exclude
|
||||
private Stock stock;
|
||||
}
|
||||
@@ -19,6 +19,14 @@ public interface DailyRepository extends SimpleRepository<Daily> {
|
||||
@Query("select distinct daily.tradeDate from Daily daily where daily.stock.id = ?1")
|
||||
List<LocalDate> findDistinctTradeDateByStockId(Long stockId);
|
||||
|
||||
@Query("select max(daily.tradeDate) from Daily daily")
|
||||
LocalDate findMaxTradeDate();
|
||||
|
||||
@Query("select min(daily.tradeDate) from Daily daily")
|
||||
LocalDate findMinTradeDate();
|
||||
|
||||
List<Daily> findAllByTradeDate_YearAndStock_Code(int tradeDateYear, String stockCode);
|
||||
|
||||
@EntityGraph(attributePaths = {"stock"})
|
||||
@Override
|
||||
Optional<Daily> findOne(Predicate predicate);
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.lanyuanxiaoyao.leopard.core.repository;
|
||||
|
||||
import com.lanyuanxiaoyao.leopard.core.entity.Yearly;
|
||||
import com.lanyuanxiaoyao.service.template.repository.SimpleRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface YearlyRepository extends SimpleRepository<Yearly> {
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.lanyuanxiaoyao.leopard.core;
|
||||
|
||||
import com.lanyuanxiaoyao.service.template.util.DDLGenerator;
|
||||
import com.lanyuanxiaoyao.service.template.Helper;
|
||||
import org.hibernate.dialect.PostgreSQLDialect;
|
||||
import org.postgresql.Driver;
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.postgresql.Driver;
|
||||
*/
|
||||
public class GenerateDDL {
|
||||
public static void main(String[] args) {
|
||||
DDLGenerator.generateDDL(
|
||||
Helper.generateDDL(
|
||||
"com.lanyuanxiaoyao.leopard.core.entity",
|
||||
"/Users/lanyuanxiaoyao/Project/IdeaProjects/leopard/leopard-core/target",
|
||||
PostgreSQLDialect.class,
|
||||
|
||||
Reference in New Issue
Block a user