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

View file

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

View file

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