From 2e384d0b9a496eda0469ee496e9008ddd399f999 Mon Sep 17 00:00:00 2001 From: yanweidong Date: Tue, 7 Apr 2026 19:30:42 +0800 Subject: [PATCH] fix bug --- models/models.go | 152 +++++++++++++++++++++++------------------------ 1 file changed, 76 insertions(+), 76 deletions(-) diff --git a/models/models.go b/models/models.go index b1d0f46..678a6b7 100644 --- a/models/models.go +++ b/models/models.go @@ -8,96 +8,96 @@ import ( // AssetSnapshot 资产快照数据库模型 type CollectorAssets struct { - ID uint `json:"id" gorm:"primaryKey"` - AccountID string `json:"account_id" gorm:"type:varchar(50);not null;index"` - Ymd int `json:"ymd" gorm:"not null;index;comment:年月日数字格式,如20260407"` - Cash float64 `json:"cash" gorm:"type:decimal(15,2);not null;default:0"` - FrozenCash float64 `json:"frozen_cash" gorm:"type:decimal(15,2);not null;default:0;column:frozen_cash"` - MarketValue float64 `json:"market_value" gorm:"type:decimal(15,2);not null;default:0;column:market_value"` - Profit float64 `json:"profit" gorm:"type:decimal(15,2);not null;default:0"` - TotalAsset float64 `json:"total_asset" gorm:"type:decimal(15,2);not null;default:0;column:total_asset"` - DataHash string `json:"data_hash" gorm:"type:varchar(64);not null;index"` - CollectedAt time.Time `json:"collected_at" gorm:"not null;index"` - CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"` - DeletedAt gorm.DeletedAt `json:"-" gorm:"index"` + ID uint `json:"id" gorm:"primaryKey;comment:主键ID"` + AccountID string `json:"account_id" gorm:"type:varchar(50);not null;index;comment:账户ID"` + Ymd int `json:"ymd" gorm:"not null;index;comment:采集日期(年月日数字格式,如20260407)"` + Cash float64 `json:"cash" gorm:"type:decimal(15,2);not null;default:0;comment:可用资金"` + FrozenCash float64 `json:"frozen_cash" gorm:"type:decimal(15,2);not null;default:0;column:frozen_cash;comment:冻结资金"` + MarketValue float64 `json:"market_value" gorm:"type:decimal(15,2);not null;default:0;column:market_value;comment:持仓市值"` + Profit float64 `json:"profit" gorm:"type:decimal(15,2);not null;default:0;comment:当日盈亏"` + TotalAsset float64 `json:"total_asset" gorm:"type:decimal(15,2);not null;default:0;column:total_asset;comment:总资产"` + DataHash string `json:"data_hash" gorm:"type:varchar(64);not null;index;comment:数据哈希值(用于变化检测)"` + CollectedAt time.Time `json:"collected_at" gorm:"not null;index;comment:数据采集时间"` + CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime;comment:记录创建时间"` + DeletedAt gorm.DeletedAt `json:"-" gorm:"index;comment:软删除时间"` } // OrderRecord 订单数据库模型 type CollectorOrder struct { - ID uint `json:"id" gorm:"primaryKey"` - OrderID int64 `json:"order_id" gorm:"not null;index"` - AccountID string `json:"account_id" gorm:"type:varchar(50);not null;index"` - StockCode string `json:"stock_code" gorm:"type:varchar(20);not null;index"` - Ymd int `json:"ymd" gorm:"not null;index;comment:年月日数字格式,如20260407"` - Price float64 `json:"price" gorm:"type:decimal(10,4);not null;default:0"` - Volume int `json:"volume" gorm:"not null;default:0"` - TradedPrice float64 `json:"traded_price" gorm:"type:decimal(10,4);not null;default:0;column:traded_price"` - TradedVolume int `json:"traded_volume" gorm:"not null;default:0;column:traded_volume"` - OrderStatus int `json:"order_status" gorm:"not null;default:0;column:order_status"` - OrderTime int64 `json:"order_time" gorm:"not null;column:order_time"` - OrderRemark string `json:"order_remark" gorm:"type:text;column:order_remark"` - DataHash string `json:"data_hash" gorm:"type:varchar(64);not null"` - CollectedAt time.Time `json:"collected_at" gorm:"not null;index"` - CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"` - DeletedAt gorm.DeletedAt `json:"-" gorm:"index"` + ID uint `json:"id" gorm:"primaryKey;comment:主键ID"` + OrderID int64 `json:"order_id" gorm:"not null;index;comment:订单ID"` + AccountID string `json:"account_id" gorm:"type:varchar(50);not null;index;comment:账户ID"` + StockCode string `json:"stock_code" gorm:"type:varchar(20);not null;index;comment:股票代码"` + Ymd int `json:"ymd" gorm:"not null;index;comment:采集日期(年月日数字格式,如20260407)"` + Price float64 `json:"price" gorm:"type:decimal(10,4);not null;default:0;comment:委托价格"` + Volume int `json:"volume" gorm:"not null;default:0;comment:委托数量"` + TradedPrice float64 `json:"traded_price" gorm:"type:decimal(10,4);not null;default:0;column:traded_price;comment:成交均价"` + TradedVolume int `json:"traded_volume" gorm:"not null;default:0;column:traded_volume;comment:成交数量"` + OrderStatus int `json:"order_status" gorm:"not null;default:0;column:order_status;comment:订单状态"` + OrderTime int64 `json:"order_time" gorm:"not null;column:order_time;comment:下单时间戳"` + OrderRemark string `json:"order_remark" gorm:"type:text;column:order_remark;comment:订单备注"` + DataHash string `json:"data_hash" gorm:"type:varchar(64);not null;comment:数据哈希值(用于变化检测)"` + CollectedAt time.Time `json:"collected_at" gorm:"not null;index;comment:数据采集时间"` + CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime;comment:记录创建时间"` + DeletedAt gorm.DeletedAt `json:"-" gorm:"index;comment:软删除时间"` } // PositionRecord 持仓数据库模型 type CollectorPosition struct { - ID uint `json:"id" gorm:"primaryKey"` - AccountID string `json:"account_id" gorm:"type:varchar(50);not null;index"` - Code string `json:"code" gorm:"type:varchar(20);not null;index"` - Ymd int `json:"ymd" gorm:"not null;index;comment:年月日数字格式,如20260407"` - Volume int `json:"volume" gorm:"not null;default:0"` - CanUseVolume int `json:"can_use_volume" gorm:"not null;default:0;column:can_use_volume"` - FrozenVolume int `json:"frozen_volume" gorm:"not null;default:0;column:frozen_volume"` - AvgPrice float64 `json:"avg_price" gorm:"type:decimal(10,4);not null;default:0;column:avg_price"` - OpenPrice float64 `json:"open_price" gorm:"type:decimal(10,4);not null;default:0;column:open_price"` - CurrentPrice float64 `json:"current_price" gorm:"type:decimal(10,4);not null;default:0;column:current_price"` - MarketValue float64 `json:"market_value" gorm:"type:decimal(15,2);not null;default:0;column:market_value"` - Profit float64 `json:"profit" gorm:"type:decimal(15,2);not null;default:0"` - ProfitRate float64 `json:"profit_rate" gorm:"type:decimal(10,4);not null;default:0;column:profit_rate"` - MinProfitRate float64 `json:"min_profit_rate" gorm:"type:decimal(10,4);not null;default:0;column:min_profit_rate"` - DataHash string `json:"data_hash" gorm:"type:varchar(64);not null"` - CollectedAt time.Time `json:"collected_at" gorm:"not null;index"` - CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"` - DeletedAt gorm.DeletedAt `json:"-" gorm:"index"` + ID uint `json:"id" gorm:"primaryKey;comment:主键ID"` + AccountID string `json:"account_id" gorm:"type:varchar(50);not null;index;comment:账户ID"` + Code string `json:"code" gorm:"type:varchar(20);not null;index;comment:股票代码"` + Ymd int `json:"ymd" gorm:"not null;index;comment:采集日期(年月日数字格式,如20260407)"` + Volume int `json:"volume" gorm:"not null;default:0;comment:持仓数量"` + CanUseVolume int `json:"can_use_volume" gorm:"not null;default:0;column:can_use_volume;comment:可用数量"` + FrozenVolume int `json:"frozen_volume" gorm:"not null;default:0;column:frozen_volume;comment:冻结数量"` + AvgPrice float64 `json:"avg_price" gorm:"type:decimal(10,4);not null;default:0;column:avg_price;comment:持仓成本价"` + OpenPrice float64 `json:"open_price" gorm:"type:decimal(10,4);not null;default:0;column:open_price;comment:开仓价格"` + CurrentPrice float64 `json:"current_price" gorm:"type:decimal(10,4);not null;default:0;column:current_price;comment:当前价格"` + MarketValue float64 `json:"market_value" gorm:"type:decimal(15,2);not null;default:0;column:market_value;comment:持仓市值"` + Profit float64 `json:"profit" gorm:"type:decimal(15,2);not null;default:0;comment:持仓盈亏"` + ProfitRate float64 `json:"profit_rate" gorm:"type:decimal(10,4);not null;default:0;column:profit_rate;comment:盈亏比例"` + MinProfitRate float64 `json:"min_profit_rate" gorm:"type:decimal(10,4);not null;default:0;column:min_profit_rate;comment:最低盈亏比例"` + DataHash string `json:"data_hash" gorm:"type:varchar(64);not null;comment:数据哈希值(用于变化检测)"` + CollectedAt time.Time `json:"collected_at" gorm:"not null;index;comment:数据采集时间"` + CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime;comment:记录创建时间"` + DeletedAt gorm.DeletedAt `json:"-" gorm:"index;comment:软删除时间"` } // TickRecord 行情数据库模型 type CollectorTick struct { - ID uint `json:"id" gorm:"primaryKey"` - StockCode string `json:"stock_code" gorm:"type:varchar(20);not null;index"` - Ymd int `json:"ymd" gorm:"not null;index;comment:年月日数字格式,如20260407"` - LastPrice float64 `json:"last_price" gorm:"type:decimal(10,4);not null;default:0;column:last_price"` - Open float64 `json:"open" gorm:"type:decimal(10,4);not null;default:0"` - High float64 `json:"high" gorm:"type:decimal(10,4);not null;default:0"` - Low float64 `json:"low" gorm:"type:decimal(10,4);not null;default:0"` - LastClose float64 `json:"last_close" gorm:"type:decimal(10,4);not null;default:0;column:last_close"` - Volume int64 `json:"volume" gorm:"not null;default:0"` - Amount float64 `json:"amount" gorm:"type:decimal(15,2);not null;default:0"` - PVolume int64 `json:"pvolume" gorm:"not null;default:0;column:pvolume"` - BidPrices []float64 `json:"bid_prices" gorm:"type:decimal(10,4)[];column:bid_prices"` - BidVolumes []int `json:"bid_volumes" gorm:"type:integer[];column:bid_volumes"` - AskPrices []float64 `json:"ask_prices" gorm:"type:decimal(10,4)[];column:ask_prices"` - AskVolumes []int `json:"ask_volumes" gorm:"type:integer[];column:ask_volumes"` - Time int64 `json:"time" gorm:"not null;index"` - TimeTag string `json:"timetag" gorm:"type:varchar(50);column:timetag"` - StockStatus int `json:"stock_status" gorm:"not null;default:0;column:stock_status"` - DataHash string `json:"data_hash" gorm:"type:varchar(64);not null"` - CollectedAt time.Time `json:"collected_at" gorm:"not null;index"` - CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"` - DeletedAt gorm.DeletedAt `json:"-" gorm:"index"` + ID uint `json:"id" gorm:"primaryKey;comment:主键ID"` + StockCode string `json:"stock_code" gorm:"type:varchar(20);not null;index;comment:股票代码"` + Ymd int `json:"ymd" gorm:"not null;index;comment:采集日期(年月日数字格式,如20260407)"` + LastPrice float64 `json:"last_price" gorm:"type:decimal(10,4);not null;default:0;column:last_price;comment:最新成交价"` + Open float64 `json:"open" gorm:"type:decimal(10,4);not null;default:0;comment:开盘价"` + High float64 `json:"high" gorm:"type:decimal(10,4);not null;default:0;comment:最高价"` + Low float64 `json:"low" gorm:"type:decimal(10,4);not null;default:0;comment:最低价"` + LastClose float64 `json:"last_close" gorm:"type:decimal(10,4);not null;default:0;column:last_close;comment:昨收盘价"` + Volume int64 `json:"volume" gorm:"not null;default:0;comment:成交量(股)"` + Amount float64 `json:"amount" gorm:"type:decimal(15,2);not null;default:0;comment:成交额(元)"` + PVolume int64 `json:"pvolume" gorm:"not null;default:0;column:pvolume;comment:累积成交量"` + BidPrices []float64 `json:"bid_prices" gorm:"type:decimal(10,4)[];column:bid_prices;comment:买盘价格数组(买一到买五)"` + BidVolumes []int `json:"bid_volumes" gorm:"type:integer[];column:bid_volumes;comment:买盘数量数组(买一到买五)"` + AskPrices []float64 `json:"ask_prices" gorm:"type:decimal(10,4)[];column:ask_prices;comment:卖盘价格数组(卖一到卖五)"` + AskVolumes []int `json:"ask_volumes" gorm:"type:integer[];column:ask_volumes;comment:卖盘数量数组(卖一到卖五)"` + Time int64 `json:"time" gorm:"not null;index;comment:行情时间戳"` + TimeTag string `json:"timetag" gorm:"type:varchar(50);column:timetag;comment:时间标签(格式化时间字符串)"` + StockStatus int `json:"stock_status" gorm:"not null;default:0;column:stock_status;comment:股票状态"` + DataHash string `json:"data_hash" gorm:"type:varchar(64);not null;comment:数据哈希值(用于变化检测)"` + CollectedAt time.Time `json:"collected_at" gorm:"not null;index;comment:数据采集时间"` + CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime;comment:记录创建时间"` + DeletedAt gorm.DeletedAt `json:"-" gorm:"index;comment:软删除时间"` } // CollectionLog 采集日志数据库模型 type CollectorLog struct { - ID uint `json:"id" gorm:"primaryKey"` - DataHash string `json:"data_hash" gorm:"type:varchar(64);not null;index"` - Ymd int `json:"ymd" gorm:"not null;index;comment:年月日数字格式,如20260407"` - HasChanged bool `json:"has_changed" gorm:"not null;default:false;column:has_changed"` - StatusMessage string `json:"status_message" gorm:"type:text;column:status_message"` - CollectedAt time.Time `json:"collected_at" gorm:"not null;index"` - CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"` - DeletedAt gorm.DeletedAt `json:"-" gorm:"index"` + ID uint `json:"id" gorm:"primaryKey;comment:主键ID"` + DataHash string `json:"data_hash" gorm:"type:varchar(64);not null;index;comment:数据哈希值(用于变化检测)"` + Ymd int `json:"ymd" gorm:"not null;index;comment:采集日期(年月日数字格式,如20260407)"` + HasChanged bool `json:"has_changed" gorm:"not null;default:false;column:has_changed;comment:数据是否发生变化"` + StatusMessage string `json:"status_message" gorm:"type:text;column:status_message;comment:状态消息(成功/失败信息)"` + CollectedAt time.Time `json:"collected_at" gorm:"not null;index;comment:数据采集时间"` + CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime;comment:记录创建时间"` + DeletedAt gorm.DeletedAt `json:"-" gorm:"index;comment:软删除时间"` }