26 lines
868 B
Python
26 lines
868 B
Python
|
from tortoise import Model, fields
|
||
|
from tortoise.contrib.pydantic import pydantic_model_creator
|
||
|
|
||
|
from src.models import with_table_name, StockType
|
||
|
|
||
|
|
||
|
class StockDetails(Model):
|
||
|
"""
|
||
|
股票相关信息
|
||
|
"""
|
||
|
id = fields.IntField(pk=True, description="主键")
|
||
|
stock_code = fields.CharField(max_length=30, description="股票代码")
|
||
|
stock_name = fields.CharField(max_length=30, null=True, description="股票名称")
|
||
|
type = fields.CharEnumField(StockType, null=True, description="类型")
|
||
|
stock_pinyin = fields.CharField(max_length=30, description="股票拼音")
|
||
|
latest_price = fields.FloatField(null=True, description="最新价")
|
||
|
rise_fall = fields.FloatField(null=True, description="跌涨幅")
|
||
|
|
||
|
class Meta:
|
||
|
table = with_table_name("stock_details")
|
||
|
|
||
|
|
||
|
StockDetailsResponse = pydantic_model_creator(
|
||
|
StockDetails
|
||
|
)
|