chore: 并入 iotlcm-app 历史到 app/(原提交 f40bda9)
This commit is contained in:
@@ -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{},
|
||||
)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// package router
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package router
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/controller/common"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/service"
|
||||
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
)
|
||||
|
||||
// Common 通用路由
|
||||
func Common(ctx context.Context, group *ghttp.RouterGroup) {
|
||||
|
||||
group.Group("/common", func(group *ghttp.RouterGroup) {
|
||||
group.Middleware(
|
||||
service.Middleware().Auth,
|
||||
)
|
||||
group.Bind(
|
||||
common.NewV1(),
|
||||
)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// package router
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package router
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/router/genrouter"
|
||||
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
)
|
||||
|
||||
// 生成代码注册
|
||||
func Gen(ctx context.Context, group *ghttp.RouterGroup) {
|
||||
genrouter.Register(ctx, group)
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// package router
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package router
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/controller/gen_codes"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/service"
|
||||
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
)
|
||||
|
||||
// GenCodes 代码生成路由
|
||||
func GenCodes(ctx context.Context, group *ghttp.RouterGroup) {
|
||||
group.Group("/genCodes", func(group *ghttp.RouterGroup) {
|
||||
group.Middleware(
|
||||
service.Middleware().Auth,
|
||||
)
|
||||
group.Bind(
|
||||
gen_codes.NewV1(),
|
||||
)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// package genrouter
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package genrouter
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/service"
|
||||
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
)
|
||||
|
||||
var (
|
||||
NoLoginRouter []interface{} // 无需登录
|
||||
LoginRequiredRouter []interface{} // 需要登录
|
||||
)
|
||||
|
||||
// Register 注册通过代码生成的后台路由
|
||||
func Register(ctx context.Context, group *ghttp.RouterGroup) {
|
||||
group.Group("/gen", func(group *ghttp.RouterGroup) {
|
||||
if len(NoLoginRouter) > 0 {
|
||||
group.Bind(NoLoginRouter...)
|
||||
}
|
||||
group.Middleware(service.Middleware().Auth)
|
||||
if len(LoginRequiredRouter) > 0 {
|
||||
group.Bind(LoginRequiredRouter...)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// Package genrouter
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
// @AutoGenerate Version
|
||||
package genrouter
|
||||
|
||||
import "git.5iot.com/iotlcm-public/iotlcm-app/internal/controller/gen"
|
||||
|
||||
func init() {
|
||||
LoginRequiredRouter = append(LoginRequiredRouter, gen.TestDemo) // 测试单表
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// Package genrouter
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2026 LiXiujie
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
// @AutoGenerate Version
|
||||
package genrouter
|
||||
|
||||
import "git.5iot.com/iotlcm-public/iotlcm-app/internal/controller/gen"
|
||||
|
||||
func init() {
|
||||
LoginRequiredRouter = append(LoginRequiredRouter, gen.TestTree) // 测试树表
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// package router
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package router
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/controller/monitor"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/library/websocket"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/service"
|
||||
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
)
|
||||
|
||||
// Monitor 监控功能的路由,不含业务属性的
|
||||
func Monitor(ctx context.Context, group *ghttp.RouterGroup) {
|
||||
group.Group("/monitor", func(group *ghttp.RouterGroup) {
|
||||
group.Middleware(
|
||||
service.Middleware().Auth,
|
||||
)
|
||||
group.Bind(
|
||||
monitor.NewV1(),
|
||||
)
|
||||
group.ALL("/ws", websocket.WsPage)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
// package router
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package router
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/controller/info"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/service"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
)
|
||||
|
||||
// InitRouter 初始化路由
|
||||
func InitRouter(ctx context.Context, s *ghttp.Server) {
|
||||
uploadPath := g.Cfg().MustGet(ctx, "system.upload.local.path").String()
|
||||
if uploadPath != "" {
|
||||
s.AddStaticPath("/upload", uploadPath)
|
||||
}
|
||||
s.Group("/api/v1", func(group *ghttp.RouterGroup) {
|
||||
group.Middleware(
|
||||
service.Middleware().ResponseHandler,
|
||||
service.Middleware().CORS,
|
||||
)
|
||||
group.Bind(
|
||||
info.NewV1(),
|
||||
)
|
||||
})
|
||||
s.Group("/api/v1", func(group *ghttp.RouterGroup) {
|
||||
group.Middleware(
|
||||
service.Middleware().Ctx,
|
||||
service.Middleware().ResponseHandler,
|
||||
service.Middleware().CORS,
|
||||
)
|
||||
System(ctx, group)
|
||||
App(ctx, group)
|
||||
Monitor(ctx, group)
|
||||
Common(ctx, group)
|
||||
GenCodes(ctx, group)
|
||||
Gen(ctx, group)
|
||||
})
|
||||
//操作日志
|
||||
s.BindHookHandler("/*", ghttp.HookAfterOutput, func(r *ghttp.Request) {
|
||||
service.Middleware().OperationLog(r)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// package router
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package router
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/controller/system"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/service"
|
||||
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
)
|
||||
|
||||
// System 系统默认功能的路由,不含业务属性的
|
||||
func System(ctx context.Context, group *ghttp.RouterGroup) {
|
||||
|
||||
group.Group("/system", func(group *ghttp.RouterGroup) {
|
||||
group.Middleware(
|
||||
service.Middleware().Auth,
|
||||
)
|
||||
group.Bind(
|
||||
system.NewV1(),
|
||||
)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user