Files
FastapiAdmin/backend/app/api/v1/models/system/menu_model.py
T
zhangtao 00b7fe54ba feat: 添加任务管理和字典管理功能,优化系统配置和代码结构
本次提交主要包含以下变更:
1. 新增任务管理模块,支持定时任务的创建、更新、删除和状态管理
2. 新增字典管理模块,用于维护系统中常用的固定数据
3. 优化系统配置,移除Celery,改用APScheduler进行任务调度
4. 修复部分前端组件的样式问题,统一输入框宽度
5. 更新文档和相关图片资源,完善系统功能描述

这些变更旨在增强系统的可维护性和功能性,提供更灵活的任务调度机制和更便捷的字典数据管理方式。
2025-04-12 06:43:27 +08:00

60 lines
2.3 KiB
Python

# -*- coding: utf-8 -*-
from datetime import datetime
from sqlalchemy import Boolean, Column, String, Integer, ForeignKey, Text, DateTime
from sqlalchemy.orm import relationship
from app.core.base_model import ModelBase
class MenuModel(ModelBase):
"""
菜单表 - 用于存储系统菜单信息
type 菜单类型说明:
1: 目录
2: 菜单
3: 按钮/权限
"""
__tablename__ = "system_menu"
__table_args__ = ({'comment': '菜单表'})
# 基础字段
id = Column(Integer, primary_key=True, autoincrement=True, comment='主键ID')
name = Column(String(50), nullable=False, comment="菜单名称", unique=True)
type = Column(Integer, nullable=False, default=2, comment="菜单类型")
order = Column(Integer, nullable=False, default=1, comment="显示排序")
# 权限相关
permission = Column(String(100), nullable=True, comment="权限标识(如:system:user:list)")
available = Column(Boolean, default=True, nullable=False, comment="是否启用(True:启用 False:禁用)")
# 前端路由相关
icon = Column(String(50), nullable=True, comment="菜单图标")
route_name = Column(String(100), nullable=True, comment="路由名称")
route_path = Column(String(200), nullable=True, comment="路由路径")
component_path = Column(String(200), nullable=True, comment="组件路径")
redirect = Column(String(200), nullable=True, comment="重定向地址")
hidden = Column(Boolean, default=False, nullable=False, comment="是否隐藏(True:隐藏 False:显示)")
cache = Column(Boolean, default=True, nullable=False, comment="是否缓存(True:是 False:否)")
# 层级关系
parent_id = Column(
Integer,
ForeignKey("system_menu.id", ondelete="CASCADE", onupdate="CASCADE"),
nullable=True,
index=True,
comment="父级菜单ID"
)
parent = relationship(
"MenuModel",
cascade='all, delete-orphan',
primaryjoin="MenuModel.parent_id == MenuModel.id",
uselist=False
)
# 审计字段
description = Column(Text, nullable=True, comment="备注说明")
created_at = Column(DateTime, default=datetime.now, comment='创建时间')
updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')