新增用户管理/角色管理/菜单管理功能,修复创作流水线研究脚本
- 用户管理:新增编辑弹窗(修改用户名/角色/密码),增加组织/创建时间/最后登录列 - 角色管理:新增 Role 模型 + CRUD API,admin.html 新增角色管理 tab - 菜单管理:新增 Menu 模型 + CRUD API,导航栏从 API 动态加载菜单项 - 个人中心:右上角下拉菜单(个人信息/修改密码/退出),新增修改密码 API - 种子数据:initial_data.py 自动创建默认角色(admin/editor)和默认菜单(7项) - 修复 research.py 缺少 enrich_topic_research 函数导致导入失败 - 修复 db_helper.py 中 generated_at 条件导致重创作不更新时间戳 - admin.html 操作列加宽防止按钮换行,平台配置增加删除按钮 - articles.html 预览弹窗加 lock-scroll=false 防止页面尺寸跳动
This commit is contained in:
@@ -57,6 +57,54 @@ class User(Base):
|
||||
}
|
||||
|
||||
|
||||
class Role(Base):
|
||||
__tablename__ = "roles"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True, autoincrement=True)
|
||||
name = Column(String, unique=True, nullable=False)
|
||||
description = Column(String, default="")
|
||||
is_system = Column(Boolean, default=False)
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
"id": self.id,
|
||||
"name": self.name,
|
||||
"description": self.description,
|
||||
"is_system": self.is_system,
|
||||
"created_at": self.created_at.isoformat() if self.created_at else None
|
||||
}
|
||||
|
||||
|
||||
class Menu(Base):
|
||||
__tablename__ = "menus"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True, autoincrement=True)
|
||||
parent_id = Column(Integer, ForeignKey("menus.id"), nullable=True)
|
||||
name = Column(String, nullable=False)
|
||||
path = Column(String, nullable=False)
|
||||
icon = Column(String, default="")
|
||||
sort_order = Column(Integer, default=0)
|
||||
roles = Column(JSON, default=list)
|
||||
is_active = Column(Boolean, default=True)
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
parent = relationship("Menu", remote_side=[id], backref="children")
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
"id": self.id,
|
||||
"parent_id": self.parent_id,
|
||||
"name": self.name,
|
||||
"path": self.path,
|
||||
"icon": self.icon,
|
||||
"sort_order": self.sort_order,
|
||||
"roles": self.roles or [],
|
||||
"is_active": self.is_active,
|
||||
"created_at": self.created_at.isoformat() if self.created_at else None
|
||||
}
|
||||
|
||||
|
||||
class TopicField(Base):
|
||||
__tablename__ = "topic_fields"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user