fix: resolve build errors after merge (types, config, logic)

This commit is contained in:
shanshanzhong 2025-12-28 17:25:11 -08:00
parent d94cbc09b0
commit 615b87ef26
7 changed files with 64 additions and 11 deletions

42
cmd/migrate.go Normal file
View File

@ -0,0 +1,42 @@
package cmd
import (
"fmt"
"os"
"github.com/perfect-panel/server/initialize"
"github.com/perfect-panel/server/internal/config"
"github.com/perfect-panel/server/internal/svc"
"github.com/perfect-panel/server/pkg/conf"
"github.com/perfect-panel/server/pkg/logger"
"github.com/spf13/cobra"
)
func init() {
migrateCmd.Flags().StringVar(&migrateConfigPath, "config", "etc/ppanel.yaml", "ppanel.yaml directory to read from")
rootCmd.AddCommand(migrateCmd)
}
var (
migrateConfigPath string
)
var migrateCmd = &cobra.Command{
Use: "migrate",
Short: "Run database migrations",
Run: func(cmd *cobra.Command, args []string) {
runMigrate()
},
}
func runMigrate() {
var c config.Config
conf.MustLoad(migrateConfigPath, &c)
if err := logger.SetUp(c.Logger); err != nil {
fmt.Println("Logger setup failed:", err.Error())
os.Exit(1)
}
ctx := svc.NewServiceContext(c)
initialize.Migrate(ctx)
logger.Info("[Migrate] database migration completed")
}

View File

@ -204,6 +204,8 @@ type InviteConfig struct {
FirstPurchasePercentage int64 `yaml:"FirstPurchasePercentage" default:"20"` FirstPurchasePercentage int64 `yaml:"FirstPurchasePercentage" default:"20"`
FirstYearlyPurchasePercentage int64 `yaml:"FirstYearlyPurchasePercentage" default:"25"` FirstYearlyPurchasePercentage int64 `yaml:"FirstYearlyPurchasePercentage" default:"25"`
NonFirstPurchasePercentage int64 `yaml:"NonFirstPurchasePercentage" default:"10"` NonFirstPurchasePercentage int64 `yaml:"NonFirstPurchasePercentage" default:"10"`
ReferralPercentage uint8 `yaml:"ReferralPercentage" default:"10"`
OnlyFirstPurchase bool `yaml:"OnlyFirstPurchase" default:"false"`
} }
type Telegram struct { type Telegram struct {

View File

@ -58,7 +58,7 @@ func (l *QuerySubscribeListLogic) QuerySubscribeList(req *types.QuerySubscribeLi
} }
list[i] = sub list[i] = sub
// 通过服务组查询关联的节点数量 // 通过服务组查询关联的节点数量
servers, err := l.svcCtx.ServerModel.FindServerListByGroupIds(l.ctx, sub.ServerGroup) servers, err := l.svcCtx.ServerModel.FindServerListByGroupIds(l.ctx, tool.StringToInt64Slice(sub.ServerGroup))
if err != nil { if err != nil {
l.Errorw("[QuerySubscribeListLogic] FindServerListByGroupIds error", logger.Field("error", err.Error())) l.Errorw("[QuerySubscribeListLogic] FindServerListByGroupIds error", logger.Field("error", err.Error()))
sub.ServerCount = 0 sub.ServerCount = 0

View File

@ -22,6 +22,7 @@ type Subscribe struct {
Quota int64 `gorm:"type:int;not null;default:0;comment:Quota"` Quota int64 `gorm:"type:int;not null;default:0;comment:Quota"`
Nodes string `gorm:"type:varchar(255);comment:Node Ids"` Nodes string `gorm:"type:varchar(255);comment:Node Ids"`
NodeTags string `gorm:"type:varchar(255);comment:Node Tags"` NodeTags string `gorm:"type:varchar(255);comment:Node Tags"`
ServerGroup string `gorm:"type:varchar(255);comment:Server Group"`
Show *bool `gorm:"type:tinyint(1);not null;default:0;comment:Show portal page"` Show *bool `gorm:"type:tinyint(1);not null;default:0;comment:Show portal page"`
Sell *bool `gorm:"type:tinyint(1);not null;default:0;comment:Sell"` Sell *bool `gorm:"type:tinyint(1);not null;default:0;comment:Sell"`
Sort int64 `gorm:"type:int;not null;default:0;comment:Sort"` Sort int64 `gorm:"type:int;not null;default:0;comment:Sort"`

View File

@ -17,6 +17,7 @@ import (
"github.com/perfect-panel/server/internal/model/order" "github.com/perfect-panel/server/internal/model/order"
"github.com/perfect-panel/server/internal/model/payment" "github.com/perfect-panel/server/internal/model/payment"
"github.com/perfect-panel/server/internal/model/subscribe" "github.com/perfect-panel/server/internal/model/subscribe"
"github.com/perfect-panel/server/internal/model/server"
"github.com/perfect-panel/server/internal/model/system" "github.com/perfect-panel/server/internal/model/system"
"github.com/perfect-panel/server/internal/model/ticket" "github.com/perfect-panel/server/internal/model/ticket"
"github.com/perfect-panel/server/internal/model/traffic" "github.com/perfect-panel/server/internal/model/traffic"
@ -48,7 +49,7 @@ type ServiceContext struct {
OrderModel order.Model OrderModel order.Model
ClientModel client.Model ClientModel client.Model
TicketModel ticket.Model TicketModel ticket.Model
//ServerModel server.Model ServerModel server.Model
SystemModel system.Model SystemModel system.Model
CouponModel coupon.Model CouponModel coupon.Model
PaymentModel payment.Model PaymentModel payment.Model
@ -109,7 +110,7 @@ func NewServiceContext(c config.Config) *ServiceContext {
OrderModel: order.NewModel(db, rds), OrderModel: order.NewModel(db, rds),
ClientModel: client.NewSubscribeApplicationModel(db), ClientModel: client.NewSubscribeApplicationModel(db),
TicketModel: ticket.NewModel(db, rds), TicketModel: ticket.NewModel(db, rds),
//ServerModel: server.NewModel(db, rds), ServerModel: server.NewModel(db, rds),
SystemModel: system.NewModel(db, rds), SystemModel: system.NewModel(db, rds),
CouponModel: coupon.NewModel(db, rds), CouponModel: coupon.NewModel(db, rds),
PaymentModel: payment.NewModel(db, rds), PaymentModel: payment.NewModel(db, rds),

View File

@ -953,6 +953,7 @@ type GetStatResponse struct {
Node int64 `json:"node"` Node int64 `json:"node"`
Country int64 `json:"country"` Country int64 `json:"country"`
Protocol []string `json:"protocol"` Protocol []string `json:"protocol"`
OnlineDevice int64 `json:"online_devices"`
} }
type GetSubscribeApplicationListRequest struct { type GetSubscribeApplicationListRequest struct {
@ -2060,6 +2061,8 @@ type Subscribe struct {
Quota int64 `json:"quota"` Quota int64 `json:"quota"`
Nodes []int64 `json:"nodes"` Nodes []int64 `json:"nodes"`
NodeTags []string `json:"node_tags"` NodeTags []string `json:"node_tags"`
ServerGroup string `json:"server_group"`
ServerCount int64 `json:"server_count"`
Show bool `json:"show"` Show bool `json:"show"`
Sell bool `json:"sell"` Sell bool `json:"sell"`
Sort int64 `json:"sort"` Sort int64 `json:"sort"`

View File

@ -56,6 +56,10 @@ func parseDefaultValue(kind reflect.Kind, defaultValue string) any {
var i uint32 var i uint32
_, _ = fmt.Sscanf(defaultValue, "%d", &i) _, _ = fmt.Sscanf(defaultValue, "%d", &i)
return i return i
case reflect.Uint8:
var i uint8
_, _ = fmt.Sscanf(defaultValue, "%d", &i)
return i
default: default:
fmt.Printf("类型 %v 没有处理, 值为: %v \n", kind, defaultValue) fmt.Printf("类型 %v 没有处理, 值为: %v \n", kind, defaultValue)
panic("unhandled default case") panic("unhandled default case")