- 用户表扩展:MES/WMS user 实体新增字段,新增 active_token 迁移 SQL(2026-11-11) - 会话机制:MES 新增 session_guard,重构 token/auth/jwt/perm 与路由;WMS/工作站同步令牌续签与鉴权 - 看板(board):调整 MES 看板产线/生产/侧栏/仓库组件及样式;WMS 看板展示页同步调整 - 工位终端后端:完善报警流、绑定、PLC 对账、拧紧、proxy、上报、站点告警/操作等 handler,补充 mes client/store - 工位终端前端:登录/主界面/各操作面板调整,新增滚动分页与多语言 yaml 文案,刷新构建产物 - MES 业务:新增流程链 logic,调整待审核/产能支撑/产品工艺/设置页、PLC 监控与帮助文档,刷新构建产物 - 更新问题记录文档
63 lines
3.6 KiB
Go
63 lines
3.6 KiB
Go
package handler
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"bj_power_mes/internal/svc"
|
|
|
|
"github.com/zeromicro/go-zero/rest"
|
|
)
|
|
|
|
// RegisterRoutes 注册鉴权 + 系统管理(用户/角色/权限)路由
|
|
func RegisterRoutes(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|
// 免鉴权
|
|
server.AddRoutes([]rest.Route{
|
|
{Method: http.MethodPost, Path: "/login", Handler: LoginHandler(serverCtx)},
|
|
}, rest.WithPrefix("/api/v1"), rest.WithMaxBytes(serverCtx.Config.Upload.MaxMB<<20))
|
|
|
|
// JWT 保护:用户信息 + 用户/角色/权限 管理
|
|
jwtAdmin := []rest.Route{
|
|
{Method: http.MethodGet, Path: "/userinfo", Handler: UserInfoHandler(serverCtx)},
|
|
// /seed 已从对外路由摘除:seed 是运维/初始化工具接口,非业务接口,
|
|
// 仅通过 CLI 子命令 `bj_power_mes.exe seed`(带管理员密码门 adminGate)执行,避免任意登录用户提权。
|
|
{Method: http.MethodPost, Path: "/user/change-password", Handler: ChangePasswordHandler(serverCtx)},
|
|
{Method: http.MethodPost, Path: "/logout", Handler: LogoutHandler(serverCtx)},
|
|
|
|
{Method: http.MethodGet, Path: "/users", Handler: ListUsersHandler(serverCtx)},
|
|
{Method: http.MethodPost, Path: "/users", Handler: CreateUserHandler(serverCtx)},
|
|
{Method: http.MethodPut, Path: "/users", Handler: UpdateUserHandler(serverCtx)},
|
|
{Method: http.MethodDelete, Path: "/users/:id", Handler: DeleteUserHandler(serverCtx)},
|
|
|
|
{Method: http.MethodGet, Path: "/roles", Handler: ListRolesHandler(serverCtx)},
|
|
{Method: http.MethodPost, Path: "/roles", Handler: CreateRoleHandler(serverCtx)},
|
|
{Method: http.MethodPut, Path: "/roles", Handler: UpdateRoleHandler(serverCtx)},
|
|
{Method: http.MethodDelete, Path: "/roles/:id", Handler: DeleteRoleHandler(serverCtx)},
|
|
|
|
{Method: http.MethodGet, Path: "/permissions", Handler: ListPermissionsHandler(serverCtx)},
|
|
{Method: http.MethodPost, Path: "/permissions", Handler: CreatePermissionHandler(serverCtx)},
|
|
{Method: http.MethodPut, Path: "/permissions", Handler: UpdatePermissionHandler(serverCtx)},
|
|
{Method: http.MethodDelete, Path: "/permissions/:id", Handler: DeletePermissionHandler(serverCtx)},
|
|
|
|
// 备份到外部存储(U盘/移动硬盘)+ 按时间窗物理清理
|
|
{Method: http.MethodGet, Path: "/backup/items", Handler: BackupItemsHandler(serverCtx)},
|
|
{Method: http.MethodPost, Path: "/backup/start", Handler: BackupStartHandler(serverCtx)},
|
|
{Method: http.MethodGet, Path: "/backup/progress", Handler: BackupProgressHandler(serverCtx)},
|
|
{Method: http.MethodPost, Path: "/cleanup/check", Handler: CleanupCheckHandler(serverCtx)},
|
|
{Method: http.MethodPost, Path: "/cleanup/start", Handler: CleanupStartHandler(serverCtx)},
|
|
{Method: http.MethodGet, Path: "/cleanup/progress", Handler: CleanupProgressHandler(serverCtx)},
|
|
// 数据归档增强:目录选择器 / 提醒 / 预览 / 历史
|
|
{Method: http.MethodGet, Path: "/backup/drives", Handler: BackupDrivesHandler(serverCtx)},
|
|
{Method: http.MethodGet, Path: "/backup/listdir", Handler: BackupListDirHandler(serverCtx)},
|
|
{Method: http.MethodGet, Path: "/backup/reminder", Handler: BackupReminderHandler(serverCtx)},
|
|
{Method: http.MethodPost, Path: "/cleanup/preview", Handler: CleanupPreviewHandler(serverCtx)},
|
|
{Method: http.MethodGet, Path: "/backup/records", Handler: BackupRecordsHandler(serverCtx)},
|
|
}
|
|
server.AddRoutes(
|
|
// SessionGuard:后台同账号互踢(2026-11-11);permissionGuard:按钮级权限兜底
|
|
rest.WithMiddlewares([]rest.Middleware{SessionGuard(serverCtx), permissionGuard(serverCtx)}, jwtAdmin...),
|
|
rest.WithPrefix("/api/v1"),
|
|
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
|
rest.WithMaxBytes(serverCtx.Config.Upload.MaxMB<<20),
|
|
)
|
|
}
|