auth_role.go 455 B

12345678910111213141516171819202122
  1. package manager
  2. import (
  3. "context"
  4. "database/sql"
  5. "go-common/library/log"
  6. )
  7. const (
  8. _getUserRoleSQL = "SELECT `role` FROM `auth_role` WHERE uid = ?"
  9. )
  10. // GetUserRole 用户角色
  11. func (d *Dao) GetUserRole(c context.Context, uid int64) (role int8, err error) {
  12. err = d.managerDB.QueryRow(c, _getUserRoleSQL, uid).Scan(&role)
  13. if err != nil && err != sql.ErrNoRows {
  14. log.Error("d.managerDB.Query error(%v)", err)
  15. return
  16. }
  17. return role, nil
  18. }