|
|
@@ -46,8 +46,8 @@ func NewSysUserRoleModel(conn sqlx.SqlConn, c cache.CacheConf, cachePrefix strin
|
|
|
// 仅在超管未带产品上下文时通过 UserDetail 调用,返回结果不区分产品归属。
|
|
|
func (m *customSysUserRoleModel) FindRoleIdsByUserId(ctx context.Context, userId int64) ([]int64, error) {
|
|
|
var ids []int64
|
|
|
- query := fmt.Sprintf("SELECT `roleId` FROM %s WHERE `userId` = ?", m.table)
|
|
|
- if err := m.QueryRowsNoCacheCtx(ctx, &ids, query, userId); err != nil {
|
|
|
+ query := fmt.Sprintf("SELECT ur.`roleId` FROM %s ur INNER JOIN `sys_role` r ON ur.`roleId` = r.`id` WHERE ur.`userId` = ? AND r.`status` = ?", m.table)
|
|
|
+ if err := m.QueryRowsNoCacheCtx(ctx, &ids, query, userId, consts.StatusEnabled); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
return ids, nil
|