Browse Source

gormv2升级 阶段2

main
QM303176530 4 years ago
parent
commit
5406248d14
  1. 2
      server/config.yaml
  2. 4
      server/initialize/mysql.go
  3. 1
      server/service/sys_base_menu.go
  4. 2
      server/service/sys_menu.go
  5. 9
      web/src/view/superAdmin/menu/menu.vue

2
server/config.yaml

@ -17,7 +17,7 @@ mysql:
config: 'charset=utf8&parseTime=True&loc=Local' config: 'charset=utf8&parseTime=True&loc=Local'
max-idle-conns: 10 max-idle-conns: 10
max-open-conns: 10 max-open-conns: 10
log-mode: true
log-mode: false
#sqlite 配置 #sqlite 配置
sqlite: sqlite:

4
server/initialize/mysql.go

@ -25,7 +25,9 @@ func Mysql() {
Logger: logger.Default.LogMode(logger.Info), Logger: logger.Default.LogMode(logger.Info),
} }
} else { } else {
gormConfig = &gorm.Config{}
gormConfig = &gorm.Config{
Logger: logger.Default.LogMode(logger.Silent),
}
} }
if db, err := gorm.Open(mysql.New(mysqlConfig), gormConfig); err != nil { if db, err := gorm.Open(mysql.New(mysqlConfig), gormConfig); err != nil {

1
server/service/sys_base_menu.go

@ -58,6 +58,7 @@ func UpdateBaseMenu(menu model.SysBaseMenu) (err error) {
return errors.New("存在相同name修改失败") 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) err = db.Updates(upDateMap).Association("Parameters").Replace(menu.Parameters)
global.GVA_LOG.Debug("菜单修改时候,关联菜单err:%v", err) global.GVA_LOG.Debug("菜单修改时候,关联菜单err:%v", err)
return err return err

2
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) { 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" //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 //err = global.GVA_DB.Raw(sql, authorityId).Scan(&menus).Error
return err, menus return err, menus
} }

9
web/src/view/superAdmin/menu/menu.vue

@ -124,7 +124,7 @@
size="small" size="small"
type="primary" type="primary"
icon="el-icon-edit" icon="el-icon-edit"
@click="addParameter(form.parameters)"
@click="addParameter(form)"
>新增菜单参数</el-button> >新增菜单参数</el-button>
<el-table :data="form.parameters" stripe style="width: 100%"> <el-table :data="form.parameters" stripe style="width: 100%">
<el-table-column prop="type" label="参数类型" width="180"> <el-table-column prop="type" label="参数类型" width="180">
@ -230,8 +230,11 @@ export default {
icon icon
}, },
methods: { methods: {
addParameter(parameters) {
parameters.push({
addParameter(form) {
if (!form.parameters){
form.parameters = []
}
form.parameters.push({
type: "query", type: "query",
key: "", key: "",
value: "" value: ""

Loading…
Cancel
Save