37 lines
950 B
Go
37 lines
950 B
Go
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"
|
|
)
|
|
|
|
type row struct {
|
|
ID int64
|
|
Method string
|
|
Enabled int
|
|
Config string
|
|
}
|
|
|
|
func main() {
|
|
var c config.Config
|
|
conf.MustLoad("/private/tmp/ppanel-local-upload.yaml", &c)
|
|
ctx := svc.NewServiceContext(c)
|
|
|
|
var rows []row
|
|
if err := ctx.DB.Raw("SELECT id, method, enabled, config FROM auth_method WHERE method = ?", "device").Scan(&rows).Error; err != nil {
|
|
panic(err)
|
|
}
|
|
fmt.Printf("raw rows: %+v\n", rows)
|
|
|
|
m, err := ctx.AuthModel.FindOneByMethod(ctx.DB.Statement.Context, "device")
|
|
fmt.Printf("model err=%v\n", err)
|
|
if err == nil && m != nil && m.Enabled != nil {
|
|
fmt.Printf("model row: id=%d method=%s enabled=%v config=%s\n", m.Id, m.Method, *m.Enabled, m.Config)
|
|
} else {
|
|
fmt.Printf("model row nil or no enabled ptr: %#v\n", m)
|
|
}
|
|
}
|