cutego/modules/core/dao/role_menu_dao.go

38 lines
698 B
Go
Raw Normal View History

2022-03-01 13:50:13 +08:00
package dao
import (
2023-01-18 15:40:27 +08:00
"cutego/modules/core/entity"
2022-03-01 13:50:13 +08:00
"cutego/pkg/common"
)
type RoleMenuDao struct {
}
// Insert 添加角色菜单关系
2023-01-18 15:40:27 +08:00
func (d RoleMenuDao) Insert(list []entity.SysRoleMenu) int64 {
2022-03-01 13:50:13 +08:00
session := SqlDB.NewSession()
session.Begin()
insert, err := session.Insert(&list)
if err != nil {
common.ErrorLog(err)
session.Rollback()
}
session.Commit()
return insert
}
// Delete 删除角色和菜单关系
2023-01-18 15:40:27 +08:00
func (d RoleMenuDao) Delete(role entity.SysRole) {
menu := entity.SysRoleMenu{
2022-03-01 13:50:13 +08:00
RoleId: role.RoleId,
}
session := SqlDB.NewSession()
session.Begin()
_, err := session.Delete(&menu)
if err != nil {
common.ErrorLog(err)
session.Rollback()
}
session.Commit()
}