You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
671 B
31 lines
671 B
2 years ago
|
package models
|
||
|
|
||
|
import (
|
||
|
"github.com/beego/beego/v2/client/orm"
|
||
|
"viviman.top/dto"
|
||
|
)
|
||
|
|
||
|
type SysRolesMenus struct {
|
||
|
Id int64
|
||
|
MenuId *SysMenu `orm:"column(menu_id);rel(fk)"`
|
||
|
RoleId *SysRole `orm:"column(role_id);rel(fk)"`
|
||
|
}
|
||
|
|
||
|
func init() {
|
||
|
orm.RegisterModel(new(SysRolesMenus))
|
||
|
}
|
||
|
|
||
|
func BatchRoleMenuAdd(menu dto.RoleMenu) {
|
||
|
o := orm.NewOrm()
|
||
|
o.Raw("delete from sys_roles_menus WHERE role_id = ?", menu.Id).Exec()
|
||
|
|
||
|
var roleMenus []SysRolesMenus
|
||
|
for _, val := range menu.Menus {
|
||
|
var menus = SysMenu{Id: val.Id}
|
||
|
var roles = SysRole{Id: menu.Id}
|
||
|
roleMenus = append(roleMenus, SysRolesMenus{MenuId: &menus, RoleId: &roles})
|
||
|
}
|
||
|
|
||
|
o.InsertMulti(100, roleMenus)
|
||
|
}
|