From 5406248d145837d7953ef3f9f16c5aa212c86ba1 Mon Sep 17 00:00:00 2001 From: QM303176530 <303176530@qq.com> Date: Sun, 23 Aug 2020 16:28:20 +0800 Subject: [PATCH] =?UTF-8?q?gormv2=E5=8D=87=E7=BA=A7=20=E9=98=B6=E6=AE=B52?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/config.yaml | 2 +- server/initialize/mysql.go | 4 +++- server/service/sys_base_menu.go | 1 + server/service/sys_menu.go | 2 +- web/src/view/superAdmin/menu/menu.vue | 9 ++++++--- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/server/config.yaml b/server/config.yaml index 3c843258..42be755c 100644 --- a/server/config.yaml +++ b/server/config.yaml @@ -17,7 +17,7 @@ mysql: config: 'charset=utf8&parseTime=True&loc=Local' max-idle-conns: 10 max-open-conns: 10 - log-mode: true + log-mode: false #sqlite 配置 sqlite: diff --git a/server/initialize/mysql.go b/server/initialize/mysql.go index 1adeb5b3..dab5acee 100644 --- a/server/initialize/mysql.go +++ b/server/initialize/mysql.go @@ -25,7 +25,9 @@ func Mysql() { Logger: logger.Default.LogMode(logger.Info), } } else { - gormConfig = &gorm.Config{} + gormConfig = &gorm.Config{ + Logger: logger.Default.LogMode(logger.Silent), + } } if db, err := gorm.Open(mysql.New(mysqlConfig), gormConfig); err != nil { diff --git a/server/service/sys_base_menu.go b/server/service/sys_base_menu.go index 1aee42a3..bff7afa3 100644 --- a/server/service/sys_base_menu.go +++ b/server/service/sys_base_menu.go @@ -58,6 +58,7 @@ func UpdateBaseMenu(menu model.SysBaseMenu) (err error) { return errors.New("存在相同name修改失败") } } + err = global.GVA_DB.Delete(&model.SysBaseMenuParameter{}, "sys_base_menu_id = ?", menu.ID).Error err = db.Updates(upDateMap).Association("Parameters").Replace(menu.Parameters) global.GVA_LOG.Debug("菜单修改时候,关联菜单err:%v", err) return err diff --git a/server/service/sys_menu.go b/server/service/sys_menu.go index 3a2ade42..146a6c63 100644 --- a/server/service/sys_menu.go +++ b/server/service/sys_menu.go @@ -158,7 +158,7 @@ func AddMenuAuthority(menus []model.SysBaseMenu, authorityId string) (err error) func GetMenuAuthority(authorityId string) (err error, menus []model.SysMenu) { //sql := "SELECT authority_menu.keep_alive,authority_menu.default_menu,authority_menu.created_at,authority_menu.updated_at,authority_menu.deleted_at,authority_menu.menu_level,authority_menu.parent_id,authority_menu.path,authority_menu.`name`,authority_menu.hidden,authority_menu.component,authority_menu.title,authority_menu.icon,authority_menu.sort,authority_menu.menu_id,authority_menu.authority_id FROM authority_menu WHERE authority_menu.authority_id = ? ORDER BY authority_menu.sort ASC" - err = global.GVA_DB.Order("sort").Find(&menus).Error + err = global.GVA_DB.Where("authority_id = ? ", authorityId).Order("sort").Find(&menus).Error //err = global.GVA_DB.Raw(sql, authorityId).Scan(&menus).Error return err, menus } diff --git a/web/src/view/superAdmin/menu/menu.vue b/web/src/view/superAdmin/menu/menu.vue index 3d7c446e..f15ffdcc 100644 --- a/web/src/view/superAdmin/menu/menu.vue +++ b/web/src/view/superAdmin/menu/menu.vue @@ -124,7 +124,7 @@ size="small" type="primary" icon="el-icon-edit" - @click="addParameter(form.parameters)" + @click="addParameter(form)" >新增菜单参数 @@ -230,8 +230,11 @@ export default { icon }, methods: { - addParameter(parameters) { - parameters.push({ + addParameter(form) { + if (!form.parameters){ + form.parameters = [] + } + form.parameters.push({ type: "query", key: "", value: ""