From 8f3eda131c3d7347c5b7a026003a10f1a6ff296f Mon Sep 17 00:00:00 2001 From: vipg Date: Mon, 22 Dec 2025 17:21:49 +0800 Subject: [PATCH] add --- infra/postgres/sql/03_trading_records.sql | 1 - services/cn_futures_trading_records/src/crud/create.go | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/infra/postgres/sql/03_trading_records.sql b/infra/postgres/sql/03_trading_records.sql index b1e64b5..e2617ab 100644 --- a/infra/postgres/sql/03_trading_records.sql +++ b/infra/postgres/sql/03_trading_records.sql @@ -25,7 +25,6 @@ BEGIN ) THEN CREATE TABLE cn_futures_trading_records ( id UUID DEFAULT gen_random_uuid() PRIMARY KEY, -- id - event_type VARCHAR(40) NOT NULL, -- 事件名称 payload JSONB NOT NULL, -- 数据 deleted BOOLEAN NOT NULL DEFAULT FALSE, -- 删除状态 created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, -- 记录创建时间 diff --git a/services/cn_futures_trading_records/src/crud/create.go b/services/cn_futures_trading_records/src/crud/create.go index 1450097..7a5127b 100644 --- a/services/cn_futures_trading_records/src/crud/create.go +++ b/services/cn_futures_trading_records/src/crud/create.go @@ -14,12 +14,13 @@ import ( /* ---------- 公共 Payload 结构体 ---------- */ type Payload struct { + Status int `json:"status" binding:"required,min=-1,max=1"` // 状态(-1:亏损,0:持仓中,1:盈利) OpenYear int `json:"open_year" binding:"required,min=1900,max=2200"` // 开仓时间:年(1900-2200) OpenMonth int `json:"open_month" binding:"required,min=1,max=12"` // 开仓时间:月(1-12) OpenDay int `json:"open_day" binding:"required,min=1,max=31"` // 开仓时间:日(1-31) Symbol string `json:"symbol" binding:"required"` // 品种代码(如 RB、CU) Contract string `json:"contract" binding:"required"` // 合约代码(如 2505) - Direction string `json:"direction" binding:"required,oneof=long short"` // 交易方向:long 多头 / short 空头 + Direction int `json:"direction" binding:"required,min=-1,max=1"` // 1 多头 / -1 空头 OpenPrice float64 `json:"open_price" binding:"required"` // 开仓价格(单位:元) OpenFee float64 `json:"open_fee" binding:"required,min=0"` // 开仓手续费(≥0) CloseYear int `json:"close_year" binding:"required,min=1900,max=2200"` // 平仓时间:年(1900-2200)