From 50f962da44d74dc398629e90c366df2845ede95a Mon Sep 17 00:00:00 2001 From: pixel <303176530@qq.com> Date: Tue, 25 Aug 2020 13:56:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20authority=20=E5=85=B3?= =?UTF-8?q?=E8=81=94=E5=88=A0=E9=99=A4=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/config.yaml | 2 +- server/go.mod | 5 ----- server/service/sys_authority.go | 6 ++++-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/server/config.yaml b/server/config.yaml index 42be755c..b79d6ff2 100644 --- a/server/config.yaml +++ b/server/config.yaml @@ -13,7 +13,7 @@ mysql: username: root password: 'Aa@6447985' path: '127.0.0.1:3306' - db-name: 'qmPlus' + db-name: 'qmPlusV2' config: 'charset=utf8&parseTime=True&loc=Local' max-idle-conns: 10 max-open-conns: 10 diff --git a/server/go.mod b/server/go.mod index ddd34c4f..9f82aad6 100644 --- a/server/go.mod +++ b/server/go.mod @@ -6,7 +6,6 @@ require ( github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 github.com/casbin/casbin v1.9.1 github.com/casbin/casbin/v2 v2.11.0 - github.com/casbin/gorm-adapter v1.0.0 github.com/casbin/gorm-adapter/v3 v3.0.2 github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239 // indirect @@ -20,12 +19,10 @@ require ( github.com/go-sql-driver/mysql v1.5.0 github.com/golang/protobuf v1.4.2 // indirect github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869 // indirect - github.com/jinzhu/gorm v1.9.12 github.com/json-iterator/go v1.1.10 // indirect github.com/lestrrat/go-envload v0.0.0-20180220120943-6ed08b54a570 // indirect github.com/lestrrat/go-file-rotatelogs v0.0.0-20180223000712-d3151e2a480f github.com/lestrrat/go-strftime v0.0.0-20180220042222-ba3bf9c1d042 // indirect - github.com/lib/pq v1.3.0 // indirect github.com/mailru/easyjson v0.7.1 // indirect github.com/mitchellh/mapstructure v1.2.2 // indirect github.com/mojocn/base64Captcha v1.3.1 @@ -33,10 +30,8 @@ require ( github.com/onsi/gomega v1.4.3 // indirect github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 github.com/pelletier/go-toml v1.6.0 // indirect - github.com/piexlmax/gvaplug v0.0.8 github.com/pkg/errors v0.9.1 // indirect github.com/qiniu/api.v7/v7 v7.4.1 - github.com/qiniu/x v1.10.5 github.com/satori/go.uuid v1.2.0 github.com/spf13/afero v1.2.2 // indirect github.com/spf13/cast v1.3.1 // indirect diff --git a/server/service/sys_authority.go b/server/service/sys_authority.go index 09c7b528..dc6b86df 100644 --- a/server/service/sys_authority.go +++ b/server/service/sys_authority.go @@ -87,9 +87,11 @@ func DeleteAuthority(auth *model.SysAuthority) (err error) { if !notHas { return errors.New("此角色存在子角色不允许删除") } - db := global.GVA_DB.Preload("SysBaseMenus").Where("authority_id = ?", auth.AuthorityId).First(auth).Unscoped().Delete(auth) + db := global.GVA_DB.Preload("SysBaseMenus").Where("authority_id = ?", auth.AuthorityId).First(auth) + err = db.Unscoped().Delete(auth).Error if len(auth.SysBaseMenus) > 0 { - err = db.Association("SysBaseMenus").Delete(auth.SysBaseMenus) + err = global.GVA_DB.Model(auth).Association("SysBaseMenus").Delete(auth.SysBaseMenus) + //err = db.Association("SysBaseMenus").Delete(&auth) } else { err = db.Error }