cutego/modules/core/dao/role_menu_dao.go

39 lines
739 B
Go
Raw Normal View History

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