feat: 开发我的持仓列表
This commit is contained in:
@@ -20,7 +20,14 @@ export class Position {
|
||||
description: '用户ID',
|
||||
example: 1,
|
||||
})
|
||||
@Column({ name: 'user_id', type: 'bigint' })
|
||||
@Column({
|
||||
name: 'user_id',
|
||||
type: 'bigint',
|
||||
transformer: {
|
||||
to: (value: number) => value,
|
||||
from: (value: string) => (value ? parseInt(value, 10) : null),
|
||||
},
|
||||
})
|
||||
@Index()
|
||||
userId: number;
|
||||
|
||||
@@ -28,7 +35,14 @@ export class Position {
|
||||
description: '券商ID',
|
||||
example: 1,
|
||||
})
|
||||
@Column({ name: 'broker_id', type: 'bigint' })
|
||||
@Column({
|
||||
name: 'broker_id',
|
||||
type: 'bigint',
|
||||
transformer: {
|
||||
to: (value: number) => value,
|
||||
from: (value: string) => (value ? parseInt(value, 10) : null),
|
||||
},
|
||||
})
|
||||
@Index()
|
||||
brokerId: number;
|
||||
|
||||
@@ -80,6 +94,10 @@ export class Position {
|
||||
precision: 18,
|
||||
scale: 4,
|
||||
default: 0,
|
||||
transformer: {
|
||||
to: (value: number) => value,
|
||||
from: (value: string) => (value ? parseFloat(value) : 0),
|
||||
},
|
||||
})
|
||||
shares: number;
|
||||
|
||||
@@ -92,6 +110,10 @@ export class Position {
|
||||
type: 'decimal',
|
||||
precision: 18,
|
||||
scale: 4,
|
||||
transformer: {
|
||||
to: (value: number) => value,
|
||||
from: (value: string) => (value ? parseFloat(value) : null),
|
||||
},
|
||||
})
|
||||
costPrice: number;
|
||||
|
||||
@@ -105,9 +127,30 @@ export class Position {
|
||||
precision: 18,
|
||||
scale: 4,
|
||||
nullable: true,
|
||||
transformer: {
|
||||
to: (value: number | undefined) => value,
|
||||
from: (value: string | null) => (value ? parseFloat(value) : null),
|
||||
},
|
||||
})
|
||||
currentPrice?: number;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description: '上一次的价格(用于对比显示红绿色)',
|
||||
example: 1800.0,
|
||||
})
|
||||
@Column({
|
||||
name: 'previous_price',
|
||||
type: 'decimal',
|
||||
precision: 18,
|
||||
scale: 4,
|
||||
nullable: true,
|
||||
transformer: {
|
||||
to: (value: number | undefined) => value,
|
||||
from: (value: string | null) => (value ? parseFloat(value) : null),
|
||||
},
|
||||
})
|
||||
previousPrice?: number;
|
||||
|
||||
@ApiProperty({
|
||||
description: '货币类型',
|
||||
example: 'CNY',
|
||||
@@ -133,6 +176,10 @@ export class Position {
|
||||
precision: 10,
|
||||
scale: 6,
|
||||
default: 1,
|
||||
transformer: {
|
||||
to: (value: number | undefined) => value,
|
||||
from: (value: string | null) => (value ? parseFloat(value) : 1),
|
||||
},
|
||||
})
|
||||
exchangeRate?: number;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user