From f6229182a3166dc338dd662299884521968b571c Mon Sep 17 00:00:00 2001 From: huangzhuang_3rd Date: Wed, 12 Aug 2026 13:30:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20AI=20Worker=20=E5=B9=B3=E5=8F=B0=20MVP?= =?UTF-8?q?=20v1.0.0=20-=20=E5=A4=9A=E7=A7=9F=E6=88=B7/=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E7=AE=A1=E7=90=86/AI=20Worker/=E4=BB=BB=E5=8A=A1=E7=BC=96?= =?UTF-8?q?=E6=8E=92/HITL=E5=AE=A1=E6=A0=B8/=E6=88=90=E6=9C=AC=E6=B2=BB?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/models/user.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 backend/app/models/user.py diff --git a/backend/app/models/user.py b/backend/app/models/user.py new file mode 100644 index 0000000..3e35f82 --- /dev/null +++ b/backend/app/models/user.py @@ -0,0 +1,33 @@ +"""User model - represents both humans and AI worker accounts.""" +from sqlalchemy import Column, String, Boolean, Integer, Text, ForeignKey +from app.models.base import Base, TimestampMixin, TenantMixin + + +class User(Base, TimestampMixin, TenantMixin): + """A user can be a human or an AI worker proxy. + + - Humans: have email + password, role determines permissions + - AI: linked to AIWorker via worker_id, role is typically 'worker' + + Roles: super_admin, tenant_admin, project_manager, reviewer, worker + """ + __tablename__ = "users" + + id = Column(Integer, primary_key=True, autoincrement=True) + email = Column(String(255), nullable=False, index=True) + username = Column(String(100), nullable=False) + hashed_password = Column(String(255), nullable=True) # null for AI users + role = Column(String(50), nullable=False, default="worker") + + # "human" or "ai" + user_type = Column(String(20), nullable=False, default="human") + + # If AI user, link to the AIWorker record + worker_id = Column(Integer, ForeignKey("ai_workers.id"), nullable=True) + + is_active = Column(Boolean, default=True, nullable=False) + avatar = Column(String(500), nullable=True) + phone = Column(String(50), nullable=True) + + def __repr__(self): + return f""