初始化2

This commit is contained in:
SunYF
2026-08-28 15:06:01 +08:00
parent b34325a16f
commit a9c3fbeb41
537 changed files with 176215 additions and 17 deletions
+133
View File
@@ -0,0 +1,133 @@
package handler
import (
"net/http"
"bj_power_wms/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)},
{Method: http.MethodPost, Path: "/api/auth/register", Handler: registerHandler(ctx)},
},
)
server.Use(authInterceptor(ctx))
// 物料档案
server.AddRoutes(
[]rest.Route{
{Method: http.MethodPost, Path: "/api/material/create", Handler: createMaterialHandler(ctx)},
{Method: http.MethodPost, Path: "/api/material/update", Handler: updateMaterialHandler(ctx)},
{Method: http.MethodGet, Path: "/api/material/query", Handler: queryMaterialsHandler(ctx)},
{Method: http.MethodGet, Path: "/api/material/list", Handler: listMaterialsHandler(ctx)},
{Method: http.MethodGet, Path: "/api/material/detail", Handler: getMaterialHandler(ctx)},
},
)
// 入库
server.AddRoutes(
[]rest.Route{
{Method: http.MethodPost, Path: "/api/inbound/create", Handler: createInboundHandler(ctx)},
{Method: http.MethodGet, Path: "/api/inbound/query", Handler: queryInboundHandler(ctx)},
{Method: http.MethodPost, Path: "/api/inbound/batch-excel", Handler: excelInboundHandler(ctx)},
},
)
// 出库
server.AddRoutes(
[]rest.Route{
{Method: http.MethodPost, Path: "/api/outbound/create", Handler: createOutboundHandler(ctx)},
{Method: http.MethodGet, Path: "/api/outbound/query", Handler: queryOutboundHandler(ctx)},
},
)
// 库存
server.AddRoutes(
[]rest.Route{
{Method: http.MethodGet, Path: "/api/stock/query", Handler: queryStockHandler(ctx)},
{Method: http.MethodPost, Path: "/api/stock/lock", Handler: lockStockHandler(ctx)},
{Method: http.MethodPost, Path: "/api/stock/unlock", Handler: unlockStockHandler(ctx)},
{Method: http.MethodPost, Path: "/api/stock/deduct", Handler: deductStockHandler(ctx)},
{Method: http.MethodPost, Path: "/api/stock/check", Handler: checkStockHandler(ctx)},
},
)
// 检验
server.AddRoutes(
[]rest.Route{
{Method: http.MethodPost, Path: "/api/inspection/create", Handler: createInspectionHandler(ctx)},
{Method: http.MethodPost, Path: "/api/inspection/batch-flip", Handler: batchFlipInspectionHandler(ctx)},
{Method: http.MethodGet, Path: "/api/inspection/query", Handler: queryInspectionHandler(ctx)},
},
)
// 区域
server.AddRoutes(
[]rest.Route{
{Method: http.MethodPost, Path: "/api/zone/create", Handler: createZoneHandler(ctx)},
{Method: http.MethodGet, Path: "/api/zone/list", Handler: listZonesHandler(ctx)},
},
)
// 盘点
server.AddRoutes(
[]rest.Route{
{Method: http.MethodPost, Path: "/api/stocktake/start", Handler: startStocktakeHandler(ctx)},
{Method: http.MethodPost, Path: "/api/stocktake/record", Handler: recordStocktakeHandler(ctx)},
{Method: http.MethodPost, Path: "/api/stocktake/finish", Handler: finishStocktakeHandler(ctx)},
{Method: http.MethodGet, Path: "/api/stocktake/query", Handler: queryStocktakeHandler(ctx)},
},
)
// 半成品
server.AddRoutes(
[]rest.Route{
{Method: http.MethodPost, Path: "/api/semi/inbound", Handler: semiInboundHandler(ctx)},
{Method: http.MethodPost, Path: "/api/semi/outbound", Handler: semiOutboundHandler(ctx)},
{Method: http.MethodGet, Path: "/api/semi/query", Handler: querySemiHandler(ctx)},
},
)
// 包装
server.AddRoutes(
[]rest.Route{
{Method: http.MethodPost, Path: "/api/package/bind", Handler: packageBindHandler(ctx)},
{Method: http.MethodGet, Path: "/api/package/query", Handler: queryPackageHandler(ctx)},
},
)
// 工单物料台账(WMS 侧)
server.AddRoutes(
[]rest.Route{
{Method: http.MethodGet, Path: "/api/ledger/query", Handler: queryLedgerHandler(ctx)},
},
)
// 大屏展示数据(免登录)
server.AddRoutes(
[]rest.Route{
{Method: http.MethodGet, Path: "/api/display/overview", Handler: internalDisplayHandler(ctx)},
},
)
// 项目间内部 APIX-API-TOKEN 写死 token 保护)
// 与 JWT 侧业务接口同实现,仅供 MES(B)/工位终端(D) 等服务间调用
server.AddRoutes(
[]rest.Route{
{Method: http.MethodPost, Path: "/api/internal/ledger/sync", Handler: wrapInternal(ctx)(ledgerSyncHandler(ctx))},
{Method: http.MethodPost, Path: "/api/internal/stock/check", Handler: wrapInternal(ctx)(checkStockHandler(ctx))},
{Method: http.MethodPost, Path: "/api/internal/stock/lock", Handler: wrapInternal(ctx)(lockStockHandler(ctx))},
{Method: http.MethodPost, Path: "/api/internal/stock/unlock", Handler: wrapInternal(ctx)(unlockStockHandler(ctx))},
{Method: http.MethodPost, Path: "/api/internal/stock/deduct", Handler: wrapInternal(ctx)(deductStockHandler(ctx))},
{Method: http.MethodGet, Path: "/api/internal/stock/query", Handler: wrapInternal(ctx)(queryStockHandler(ctx))},
{Method: http.MethodPost, Path: "/api/internal/semi/inbound", Handler: wrapInternal(ctx)(semiInboundHandler(ctx))},
{Method: http.MethodPost, Path: "/api/internal/semi/outbound", Handler: wrapInternal(ctx)(semiOutboundHandler(ctx))},
},
)
}