sys_role_admin.go 733 B

12345678910111213141516171819202122232425
  1. package system
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type SysRoleAdmin struct {
  7. Id int `orm:"column(id);pk" description:"自增ID"`
  8. AdminId int `orm:"column(admin_id);" description:"系统用户id"`
  9. RoleId int `orm:"column(role_id);" description:"角色ID"`
  10. CreateTime time.Time `orm:"column(create_time);" description:"创建时间"`
  11. }
  12. func (sa *SysRoleAdmin) TableName() string {
  13. return "sys_role_admin"
  14. }
  15. // GetRoleIdsByAdminId 根据管理员账号查询角色ID
  16. func GetRoleIdsByAdminId(adminId int) (items []*SysRoleAdmin, err error) {
  17. sql := `SELECT * from sys_role_admin where admin_id = ?`
  18. _, err = orm.NewOrm().Raw(sql, adminId).QueryRows(&items)
  19. return
  20. }