后端开发完成
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
from app.models.user import User
|
||||
from app.models.project import Project
|
||||
from app.models.project_history import ProjectHistory
|
||||
|
||||
__all__ = ["User", "Project", "ProjectHistory"]
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,20 @@
|
||||
from sqlalchemy import Column, Integer, String, Text, DateTime, ForeignKey
|
||||
from sqlalchemy.sql import func
|
||||
from app.database.database import Base
|
||||
|
||||
|
||||
class Project(Base):
|
||||
"""项目模型"""
|
||||
__tablename__ = "projects"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
name = Column(String(100), nullable=False)
|
||||
description = Column(Text)
|
||||
created_by = Column(Integer, ForeignKey("users.id"), nullable=False)
|
||||
department = Column(String(50), nullable=False)
|
||||
budget = Column(Integer)
|
||||
start_date = Column(DateTime(timezone=True))
|
||||
end_date = Column(DateTime(timezone=True))
|
||||
status = Column(String(20), default="pending")
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
||||
@@ -0,0 +1,17 @@
|
||||
from sqlalchemy import Column, Integer, String, Text, DateTime, ForeignKey
|
||||
from sqlalchemy.sql import func
|
||||
from app.database.database import Base
|
||||
|
||||
|
||||
class ProjectHistory(Base):
|
||||
"""项目历史记录模型"""
|
||||
__tablename__ = "project_histories"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
project_id = Column(Integer, ForeignKey("projects.id"), nullable=False)
|
||||
changed_by = Column(Integer, ForeignKey("users.id"), nullable=False)
|
||||
change_field = Column(String(100), nullable=False)
|
||||
old_value = Column(Text)
|
||||
new_value = Column(Text)
|
||||
change_description = Column(Text)
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
@@ -0,0 +1,16 @@
|
||||
from sqlalchemy import Column, Integer, String, DateTime
|
||||
from sqlalchemy.sql import func
|
||||
from app.database.database import Base
|
||||
|
||||
|
||||
class User(Base):
|
||||
"""用户模型"""
|
||||
__tablename__ = "users"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
username = Column(String(50), unique=True, index=True, nullable=False)
|
||||
password = Column(String(100), nullable=False)
|
||||
department = Column(String(50), nullable=False)
|
||||
role = Column(String(20), nullable=False) # admin, marketing, other
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
||||
Reference in New Issue
Block a user