mirror of
https://github.com/tnb-labs/panel.git
synced 2026-10-30 18:21:30 +08:00
依赖注入:
- 移除 google/wire(含 wire.go/wire_gen.go 与全部 ProviderSet),
改用 samber/do v2 单注入器 + 双入口惰性构建
- 贡献模型替代命令式注册:路由 routes:、命令 commands:、
任务 jobs: 前缀经 internal/registry 收集与校验
- 构造函数统一 func NewXxx(i do.Injector) (T, error)
三层架构:
- 补全用例层:每个 biz.XxxRepo 配 XxxUsecase,
service/command/job 表现层只依赖用例,不再直接引用仓储
路由与文档:
- route/http.go 按域拆为声明式 Endpoint 贡献,
Endpoint 承载登录白名单与端点限流语义
- 调试模式下提供 OpenAPI 3.1 文档:/openapi.json 与 /docs(Scalar),
从 validate 标签生成
目录与依赖:
- internal/http/{middleware,request,rule} 拍平至 internal/*
- CLI 命令拆至 internal/command
- 日志轮转 timberjack 换为 libtnb/logrotate
- 升级 validator/cron/sessions/gormstore/sqlite/securecookie
- 数据库迁移保持 gormigrate 不变
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
37 lines
1.7 KiB
Go
37 lines
1.7 KiB
Go
package route
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/samber/do/v2"
|
|
|
|
"github.com/acepanel/panel/v3/internal/request"
|
|
"github.com/acepanel/panel/v3/internal/service"
|
|
)
|
|
|
|
// AppRoutes 应用商店路由
|
|
func AppRoutes(i do.Injector) (Endpoints, error) {
|
|
app := do.MustInvoke[*service.AppService](i)
|
|
|
|
return Endpoints{
|
|
{Method: http.MethodGet, Path: "/api/app/categories", Handler: app.Categories,
|
|
Summary: "应用分类", Tags: []string{"应用"}},
|
|
{Method: http.MethodGet, Path: "/api/app/list", Handler: app.List,
|
|
Summary: "应用列表", Tags: []string{"应用"}},
|
|
{Method: http.MethodPost, Path: "/api/app/install", Handler: app.Install,
|
|
Summary: "安装应用", Tags: []string{"应用"}, Request: request.App{}},
|
|
{Method: http.MethodPost, Path: "/api/app/uninstall", Handler: app.Uninstall,
|
|
Summary: "卸载应用", Tags: []string{"应用"}, Request: request.AppSlug{}},
|
|
{Method: http.MethodPost, Path: "/api/app/update", Handler: app.Update,
|
|
Summary: "更新应用", Tags: []string{"应用"}, Request: request.AppSlug{}},
|
|
{Method: http.MethodPost, Path: "/api/app/update_show", Handler: app.UpdateShow,
|
|
Summary: "更新应用首页显示", Tags: []string{"应用"}, Request: request.AppUpdateShow{}},
|
|
{Method: http.MethodPost, Path: "/api/app/update_order", Handler: app.UpdateOrder,
|
|
Summary: "更新应用排序", Tags: []string{"应用"}, Request: request.AppUpdateOrder{}},
|
|
{Method: http.MethodGet, Path: "/api/app/is_installed", Handler: app.IsInstalled,
|
|
Summary: "检查应用是否已安装", Tags: []string{"应用"}, Request: request.AppSlugs{}},
|
|
{Method: http.MethodGet, Path: "/api/app/update_cache", Handler: app.UpdateCache,
|
|
Summary: "更新应用缓存", Tags: []string{"应用"}},
|
|
}, nil
|
|
}
|