add a powershell script that supports starting MES, WMS, WMSClient, Workstation and Dashboard projects with one command, includes build and run logic for backend services and npm dev for dashboard
45 lines
2.0 KiB
Go
45 lines
2.0 KiB
Go
package handler
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"bj_power_mes/internal/svc"
|
|
|
|
"github.com/zeromicro/go-zero/rest"
|
|
)
|
|
|
|
// RegisterRoutes 注册鉴权 + 系统管理(用户/角色/权限)路由
|
|
func RegisterRoutes(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|
// 免鉴权
|
|
server.AddRoutes([]rest.Route{
|
|
{Method: http.MethodPost, Path: "/login", Handler: LoginHandler(serverCtx)},
|
|
{Method: http.MethodPost, Path: "/refresh", Handler: RefreshHandler(serverCtx)},
|
|
}, rest.WithPrefix("/api/v1"))
|
|
|
|
// JWT 保护:用户信息 + 用户/角色/权限 管理
|
|
jwtAdmin := []rest.Route{
|
|
{Method: http.MethodGet, Path: "/userinfo", Handler: UserInfoHandler(serverCtx)},
|
|
{Method: http.MethodPost, Path: "/seed", Handler: SeedHandler(serverCtx)},
|
|
{Method: http.MethodPost, Path: "/user/change-password", Handler: ChangePasswordHandler(serverCtx)},
|
|
|
|
{Method: http.MethodGet, Path: "/users", Handler: ListUsersHandler(serverCtx)},
|
|
{Method: http.MethodPost, Path: "/users", Handler: CreateUserHandler(serverCtx)},
|
|
{Method: http.MethodPut, Path: "/users", Handler: UpdateUserHandler(serverCtx)},
|
|
{Method: http.MethodDelete, Path: "/users/:id", Handler: DeleteUserHandler(serverCtx)},
|
|
|
|
{Method: http.MethodGet, Path: "/roles", Handler: ListRolesHandler(serverCtx)},
|
|
{Method: http.MethodPost, Path: "/roles", Handler: CreateRoleHandler(serverCtx)},
|
|
{Method: http.MethodPut, Path: "/roles", Handler: UpdateRoleHandler(serverCtx)},
|
|
{Method: http.MethodDelete, Path: "/roles/:id", Handler: DeleteRoleHandler(serverCtx)},
|
|
|
|
{Method: http.MethodGet, Path: "/permissions", Handler: ListPermissionsHandler(serverCtx)},
|
|
{Method: http.MethodPost, Path: "/permissions", Handler: CreatePermissionHandler(serverCtx)},
|
|
{Method: http.MethodPut, Path: "/permissions", Handler: UpdatePermissionHandler(serverCtx)},
|
|
{Method: http.MethodDelete, Path: "/permissions/:id", Handler: DeletePermissionHandler(serverCtx)},
|
|
}
|
|
server.AddRoutes(jwtAdmin,
|
|
rest.WithPrefix("/api/v1"),
|
|
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
|
)
|
|
}
|