- 新增区域状态字段与增删改查接口,支持区域启用/停用 - 重构实体字段JSON标签为camelCase格式统一接口规范 - 优化入库、盘点、装箱流程的交互与提示文案 - 新增装箱管理功能,支持合同号关联与装箱编辑 - 调整前端菜单与帮助文档适配业务场景变更
145 lines
5.6 KiB
Go
145 lines
5.6 KiB
Go
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))
|
||
|
||
// 当前登录用户(JWT 鉴权)
|
||
server.AddRoutes(
|
||
[]rest.Route{
|
||
{Method: http.MethodPost, Path: "/api/user/change-password", Handler: changePasswordHandler(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.MethodPost, Path: "/api/zone/update", Handler: updateZoneHandler(ctx)},
|
||
{Method: http.MethodGet, Path: "/api/zone/list", Handler: listZonesHandler(ctx)},
|
||
{Method: http.MethodGet, Path: "/api/zone/picker", Handler: listZonesForPicker(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.MethodPost, Path: "/api/package/update", Handler: packageUpdateHandler(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)},
|
||
{Method: http.MethodGet, Path: "/api/orders", Handler: ordersHandler(ctx)},
|
||
},
|
||
)
|
||
|
||
// 大屏展示数据(免登录)
|
||
server.AddRoutes(
|
||
[]rest.Route{
|
||
{Method: http.MethodGet, Path: "/api/display/overview", Handler: internalDisplayHandler(ctx)},
|
||
},
|
||
)
|
||
|
||
// 项目间内部 API(X-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))},
|
||
},
|
||
)
|
||
}
|