сделал модели табличек

This commit is contained in:
Андрей Дувакин 2024-10-03 19:21:10 +05:00
parent 706046867e
commit bbca53c89c
10 changed files with 194 additions and 1 deletions

View File

@ -1,6 +1,6 @@
<mxfile host="Electron" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/24.7.8 Chrome/128.0.6613.36 Electron/32.0.1 Safari/537.36" version="24.7.8">
<diagram name="Page-1" id="mP2IPReIOeFjsobHqe8U">
<mxGraphModel dx="3585" dy="2075" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="2336" pageHeight="1654" math="0" shadow="0">
<mxGraphModel dx="598" dy="346" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="2336" pageHeight="1654" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
@ -498,6 +498,35 @@
<mxCell id="vXrQV9W24_iiTXsCYrPu-153" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=1;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="vXrQV9W24_iiTXsCYrPu-135" target="vXrQV9W24_iiTXsCYrPu-130">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="vXrQV9W24_iiTXsCYrPu-154" value="statuses" style="shape=table;startSize=30;container=1;collapsible=1;childLayout=tableLayout;fixedRows=1;rowLines=0;fontStyle=1;align=center;resizeLast=1;html=1;" vertex="1" parent="1">
<mxGeometry x="1480" y="750" width="180" height="90" as="geometry" />
</mxCell>
<mxCell id="vXrQV9W24_iiTXsCYrPu-155" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=1;" vertex="1" parent="vXrQV9W24_iiTXsCYrPu-154">
<mxGeometry y="30" width="180" height="30" as="geometry" />
</mxCell>
<mxCell id="vXrQV9W24_iiTXsCYrPu-156" value="PK" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;fontStyle=1;overflow=hidden;whiteSpace=wrap;html=1;" vertex="1" parent="vXrQV9W24_iiTXsCYrPu-155">
<mxGeometry width="30" height="30" as="geometry">
<mxRectangle width="30" height="30" as="alternateBounds" />
</mxGeometry>
</mxCell>
<mxCell id="vXrQV9W24_iiTXsCYrPu-157" value="id" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;fontStyle=5;overflow=hidden;whiteSpace=wrap;html=1;" vertex="1" parent="vXrQV9W24_iiTXsCYrPu-155">
<mxGeometry x="30" width="150" height="30" as="geometry">
<mxRectangle width="150" height="30" as="alternateBounds" />
</mxGeometry>
</mxCell>
<mxCell id="vXrQV9W24_iiTXsCYrPu-158" value="" style="shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;top=0;left=0;right=0;bottom=0;" vertex="1" parent="vXrQV9W24_iiTXsCYrPu-154">
<mxGeometry y="60" width="180" height="30" as="geometry" />
</mxCell>
<mxCell id="vXrQV9W24_iiTXsCYrPu-159" value="" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;editable=1;overflow=hidden;whiteSpace=wrap;html=1;" vertex="1" parent="vXrQV9W24_iiTXsCYrPu-158">
<mxGeometry width="30" height="30" as="geometry">
<mxRectangle width="30" height="30" as="alternateBounds" />
</mxGeometry>
</mxCell>
<mxCell id="vXrQV9W24_iiTXsCYrPu-160" value="name" style="shape=partialRectangle;connectable=0;fillColor=none;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;overflow=hidden;whiteSpace=wrap;html=1;" vertex="1" parent="vXrQV9W24_iiTXsCYrPu-158">
<mxGeometry x="30" width="150" height="30" as="geometry">
<mxRectangle width="150" height="30" as="alternateBounds" />
</mxGeometry>
</mxCell>
</root>
</mxGraphModel>
</diagram>

View File

@ -0,0 +1,18 @@
from sqlalchemy import Column, Integer, VARCHAR, Float
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
base = declarative_base()
class Accessories(base):
__tablename__ = 'accessories'
id = Column(Integer, primary_key=True, autoincrement=True)
name = Column(VARCHAR(100), nullable=False)
width = Column(Float)
height = Column(Float)
length = Column(Float)
weight = Column(Float)
storage_accessories = relationship('StorageAccessories', back_populates='accessories')

View File

@ -0,0 +1,18 @@
from sqlalchemy import Column, Integer, DateTime, ForeignKey
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
base = declarative_base()
class Delivery(base):
__tablename__ = 'deliveries'
id = Column(Integer, primary_key=True, autoincrement=True)
count = Column(Integer, nullable=False)
storage_accessories_id = Column(Integer, ForeignKey('storage_accessories.id'))
step_id = Column(Integer, ForeignKey('steps.id'))
storage_accessories = relationship('StorageAccessories', back_populates='delivery')
step = relationship('Step', back_populates='delivery')

View File

@ -0,0 +1,18 @@
from sqlalchemy import Column, Integer, DateTime, ForeignKey
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
base = declarative_base()
class Order(base):
__tablename__ = 'orders'
id = Column(Integer, primary_key=True, autoincrement=True)
order_datetime = Column(DateTime, nullable=False)
user_id = Column(Integer, ForeignKey('users.id'))
status_id = Column(Integer, ForeignKey('statuses.id'))
user = relationship('User', back_populates='orders')
status = relationship('Status', back_populates='orders')

View File

@ -0,0 +1,14 @@
from sqlalchemy import Column, Integer, VARCHAR
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
base = declarative_base()
class Role(base):
__tablename__ = 'roles'
id = Column(Integer, primary_key=True, autoincrement=True)
name = Column(VARCHAR(100), nullable=False)
users = relationship('User', back_populates='role')

View File

@ -0,0 +1,15 @@
from sqlalchemy import Column, Integer, VARCHAR
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
base = declarative_base()
class Status(base):
__tablename__ = 'statuses'
id = Column(Integer, primary_key=True, autoincrement=True)
name = Column(VARCHAR(100), nullable=False)
orders = relationship('Order', back_populates='status')
steps = relationship('Step', back_populates='status')

View File

@ -0,0 +1,21 @@
from sqlalchemy import Column, Integer, DateTime, ForeignKey
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
base = declarative_base()
class Step(base):
__tablename__ = 'steps'
id = Column(Integer, primary_key=True, autoincrement=True)
start_deadline = Column(DateTime, nullable=False)
finish_deadline = Column(DateTime, nullable=False)
order_id = Column(Integer, ForeignKey('orders.id'))
status_id = Column(Integer, ForeignKey('statuses.id'))
order = relationship('Order', back_populates='steps')
status = relationship('Status', back_populates='steps')
deliveries = relationship('Delivery', back_populates='step')

View File

@ -0,0 +1,22 @@
from sqlalchemy import Column, Integer, DateTime, ForeignKey
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
base = declarative_base()
class StorageAccessories(base):
__tablename__ = 'storage_accessories'
id = Column(Integer, primary_key=True, autoincrement=True)
current_count = Column(Integer, nullable=False)
change_datetime = Column(DateTime)
storage_id = Column(Integer, ForeignKey('storages.id'))
accessories_id = Column(Integer, ForeignKey('accessories'))
storage = relationship('Storage', back_populates='storage_accessories')
accessories = relationship('Accessories', back_populates='storage_accessories')
deliveries = relationship('Delivery', back_populates='storage_accessories')

View File

@ -0,0 +1,16 @@
from sqlalchemy import Column, Integer, DateTime, ForeignKey, VARCHAR, Float
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
base = declarative_base()
class Storage(base):
__tablename__ = 'storages'
id = Column(Integer, primary_key=True, autoincrement=True)
name = Column(VARCHAR(100), nullable=False)
x_coordinate = Column(Float, nullable=False)
y_coordinate = Column(Float, nullable=False)
storage_accessories = relationship('StorageAccessories', back_populates='storage')

View File

@ -0,0 +1,22 @@
from sqlalchemy import Column, Integer, VARCHAR, ForeignKey
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
base = declarative_base()
class User(base):
__tablename__ = 'users'
id = Column(Integer, primary_key=True, autoincrement=True)
first_name = Column(VARCHAR(100), nullable=False)
last_name = Column(VARCHAR(100), nullable=False)
login = Column(VARCHAR(150), nullable=False)
password = Column(VARCHAR(500), nullable=False)
role_id = Column(Integer, ForeignKey('roles.id'))
role = relationship('Role', back_populates='users')
orders = relationship('Order', back_populates='user')