Browse Source

add model and schemas for space weight

chenhaiyang 4 years ago
parent
commit
1dab57e9ce
2 changed files with 58 additions and 0 deletions
  1. 17 0
      app/models/space/weight.py
  2. 41 0
      app/schemas/sapce_weight.py

+ 17 - 0
app/models/space/weight.py

@@ -0,0 +1,17 @@
+# -*- coding: utf-8 -*-
+
+from sqlalchemy import Column, Float, Integer, String
+
+from app.db.session import Base
+
+
+class VAVRoomWeight(Base):
+    __tablename__ = 'vav_room_weights'
+
+    id = Column(Integer, primary_key=True, index=True)
+    default_weight = Column(Float)
+    project_id = Column(String, index=True, nullable=False)
+    space_id = Column(String, index=True, unique=True, nullable=False)
+    vav_box_id = Column(String, index=True, nullable=False)
+    temporary_weight = Column(Float, default=0.0)
+    temporary_weight_update_time = Column(String, default='20201111110400')

+ 41 - 0
app/schemas/sapce_weight.py

@@ -0,0 +1,41 @@
+# -*- coding: utf-8 -*-
+
+from typing import Optional
+
+from pydantic import BaseModel
+
+
+# Shared properties
+class SpaceWeightBase(BaseModel):
+    project_id: Optional[str] = None
+    space_id: Optional[str] = None
+    vav_box_id: Optional[str] = None
+    default_weight: Optional[float] = 0.0
+
+
+# Properties to receive via API to creation
+class SpaceWeightCreate(SpaceWeightBase):
+    pass
+
+
+# Properties to receive via API on update
+class SpaceWeightUpdate(SpaceWeightBase):
+    temporary_weight: Optional[float] = 0.0
+    temporary_weight_update_time: Optional[str] = None
+
+
+class SpaceWeightInDBBase(SpaceWeightUpdate):
+    id: Optional[int] = None
+
+    class Config:
+        orm_mode = True
+
+
+# Additional properties to return vai API
+class SpaceWeight(SpaceWeightInDBBase):
+    pass
+
+
+# Additional properties stored in DB
+class SpaceWeightInDB(SpaceWeightInDBBase):
+    pass