初始化
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
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)},
|
||||
},
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user