Files
bj_power/bj_power_workstation/internal/handler/routes.go
T
SunYF a2afd2f6dc feat: 五项目业务实现并对接完成
- MES(B): 工单/BOM/备料/工序字典/PLC下发/拧紧/扫码报工/半成品/AGV/追溯逻辑,WMS与海康RCS客户端,看板Redis缓存API(概览/设备/进度/报警/趋势)+SSE
- WMS(C): JWT滑动续签、Excel导入、盘点、内部API、种子数据、独立Postgres配置
- WMS客户端(E): Go网关8891反向代理+内嵌Vue3十页
- 工位终端(D): SQLite本地缓存+模拟拧紧源+内嵌Vue3页面
- Dashboard(A): 看板数据改接MES内部缓存API,SSE实时刷新+vite代理
- 清理各项目球形磨遗留代码,新增部署手册.md
2026-08-27 19:50:57 +08:00

41 lines
1.8 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package handler
import (
"net/http"
"bj_power_workstation/internal/auth"
"bj_power_workstation/internal/svc"
"github.com/zeromicro/go-zero/rest"
)
func RegisterHandlers(server *rest.Server, ctx *svc.ServiceContext) {
// 免鉴权:健康检查 / 登录
server.AddRoutes(
[]rest.Route{
{Method: http.MethodGet, Path: "/api/health", Handler: healthHandler(ctx)},
{Method: http.MethodPost, Path: "/api/auth/login", Handler: loginHandler(ctx)},
// 前端静态托管(auth.Interceptor 对非 /api/、/pdfopen/ 路径直接放行)
{Method: http.MethodGet, Path: "/", Handler: indexHandler(ctx.WebFS)},
{Method: http.MethodGet, Path: "/assets/:file", Handler: assetHandler(ctx.WebFS)},
},
)
// 登录鉴权中间件:白名单 /api/health、/api/auth/login、/pdfopen/*;其余 /api/* 需 JWT
server.Use(auth.Interceptor(ctx.Config.Auth.AccessSecret, ctx.Config.Auth.AccessExpire))
// 业务接口(均需登录 JWT,响应统一 {code,message,data}PDF 代理除外——原样转发文件流)
server.AddRoutes(
[]rest.Route{
{Method: http.MethodGet, Path: "/api/task/current", Handler: taskCurrentHandler(ctx.Mes)},
{Method: http.MethodGet, Path: "/api/pdf", Handler: pdfQueryHandler(ctx.Mes)},
{Method: http.MethodGet, Path: "/pdfopen/:name", Handler: pdfOpenHandler(ctx.Mes)},
{Method: http.MethodGet, Path: "/api/tightening/list", Handler: tighteningListHandler(ctx)},
{Method: http.MethodPost, Path: "/api/report/process-done", Handler: processDoneHandler(ctx)},
{Method: http.MethodPost, Path: "/api/report/temp-store", Handler: tempStoreHandler(ctx)},
{Method: http.MethodPost, Path: "/api/sync/flush", Handler: syncFlushHandler(ctx)},
{Method: http.MethodGet, Path: "/api/sync/stats", Handler: syncStatsHandler(ctx)},
},
)
}