package rbac

import (
	"github.com/casbin/casbin/v2"
	gormadapter "github.com/casbin/gorm-adapter/v3"
	"log"
)

var Ef *casbin.Enforcer

func Setup() {
	var err error
	a, _ := gormadapter.NewAdapter("mysql", "root:fVkWkJZoOQcpunqC@tcp(172.16.101.45:3306)/pc_manage", true)
	Ef, err = casbin.NewEnforcer("./conf/model.conf", a)
	if err != nil {
		log.Fatalf("casbin.Setup, fail to parse 'conf/model.conf': %v", err)
	}

	// 日志记录
	Ef.EnableLog(true)
}
