package main import ( "context" "fmt" "time" "github.com/perfect-panel/server/initialize" "github.com/perfect-panel/server/internal/config" loggerLog "github.com/perfect-panel/server/internal/model/log" "github.com/perfect-panel/server/internal/svc" "github.com/perfect-panel/server/pkg/conf" ) func main() { var c config.Config conf.MustLoad("etc/ppanel.yaml", &c) fmt.Println("Initializing ServiceContext...") svcCtx := svc.NewServiceContext(c) initialize.Email(svcCtx) fmt.Println("ServiceContext initialized.") ctx := context.Background() // 模拟真实数据 content := map[string]interface{}{ "Type": 1, "SiteLogo": c.Site.SiteLogo, "SiteName": c.Site.SiteName, "Expire": 15, "Code": "123456", } messageLog := loggerLog.Message{ Platform: svcCtx.Config.Email.Platform, To: "shanshanzhong147@gmail.com", Subject: "PPanel Test - Verify Email (Register)", Content: content, Status: 1, } emailLog, err := messageLog.Marshal() if err != nil { panic(err) } systemLog := &loggerLog.SystemLog{ Type: loggerLog.TypeEmailMessage.Uint8(), Date: time.Now().Format("2006-01-02"), ObjectID: 0, Content: string(emailLog), } fmt.Println("Attempting to insert into system_logs...") err = svcCtx.LogModel.Insert(ctx, systemLog) if err != nil { fmt.Printf("❌ Insert failed!\n") fmt.Printf("Error Type: %T\n", err) fmt.Printf("Error String: %s\n", err.Error()) fmt.Printf("Detailed Error: %+v\n", err) } else { fmt.Println("✅ Insert successful!") } }