feat: node if, node start, node link
This commit is contained in:
6
orm/schemas/__init__.py
Normal file
6
orm/schemas/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
||||
# Экспорты для базовых схем
|
||||
from .base import Base
|
||||
|
||||
__all__ = [
|
||||
"Base",
|
||||
]
|
11
orm/schemas/base.py
Normal file
11
orm/schemas/base.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
from pydantic.alias_generators import to_camel
|
||||
|
||||
|
||||
|
||||
class Base(BaseModel):
|
||||
model_config = ConfigDict(
|
||||
from_attributes=True,
|
||||
alias_generator=to_camel,
|
||||
populate_by_name=True,
|
||||
)
|
0
orm/schemas/process/__init__.py
Normal file
0
orm/schemas/process/__init__.py
Normal file
18
orm/schemas/process/node_link.py
Normal file
18
orm/schemas/process/node_link.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from pydantic import Field
|
||||
from typing import Dict, Any
|
||||
from datetime import datetime
|
||||
from enum import Enum
|
||||
|
||||
from orm.schemas.base import Base
|
||||
from orm.tables.process import NodeLinkStatus
|
||||
|
||||
|
||||
class NodeLink(Base):
|
||||
id: int
|
||||
link_name: str = Field(..., max_length=20)
|
||||
node_id: int
|
||||
next_node_id: int
|
||||
settings: Dict[str, Any]
|
||||
creator_id: int
|
||||
created_at: datetime
|
||||
status: NodeLinkStatus
|
19
orm/schemas/process/process_schema.py
Normal file
19
orm/schemas/process/process_schema.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from pydantic import Field
|
||||
from typing import Dict, Any
|
||||
from datetime import datetime
|
||||
from enum import Enum
|
||||
|
||||
from orm.schemas.base import Base
|
||||
from orm.tables.process import ProcessStatus
|
||||
|
||||
|
||||
|
||||
class ProcessSchema(Base):
|
||||
id: int
|
||||
title: str = Field(..., max_length=100)
|
||||
description: str
|
||||
owner_id: int
|
||||
creator_id: int
|
||||
created_at: datetime
|
||||
settings: Dict[str, Any]
|
||||
status: ProcessStatus
|
13
orm/schemas/process/process_version_archive.py
Normal file
13
orm/schemas/process/process_version_archive.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from typing import Dict, Any
|
||||
from datetime import datetime
|
||||
|
||||
from orm.schemas.base import Base
|
||||
|
||||
|
||||
class ProcessStatusSchema(Base):
|
||||
id: int
|
||||
version: int
|
||||
snapshot: Dict[str, Any]
|
||||
owner_id: int
|
||||
created_at: datetime
|
||||
is_last: int
|
16
orm/schemas/process/ps_node.py
Normal file
16
orm/schemas/process/ps_node.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from datetime import datetime
|
||||
from typing import Dict, Any
|
||||
from enum import Enum
|
||||
|
||||
from orm.schemas.base import Base
|
||||
from orm.tables.process import NodeStatus,NodeType
|
||||
|
||||
|
||||
class Ps_Node(Base):
|
||||
id: int
|
||||
ps_id: int
|
||||
node_type: NodeType
|
||||
settings: dict
|
||||
creator_id: Dict[str, Any]
|
||||
created_at: datetime
|
||||
status: NodeStatus
|
@@ -33,7 +33,8 @@ process_schema_table = Table(
|
||||
Column("title", String(100), nullable=False),
|
||||
Column("description", Text, nullable=False),
|
||||
Column("owner_id", UnsignedInt, ForeignKey("account.id"), nullable=False),
|
||||
Column("creator_id", UnsignedInt, ForeignKey("account.id"), nullable=False),
|
||||
Column("creator_id", UnsignedInt, ForeignKey(
|
||||
"account.id"), nullable=False),
|
||||
Column("created_at", DateTime(timezone=True), server_default=func.now()),
|
||||
Column("settings", JSON, default={}),
|
||||
Column("status", SQLAEnum(ProcessStatus), nullable=False),
|
||||
@@ -47,7 +48,8 @@ process_version_archive_table = Table(
|
||||
"process_version_archive",
|
||||
metadata,
|
||||
Column("id", UnsignedInt, autoincrement=True, nullable=False),
|
||||
Column("ps_id", UnsignedInt, ForeignKey("process_schema.id"), nullable=False),
|
||||
Column("ps_id", UnsignedInt, ForeignKey(
|
||||
"process_schema.id"), nullable=False),
|
||||
Column("version", UnsignedInt, default=1, nullable=False),
|
||||
Column("snapshot", JSON, default={}),
|
||||
Column("owner_id", UnsignedInt, ForeignKey("account.id"), nullable=False),
|
||||
@@ -64,19 +66,21 @@ class NodeStatus(enum.StrEnum):
|
||||
|
||||
|
||||
class NodeType(Enum):
|
||||
TYPE1 = "Type1"
|
||||
TYPE2 = "Type2"
|
||||
TYPE3 = "Type3"
|
||||
LISTEN = "LISTEN"
|
||||
IF = "IF"
|
||||
|
||||
|
||||
ps_node_table = Table(
|
||||
"ps_node",
|
||||
metadata,
|
||||
Column("id", UnsignedInt, autoincrement=True, primary_key=True, nullable=False),
|
||||
Column("ps_id", UnsignedInt, ForeignKey("process_schema.id"), nullable=False),
|
||||
Column("id", UnsignedInt, autoincrement=True,
|
||||
primary_key=True, nullable=False),
|
||||
Column("ps_id", UnsignedInt, ForeignKey(
|
||||
"process_schema.id"), nullable=False),
|
||||
Column("node_type", SQLAEnum(NodeType), nullable=False),
|
||||
Column("settings", JSON, default={}),
|
||||
Column("creator_id", UnsignedInt, ForeignKey("account.id"), nullable=False),
|
||||
Column("creator_id", UnsignedInt, ForeignKey(
|
||||
"account.id"), nullable=False),
|
||||
Column("created_at", DateTime(timezone=True), server_default=func.now()),
|
||||
Column("status", SQLAEnum(NodeStatus), nullable=False),
|
||||
Index("idx_ps_id", "ps_id"),
|
||||
@@ -93,12 +97,15 @@ class NodeLinkStatus(enum.StrEnum):
|
||||
node_link_table = Table(
|
||||
"node_link",
|
||||
metadata,
|
||||
Column("id", UnsignedInt, autoincrement=True, primary_key=True, nullable=False),
|
||||
Column("id", UnsignedInt, autoincrement=True,
|
||||
primary_key=True, nullable=False),
|
||||
Column("link_name", String(20), nullable=False),
|
||||
Column("node_id", UnsignedInt, ForeignKey("ps_node.id"), nullable=False),
|
||||
Column("next_node_id", UnsignedInt, ForeignKey("ps_node.id"), nullable=False),
|
||||
Column("next_node_id", UnsignedInt, ForeignKey(
|
||||
"ps_node.id"), nullable=False),
|
||||
Column("settings", JSON, default={}),
|
||||
Column("creator_id", UnsignedInt, ForeignKey("account.id"), nullable=False),
|
||||
Column("creator_id", UnsignedInt, ForeignKey(
|
||||
"account.id"), nullable=False),
|
||||
Column("created_at", DateTime(timezone=True), server_default=func.now()),
|
||||
Column("status", SQLAEnum(NodeLinkStatus), nullable=False),
|
||||
Index("idx_node_id", "node_id"),
|
||||
|
Reference in New Issue
Block a user