chore: 并入 iotlcm-app 历史到 app/(原提交 f40bda9)

This commit is contained in:
MiFaZhan
2026-11-02 13:28:00 +08:00
1107 changed files with 147143 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
package router
import (
"context"
"github.com/gogf/gf/v2/errors/gcode"
"git.5iot.com/iotlcm-public/iotlcm-app/internal/controller/app"
"git.5iot.com/iotlcm-public/iotlcm-app/internal/library/contexts"
"git.5iot.com/iotlcm-public/iotlcm-app/internal/library/mcache"
"git.5iot.com/iotlcm-public/iotlcm-app/internal/packed/response"
"git.5iot.com/iotlcm-public/iotlcm-app/internal/service"
"github.com/gogf/gf/v2/net/ghttp"
)
func App(ctx context.Context, group *ghttp.RouterGroup) {
group.Group("/", func(group *ghttp.RouterGroup) {
group.Middleware(
func(r *ghttp.Request) {
ctx := r.GetCtx()
userId := contexts.GetUserId(ctx)
if userId != 0 && !contexts.IsSuperAdmin(ctx) {
freshCtx, err := mcache.WithFreshUserAccess(ctx, userId)
if err != nil {
response.JsonExit(r, gcode.CodeNotAuthorized.Code(), "权限校验失败,请重试")
return
}
r.SetCtx(freshCtx)
}
r.Middleware.Next()
},
service.Middleware().Auth,
)
group.Bind(
app.NewV1(),
&app.ExecutionLogController{},
&app.AllocateResultController{},
)
})
}