camper/pkg/auth/company.go

31 lines
534 B
Go

/*
* SPDX-FileCopyrightText: 2023 jordi fita mas <jfita@peritasoft.com>
* SPDX-License-Identifier: AGPL-3.0-only
*/
package auth
import (
"context"
"dev.tandem.ws/tandem/camper/pkg/database"
)
type Company struct {
ID int
}
func CompanyByHost(ctx context.Context, conn *database.Conn, host string) (*Company, error) {
company := &Company{}
if err := conn.QueryRow(ctx, `
select company_id
from company_host
where host = $1
`, host).Scan(
&company.ID,
); err != nil {
return nil, err
}
return company, nil
}