mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-11-14 13:13:51 +08:00
发布代码生成、更新20+表单组件,优化数据字典,gf版本更新到2.3.1
This commit is contained in:
@@ -13,7 +13,6 @@ import (
|
||||
"github.com/casbin/casbin/v2/model"
|
||||
"github.com/casbin/casbin/v2/persist"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"log"
|
||||
"math"
|
||||
"strings"
|
||||
)
|
||||
@@ -119,7 +118,6 @@ func (a *adapter) dropPolicyTable() (err error) {
|
||||
|
||||
// LoadPolicy loads all policy rules from the storage.
|
||||
func (a *adapter) LoadPolicy(model model.Model) (err error) {
|
||||
log.Println("LoadPolicy...")
|
||||
var rules []policyRule
|
||||
|
||||
if err = a.model().Scan(&rules); err != nil {
|
||||
@@ -248,7 +246,7 @@ func (a *adapter) UpdatePolicies(sec string, ptype string, oldRules, newRules []
|
||||
return
|
||||
}
|
||||
|
||||
err = a.db.Transaction(context.TODO(), func(ctx context.Context, tx *gdb.TX) error {
|
||||
err = a.db.Transaction(context.TODO(), func(ctx context.Context, tx gdb.TX) error {
|
||||
for i := 0; i < int(math.Min(float64(len(oldRules)), float64(len(newRules)))); i++ {
|
||||
if _, err = tx.Model(a.table).Update(a.buildPolicyRule(ptype, newRules[i]), a.buildPolicyRule(ptype, oldRules[i])); err != nil {
|
||||
return err
|
||||
|
||||
@@ -29,8 +29,8 @@ var Enforcer *casbin.Enforcer
|
||||
// InitEnforcer 初始化
|
||||
func InitEnforcer(ctx context.Context) {
|
||||
var (
|
||||
link, _ = g.Cfg().Get(ctx, "database.default.link")
|
||||
a, err = NewAdapter(link.String())
|
||||
link = g.Cfg().MustGet(ctx, "database.default.link")
|
||||
a, err = NewAdapter(link.String())
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
@@ -53,10 +53,10 @@ func loadPermissions(ctx context.Context) {
|
||||
Permissions string `json:"permissions"`
|
||||
}
|
||||
var (
|
||||
rules [][]string
|
||||
polices []*Policy
|
||||
err error
|
||||
superRoleKey, _ = g.Cfg().Get(ctx, "hotgo.admin.superRoleKey")
|
||||
rules [][]string
|
||||
polices []*Policy
|
||||
err error
|
||||
superRoleKey = g.Cfg().MustGet(ctx, "hotgo.admin.superRoleKey")
|
||||
)
|
||||
|
||||
err = g.Model("hg_admin_role r").
|
||||
|
||||
Reference in New Issue
Block a user