Commit b51127a4 authored by uuo00_n's avatar uuo00_n

refactor(api): 移除后端仪表盘接口,改由前端实现

后端不再提供仪表盘接口,相关功能由前端直接对接数据源或业务接口完成。移除相关路由和模块文件。
parent d21ebdb3
......@@ -196,9 +196,8 @@ curl -X POST "http://localhost:8000/api/v1/admin/sensitive-words/import" \
# words.json 示例:[ {"word":"赌博","category":"违法活动","subcategory":"赌博","severity":3} ]
```
### 仪表盘(/dashboard)
- GET `/api/v1/dashboard/summary` 根据角色等级与版别返回个性化首页模块,最低 1 级即可访问;随角色等级与版别增加返回更多模块。
- 也挂载了版别限制依赖(require_edition_for_mode),保证仅允许后端设置的版别访问。
### 仪表盘说明
后端不再提供 `/dashboard` 接口,仪表盘由前端实现并直接对接相应数据源或后端业务接口(例如出勤、课表、请假、指示等)。
---
......
from fastapi import APIRouter, Depends
from app.api.deps import require_role, require_edition_for_mode
# 在路由层挂载版别运行模式依赖,保证仅允许后端设置的版别访问
router = APIRouter(dependencies=[Depends(require_edition_for_mode())])
@router.get("/summary")
async def dashboard_summary(current_user: dict = Depends(require_role(1))):
"""
仪表盘概要接口:根据角色等级与版别返回不同的首页信息
- 最低 1 级即可访问,但返回内容随等级与版别递增
- 关键节点:避免多层嵌套,先取必要信息后按条件构造视图
"""
role = current_user.get("role", "user")
level = current_user.get("role_level", 1)
edition = current_user.get("edition", "edu")
# 基础公共信息(所有角色可见)
base = {
"welcome": f"欢迎 {current_user.get('username','')} 登录",
"edition": edition,
"role": role,
"role_level": level,
}
# 教育版视图
if edition == "edu":
if level == 1:
base.update({
"modules": ["今日出勤", "操行与教师意见"],
})
return base
if level == 2:
base.update({
"modules": ["班级出勤率", "课程/地点", "学生请假", "上级指示"],
})
return base
if level == 3:
base.update({
"modules": ["系部教师出勤", "学生考勤", "课堂异常指标", "上级指示"],
})
return base
if level == 4:
base.update({
"modules": ["校园整体安全", "教师出勤率", "资金预算", "部门进度", "本期目标"],
})
return base
# 系统管理员:与业务最高权限分离
base.update({
"modules": ["系统运行", "告警", "运维工具"],
})
return base
# 企业版视图(biz)
if level == 1:
base.update({
"modules": ["今日出勤", "绩效", "上级意见"],
})
return base
if level == 2:
base.update({
"modules": ["小组出勤率", "工单/排班", "请假审批", "负责人指示"],
})
return base
if level == 3:
base.update({
"modules": ["部门出勤", "任务进度", "异常指标", "负责人指示"],
})
return base
if level == 4:
base.update({
"modules": ["企业整体安全", "员工出勤率", "资金预算", "部门进度", "战略目标"],
})
return base
base.update({
"modules": ["系统运行", "告警", "运维工具"],
})
return base
\ No newline at end of file
from fastapi import APIRouter
from app.api.v1 import auth, conversation, admin, dashboard
from app.api.v1 import auth, conversation, admin
api_router = APIRouter()
......@@ -7,4 +7,4 @@ api_router = APIRouter()
api_router.include_router(auth.router, prefix="/auth", tags=["认证"])
api_router.include_router(conversation.router, prefix="/conversations", tags=["对话"])
api_router.include_router(admin.router, prefix="/admin", tags=["管理员"])
api_router.include_router(dashboard.router, prefix="/dashboard", tags=["仪表盘"])
\ No newline at end of file
# 需求变更:移除后端仪表盘路由,仪表盘由前端实现,无需后端接口。
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment