本次提交包含多模块功能更新: 1. 权限系统重构:移除硬编码admin放行逻辑,新增精细化权限控制,完善权限树形结构与用户/角色保护 2. 新增物料导入导出接口,补充台账查询条件 3. 优化列表查询排序逻辑,新增区域编码大小写不敏感搜索 4. 修复帮助抽屉重复弹出问题,补充页面权限控制 5. 新增弱密码提示逻辑,优化MES/WMS用户/角色管理权限 6. 调整路由结构,新增权限校验脚本与前端权限树重构 7. 补充数据库字段与依赖包更新
162 lines
7.3 KiB
Go
162 lines
7.3 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)},
|
||
},
|
||
)
|
||
|
||
server.Use(authInterceptor(ctx))
|
||
|
||
// 当前登录用户(JWT 鉴权)
|
||
server.AddRoutes(
|
||
[]rest.Route{
|
||
{Method: http.MethodPost, Path: "/api/user/change-password", Handler: changePasswordHandler(ctx)},
|
||
{Method: http.MethodGet, Path: "/api/user/info", Handler: userInfoHandler(ctx)},
|
||
{Method: http.MethodGet, Path: "/api/user/list", Handler: listUsersHandler(ctx)},
|
||
{Method: http.MethodPost, Path: "/api/user/create", Handler: createUserHandler(ctx)},
|
||
{Method: http.MethodPost, Path: "/api/user/update", Handler: updateUserHandler(ctx)},
|
||
{Method: http.MethodPost, Path: "/api/user/delete", Handler: deleteUserHandler(ctx)},
|
||
},
|
||
)
|
||
|
||
// 角色与权限(RBAC 数据化,取代 rbac.go 中的硬编码权限 map)
|
||
server.AddRoutes(
|
||
[]rest.Route{
|
||
{Method: http.MethodPost, Path: "/api/rbac/seed", Handler: seedRbacHandler(ctx)},
|
||
{Method: http.MethodGet, Path: "/api/roles", Handler: listRolesHandler(ctx)},
|
||
{Method: http.MethodPost, Path: "/api/roles", Handler: createRoleHandler(ctx)},
|
||
{Method: http.MethodPost, Path: "/api/roles/update", Handler: updateRoleHandler(ctx)},
|
||
{Method: http.MethodPost, Path: "/api/roles/delete", Handler: deleteRoleHandler(ctx)},
|
||
{Method: http.MethodGet, Path: "/api/permissions", Handler: listPermissionsHandler(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)},
|
||
{Method: http.MethodGet, Path: "/api/material/export", Handler: exportMaterialsHandler(ctx)},
|
||
{Method: http.MethodPost, Path: "/api/material/import", Handler: excelMaterialImportHandler(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.MethodGet, Path: "/api/inbound/details", Handler: inboundDetailsHandler(ctx)},
|
||
{Method: http.MethodGet, Path: "/api/inbound/export", Handler: exportInboundHandler(ctx)},
|
||
{Method: http.MethodPost, Path: "/api/inbound/batch-excel", Handler: excelInboundHandler(ctx)},
|
||
},
|
||
)
|
||
|
||
// 出库(统一主表:备料出库 workorder / 通用出库 general,装箱信息落在同一张表)
|
||
server.AddRoutes(
|
||
[]rest.Route{
|
||
{Method: http.MethodPost, Path: "/api/outbound/create", Handler: createOutboundHandler(ctx)},
|
||
{Method: http.MethodPost, Path: "/api/outbound/general", Handler: generalOutboundHandler(ctx)},
|
||
{Method: http.MethodGet, Path: "/api/outbound/query", Handler: queryOutboundHandler(ctx)},
|
||
{Method: http.MethodGet, Path: "/api/outbound/export", Handler: exportOutboundHandler(ctx)},
|
||
},
|
||
)
|
||
|
||
// 库存
|
||
server.AddRoutes(
|
||
[]rest.Route{
|
||
{Method: http.MethodGet, Path: "/api/stock/query", Handler: queryStockHandler(ctx)},
|
||
{Method: http.MethodGet, Path: "/api/stock/details", Handler: stockDetailsHandler(ctx)},
|
||
{Method: http.MethodGet, Path: "/api/stock/export", Handler: exportStockHandler(ctx)},
|
||
{Method: http.MethodGet, Path: "/api/stock/zone-summary", Handler: zoneSummaryHandler(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)},
|
||
{Method: http.MethodGet, Path: "/api/inspection/export", Handler: exportInspectionHandler(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)},
|
||
},
|
||
)
|
||
|
||
// 工单物料台账(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))},
|
||
},
|
||
)
|
||
}
|