mirror of
https://github.com/tnb-labs/panel.git
synced 2026-08-30 17:05:19 +08:00
443516a2cf
依赖注入:
- 移除 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>
60 lines
1.6 KiB
Go
60 lines
1.6 KiB
Go
package command
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/leonelquinteros/gotext"
|
|
"github.com/samber/do/v2"
|
|
"github.com/urfave/cli/v3"
|
|
|
|
"github.com/acepanel/panel/v3/internal/service"
|
|
)
|
|
|
|
// StatusCommand 查询服务状态
|
|
func StatusCommand(i do.Injector) (*cli.Command, error) {
|
|
t := do.MustInvoke[*gotext.Locale](i)
|
|
return &cli.Command{
|
|
Name: "status",
|
|
Usage: t.Get("Get AcePanel service status"),
|
|
Action: func(ctx context.Context, cmd *cli.Command) error {
|
|
return do.MustInvoke[*service.CliService](i).Status(ctx, cmd)
|
|
},
|
|
}, nil
|
|
}
|
|
|
|
// RestartCommand 重启服务
|
|
func RestartCommand(i do.Injector) (*cli.Command, error) {
|
|
t := do.MustInvoke[*gotext.Locale](i)
|
|
return &cli.Command{
|
|
Name: "restart",
|
|
Usage: t.Get("Restart AcePanel service"),
|
|
Action: func(ctx context.Context, cmd *cli.Command) error {
|
|
return do.MustInvoke[*service.CliService](i).Restart(ctx, cmd)
|
|
},
|
|
}, nil
|
|
}
|
|
|
|
// StopCommand 停止服务
|
|
func StopCommand(i do.Injector) (*cli.Command, error) {
|
|
t := do.MustInvoke[*gotext.Locale](i)
|
|
return &cli.Command{
|
|
Name: "stop",
|
|
Usage: t.Get("Stop AcePanel service"),
|
|
Action: func(ctx context.Context, cmd *cli.Command) error {
|
|
return do.MustInvoke[*service.CliService](i).Stop(ctx, cmd)
|
|
},
|
|
}, nil
|
|
}
|
|
|
|
// StartCommand 启动服务
|
|
func StartCommand(i do.Injector) (*cli.Command, error) {
|
|
t := do.MustInvoke[*gotext.Locale](i)
|
|
return &cli.Command{
|
|
Name: "start",
|
|
Usage: t.Get("Start AcePanel service"),
|
|
Action: func(ctx context.Context, cmd *cli.Command) error {
|
|
return do.MustInvoke[*service.CliService](i).Start(ctx, cmd)
|
|
},
|
|
}, nil
|
|
}
|