Merge branch 'dev' into task5: resolved conflicts

This commit is contained in:
NANDO9322 2026-01-08 17:57:06 -03:00
commit 4ba3957b50
3 changed files with 12 additions and 7 deletions

View file

@ -7,13 +7,13 @@ type Company struct {
ID string `json:"id"`
Name string `json:"name"`
Slug string `json:"slug"`
Type string `json:"type"` // "COMPANY", "CANDIDATE_WORKSPACE"
Document *string `json:"document,omitempty"` // CNPJ, EIN, VAT
Contact *string `json:"contact,omitempty"` // Email
Phone *string `json:"phone,omitempty"`
Website *string `json:"website,omitempty"`
Address *string `json:"address,omitempty"`
Description *string `json:"description,omitempty"`
Type string `json:"type"` // "COMPANY", "CANDIDATE_WORKSPACE"
Status string `json:"status"` // "ACTIVE", "INACTIVE"
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
@ -24,7 +24,7 @@ func NewCompany(id, name string, document, contact *string) *Company {
return &Company{
ID: id,
Name: name,
Slug: name, // Basic slug, repo might refine
Slug: name,
Type: "COMPANY",
Document: document,
Contact: contact,

View file

@ -30,13 +30,17 @@ func (r *CompanyRepository) Save(ctx context.Context, company *entity.Company) (
if slug == "" {
slug = company.Name
}
// TODO: better slugify logic in service/entity
var compType = company.Type
if compType == "" {
compType = "company"
}
var id string
err := r.db.QueryRowContext(ctx, query,
company.Name,
slug,
company.Type,
compType,
company.Document,
company.Contact, // email
company.Phone,
@ -103,7 +107,8 @@ func (r *CompanyRepository) FindAll(ctx context.Context) ([]*entity.Company, err
query := `SELECT id, name, document, email,
CASE WHEN active THEN 'ACTIVE' ELSE 'INACTIVE' END as status,
created_at, updated_at
FROM companies`
FROM companies
WHERE type = 'company' OR type = 'COMPANY'`
rows, err := r.db.QueryContext(ctx, query)
if err != nil {
return nil, err

View file

@ -26,7 +26,7 @@ func (s *AdminService) ListCompanies(ctx context.Context, verified *bool, page,
// Count Total
// Count Total
countQuery := `SELECT COUNT(*) FROM companies WHERE type != 'CANDIDATE_WORKSPACE'`
countQuery := `SELECT COUNT(*) FROM companies WHERE (type = 'company' OR type = 'COMPANY' OR type IS NULL)`
var countArgs []interface{}
if verified != nil {
countQuery += " AND verified = $1"
@ -41,7 +41,7 @@ func (s *AdminService) ListCompanies(ctx context.Context, verified *bool, page,
baseQuery := `
SELECT id, name, slug, type, document, address, region_id, city_id, phone, email, website, logo_url, description, active, verified, created_at, updated_at
FROM companies
WHERE type != 'CANDIDATE_WORKSPACE'
WHERE (type = 'company' OR type = 'COMPANY' OR type IS NULL)
`
var args []interface{}