package main

import (
  "fmt"

  "github.com/perfect-panel/server/internal/config"
  "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)
  const key = "cache:auth:method:device"
  before, _ := ctx.Redis.Get(ctx.DB.Statement.Context, key).Result()
  fmt.Printf("cache before=%q\n", before)
  m, err := ctx.AuthModel.FindOneByMethod(ctx.DB.Statement.Context, "device")
  fmt.Printf("model err=%v enabled_nil=%v", err, m == nil || m.Enabled == nil)
  if m != nil && m.Enabled != nil { fmt.Printf(" enabled=%v", *m.Enabled) }
  if m != nil { fmt.Printf(" config=%s", m.Config) }
  fmt.Println()
  after, _ := ctx.Redis.Get(ctx.DB.Statement.Context, key).Result()
  fmt.Printf("cache after=%q\n", after)
}
