feat: 添加版本和构建时间变量 fix: 修正短信队列类型注释错误 style: 清理未使用的代码和测试文件 docs: 更新安装文档中的下载链接 chore: 迁移数据库脚本添加日志和订阅配置
52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
package tool
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/perfect-panel/server/internal/svc"
|
|
"github.com/perfect-panel/server/internal/types"
|
|
"github.com/perfect-panel/server/pkg/constant"
|
|
"github.com/perfect-panel/server/pkg/logger"
|
|
)
|
|
|
|
type GetVersionLogic struct {
|
|
logger.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
// NewGetVersionLogic Get Version
|
|
func NewGetVersionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetVersionLogic {
|
|
return &GetVersionLogic{
|
|
Logger: logger.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *GetVersionLogic) GetVersion() (resp *types.VersionResponse, err error) {
|
|
version := constant.Version
|
|
buildTime := constant.BuildTime
|
|
|
|
// Normalize unknown values
|
|
if version == "unknown version" {
|
|
version = "unknown"
|
|
}
|
|
if buildTime == "unknown time" {
|
|
buildTime = "unknown"
|
|
}
|
|
|
|
// Format version based on whether it starts with 'v'
|
|
var formattedVersion string
|
|
if len(version) > 0 && version[0] == 'v' {
|
|
formattedVersion = fmt.Sprintf("%s(%s)", version[1:], buildTime)
|
|
} else {
|
|
formattedVersion = fmt.Sprintf("%s(%s) Develop", version, buildTime)
|
|
}
|
|
|
|
return &types.VersionResponse{
|
|
Version: formattedVersion,
|
|
}, nil
|
|
}
|