refactor: 更新项目引用路径从perfect-panel/ppanel-server到perfect-panel/server
Build docker and publish / build (20.15.1) (push) Failing after 6m27s

feat: 添加版本和构建时间变量
fix: 修正短信队列类型注释错误
style: 清理未使用的代码和测试文件
docs: 更新安装文档中的下载链接
chore: 迁移数据库脚本添加日志和订阅配置
This commit is contained in:
2025-10-13 01:33:03 -07:00
parent 393b42f35a
commit c582087c0f
974 changed files with 23609 additions and 23398 deletions
+75
View File
@@ -0,0 +1,75 @@
package client
import (
"encoding/json"
"time"
)
type SubscribeApplication struct {
Id int64 `gorm:"primaryKey"`
Name string `gorm:"type:varchar(255);default:'';not null;comment:Application Name"`
Icon string `gorm:"type:MEDIUMTEXT;default:null;comment:Application Icon"`
Description string `gorm:"type:varchar(255);default:null;comment:Application Description"`
Scheme string `gorm:"type:varchar(255);default:'';not null;comment:Scheme"`
UserAgent string `gorm:"type:varchar(255);default:'';not null;comment:User Agent"`
IsDefault bool `gorm:"type:tinyint(1);not null;default:0;comment:Is Default Application"`
SubscribeTemplate string `gorm:"type:MEDIUMTEXT;default:null;comment:Subscribe Template"`
OutputFormat string `gorm:"type:varchar(50);default:'yaml';not null;comment:Output Format"`
DownloadLink string `gorm:"type:text;not null;comment:Download Link"`
CreatedAt time.Time `gorm:"<-:create;comment:Create Time"`
UpdatedAt time.Time `gorm:"comment:Update Time"`
}
func (SubscribeApplication) TableName() string {
return "subscribe_application"
}
type DownloadLink struct {
IOS string `json:"ios,omitempty"`
Android string `json:"android,omitempty"`
Windows string `json:"windows,omitempty"`
Mac string `json:"mac,omitempty"`
Linux string `json:"linux,omitempty"`
Harmony string `json:"harmony,omitempty"`
}
// GetDownloadLink returns the download link for the specified platform.
func (d *DownloadLink) GetDownloadLink(platform string) string {
if d == nil {
return ""
}
switch platform {
case "ios":
return d.IOS
case "android":
return d.Android
case "windows":
return d.Windows
case "mac":
return d.Mac
case "linux":
return d.Linux
case "harmony":
return d.Harmony
default:
return ""
}
}
// Marshal serializes the DownloadLink to JSON format.
func (d *DownloadLink) Marshal() ([]byte, error) {
if d == nil {
var empty DownloadLink
return json.Marshal(empty)
}
return json.Marshal(d)
}
// Unmarshal parses the JSON-encoded data and stores the result in the DownloadLink.
func (d *DownloadLink) Unmarshal(data []byte) error {
if data == nil || len(data) == 0 {
*d = DownloadLink{}
return nil
}
return json.Unmarshal(data, d)
}
+81
View File
@@ -0,0 +1,81 @@
package client
import (
"context"
"gorm.io/gorm"
)
type (
Model interface {
subscribeApplicationModel
}
subscribeApplicationModel interface {
Insert(ctx context.Context, data *SubscribeApplication) error
FindOne(ctx context.Context, id int64) (*SubscribeApplication, error)
Update(ctx context.Context, data *SubscribeApplication) error
Delete(ctx context.Context, id int64) error
List(ctx context.Context) ([]*SubscribeApplication, error)
Transaction(ctx context.Context, fn func(db *gorm.DB) error) error
}
DefaultSubscribeApplicationModel struct {
*gorm.DB
}
)
func NewSubscribeApplicationModel(db *gorm.DB) Model {
return &DefaultSubscribeApplicationModel{
DB: db,
}
}
func (m *DefaultSubscribeApplicationModel) Insert(ctx context.Context, data *SubscribeApplication) error {
if err := m.WithContext(ctx).Model(&SubscribeApplication{}).Create(data).Error; err != nil {
return err
}
return nil
}
func (m *DefaultSubscribeApplicationModel) FindOne(ctx context.Context, id int64) (*SubscribeApplication, error) {
var resp SubscribeApplication
if err := m.WithContext(ctx).Model(&SubscribeApplication{}).Where("id = ?", id).First(&resp).Error; err != nil {
return nil, err
}
return &resp, nil
}
func (m *DefaultSubscribeApplicationModel) Update(ctx context.Context, data *SubscribeApplication) error {
if _, err := m.FindOne(ctx, data.Id); err != nil {
return err
}
if err := m.WithContext(ctx).Model(&SubscribeApplication{}).Where("`id` = ?", data.Id).Save(data).Error; err != nil {
return err
}
return nil
}
func (m *DefaultSubscribeApplicationModel) Delete(ctx context.Context, id int64) error {
if err := m.WithContext(ctx).Model(&SubscribeApplication{}).Where("`id` = ?", id).Delete(&SubscribeApplication{}).Error; err != nil {
return err
}
return nil
}
func (m *DefaultSubscribeApplicationModel) Transaction(ctx context.Context, fn func(db *gorm.DB) error) error {
tx := m.WithContext(ctx).Begin()
if err := fn(tx); err != nil {
if rbErr := tx.Rollback().Error; rbErr != nil {
return rbErr
}
return err
}
return tx.Commit().Error
}
func (m *DefaultSubscribeApplicationModel) List(ctx context.Context) ([]*SubscribeApplication, error) {
var resp []*SubscribeApplication
if err := m.WithContext(ctx).Find(&resp).Error; err != nil {
return nil, err
}
return resp, nil
}