package main

import (
  "fmt"

  "github.com/perfect-panel/server/internal/config"
  authmodel "github.com/perfect-panel/server/internal/model/auth"
  "github.com/perfect-panel/server/internal/svc"
  "github.com/perfect-panel/server/pkg/conf"
)

func main() {
  var c config.Config
  conf.MustLoad("/private/tmp/ppanel-local-upload.yaml", &c)
  ctx := svc.NewServiceContext(c)

  var a1 authmodel.Auth
  err1 := ctx.DB.Model(&authmodel.Auth{}).Where("method = ?", "device").First(&a1).Error
  fmt.Printf("gorm direct err=%v enabled_nil=%v", err1, a1.Enabled == nil)
  if a1.Enabled != nil { fmt.Printf(" enabled=%v", *a1.Enabled) }
  fmt.Printf(" config=%s\n", a1.Config)

  var a2 authmodel.Auth
  err2 := ctx.DB.Table("auth_method").Where("method = ?", "device").First(&a2).Error
  fmt.Printf("gorm table err=%v enabled_nil=%v", err2, a2.Enabled == nil)
  if a2.Enabled != nil { fmt.Printf(" enabled=%v", *a2.Enabled) }
  fmt.Printf(" config=%s\n", a2.Config)
}
