Initial commit: 上传完整代码
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
from sqlalchemy import Column, String, Integer, JSON
|
||||
from sqlalchemy.orm import relationship
|
||||
from .base import BaseModel
|
||||
|
||||
class Interface(BaseModel):
|
||||
__tablename__ = "interfaces"
|
||||
|
||||
name = Column(String, index=True)
|
||||
type = Column(String) # 'CAN' 或 'Powerbus'
|
||||
description = Column(String, nullable=True)
|
||||
port = Column(String, nullable=True)
|
||||
baud_rate = Column(Integer, nullable=True)
|
||||
can_channel = Column(Integer, nullable=True)
|
||||
can_baud_rate = Column(Integer, nullable=True)
|
||||
|
||||
# 关系
|
||||
devices = relationship("Device", back_populates="interface")
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
"id": self.id,
|
||||
"name": self.name,
|
||||
"type": self.type,
|
||||
"description": self.description,
|
||||
"port": self.port,
|
||||
"baud_rate": self.baud_rate,
|
||||
"can_channel": self.can_channel,
|
||||
"can_baud_rate": self.can_baud_rate
|
||||
}
|
||||
Reference in New Issue
Block a user