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
+18 -11
View File
@@ -5,7 +5,7 @@ import (
"errors"
"fmt"
"github.com/perfect-panel/ppanel-server/pkg/cache"
"github.com/perfect-panel/server/pkg/cache"
"github.com/redis/go-redis/v9"
"gorm.io/gorm"
)
@@ -22,10 +22,10 @@ type (
customPaymentLogicModel
}
paymentModel interface {
Insert(ctx context.Context, data *Payment) error
Insert(ctx context.Context, data *Payment, tx ...*gorm.DB) error
FindOne(ctx context.Context, id int64) (*Payment, error)
Update(ctx context.Context, data *Payment) error
Delete(ctx context.Context, id int64) error
Update(ctx context.Context, data *Payment, tx ...*gorm.DB) error
Delete(ctx context.Context, id int64, tx ...*gorm.DB) error
Transaction(ctx context.Context, fn func(db *gorm.DB) error) error
}
@@ -67,8 +67,11 @@ func (m *defaultPaymentModel) getCacheKeys(data *Payment) []string {
return cacheKeys
}
func (m *defaultPaymentModel) Insert(ctx context.Context, data *Payment) error {
func (m *defaultPaymentModel) Insert(ctx context.Context, data *Payment, tx ...*gorm.DB) error {
err := m.ExecCtx(ctx, func(conn *gorm.DB) error {
if len(tx) > 0 {
conn = tx[0]
}
return conn.Create(&data).Error
}, m.getCacheKeys(data)...)
return err
@@ -88,19 +91,21 @@ func (m *defaultPaymentModel) FindOne(ctx context.Context, id int64) (*Payment,
}
}
func (m *defaultPaymentModel) Update(ctx context.Context, data *Payment) error {
func (m *defaultPaymentModel) Update(ctx context.Context, data *Payment, tx ...*gorm.DB) error {
old, err := m.FindOne(ctx, data.Id)
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
return err
}
err = m.ExecCtx(ctx, func(conn *gorm.DB) error {
db := conn
return db.Save(data).Error
if len(tx) > 0 {
conn = tx[0]
}
return conn.Save(data).Error
}, m.getCacheKeys(old)...)
return err
}
func (m *defaultPaymentModel) Delete(ctx context.Context, id int64) error {
func (m *defaultPaymentModel) Delete(ctx context.Context, id int64, tx ...*gorm.DB) error {
data, err := m.FindOne(ctx, id)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
@@ -109,8 +114,10 @@ func (m *defaultPaymentModel) Delete(ctx context.Context, id int64) error {
return err
}
err = m.ExecCtx(ctx, func(conn *gorm.DB) error {
db := conn
return db.Delete(&Payment{}, id).Error
if len(tx) > 0 {
conn = tx[0]
}
return conn.Delete(&Payment{}, id).Error
}, m.getCacheKeys(data)...)
return err
}
+47 -26
View File
@@ -46,13 +46,19 @@ type StripeConfig struct {
Payment string `json:"payment"`
}
func (l *StripeConfig) Marshal() string {
b, _ := json.Marshal(l)
return string(b)
func (l *StripeConfig) Marshal() ([]byte, error) {
type Alias StripeConfig
return json.Marshal(&struct {
*Alias
}{
Alias: (*Alias)(l),
})
}
func (l *StripeConfig) Unmarshal(s string) error {
return json.Unmarshal([]byte(s), l)
func (l *StripeConfig) Unmarshal(data []byte) error {
type Alias StripeConfig
aux := (*Alias)(l)
return json.Unmarshal(data, &aux)
}
type AlipayF2FConfig struct {
@@ -63,13 +69,19 @@ type AlipayF2FConfig struct {
Sandbox bool `json:"sandbox"`
}
func (l *AlipayF2FConfig) Marshal() string {
b, _ := json.Marshal(l)
return string(b)
func (l *AlipayF2FConfig) Marshal() ([]byte, error) {
type Alias AlipayF2FConfig
return json.Marshal(&struct {
*Alias
}{
Alias: (*Alias)(l),
})
}
func (l *AlipayF2FConfig) Unmarshal(s string) error {
return json.Unmarshal([]byte(s), l)
func (l *AlipayF2FConfig) Unmarshal(data []byte) error {
type Alias AlipayF2FConfig
aux := (*Alias)(l)
return json.Unmarshal(data, &aux)
}
type EPayConfig struct {
@@ -78,29 +90,38 @@ type EPayConfig struct {
Key string `json:"key"`
}
func (l *EPayConfig) Marshal() string {
b, _ := json.Marshal(l)
return string(b)
func (l *EPayConfig) Marshal() ([]byte, error) {
type Alias EPayConfig
return json.Marshal(&struct {
*Alias
}{
Alias: (*Alias)(l),
})
}
func (l *EPayConfig) Unmarshal(s string) error {
return json.Unmarshal([]byte(s), l)
func (l *EPayConfig) Unmarshal(data []byte) error {
type Alias EPayConfig
aux := (*Alias)(l)
return json.Unmarshal(data, &aux)
}
type PayssionConfig struct {
PmId string `json:"pm_id"`
ApiKey string `json:"api_key"`
type CryptoSaaSConfig struct {
Endpoint string `json:"endpoint"`
AccountID string `json:"account_id"`
SecretKey string `json:"secret_key"`
Currency string `json:"currency"`
QueryUrl string `json:"query_url"`
CreateUrl string `json:"create_url"`
}
func (l *PayssionConfig) Marshal() string {
b, _ := json.Marshal(l)
return string(b)
func (l *CryptoSaaSConfig) Marshal() ([]byte, error) {
type Alias CryptoSaaSConfig
return json.Marshal(&struct {
*Alias
}{
Alias: (*Alias)(l),
})
}
func (l *PayssionConfig) Unmarshal(s string) error {
return json.Unmarshal([]byte(s), l)
func (l *CryptoSaaSConfig) Unmarshal(data []byte) error {
type Alias CryptoSaaSConfig
aux := (*Alias)(l)
return json.Unmarshal(data, &aux)
}