A
Merge branch 'dev' of https://forgejo-gru.rede5.com.br/rede5/gohorsejobs into dev
This commit is contained in:
commit
31923c97be
4 changed files with 15 additions and 5 deletions
|
|
@ -6,6 +6,7 @@ import "time"
|
|||
type Company struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"` // "COMPANY", "CANDIDATE_WORKSPACE"
|
||||
Document *string `json:"document,omitempty"` // CNPJ, EIN, VAT
|
||||
Contact *string `json:"contact,omitempty"`
|
||||
Status string `json:"status"` // "ACTIVE", "INACTIVE"
|
||||
|
|
@ -18,6 +19,7 @@ func NewCompany(id, name string, document, contact *string) *Company {
|
|||
return &Company{
|
||||
ID: id,
|
||||
Name: name,
|
||||
Type: "COMPANY",
|
||||
Document: document,
|
||||
Contact: contact,
|
||||
Status: "ACTIVE",
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ func (uc *RegisterCandidateUseCase) Execute(ctx context.Context, input dto.Regis
|
|||
nil, // No document for candidates
|
||||
nil, // No contact - will use user's contact info
|
||||
)
|
||||
candidateCompany.Type = "CANDIDATE_WORKSPACE"
|
||||
|
||||
savedCompany, err := uc.companyRepo.Save(ctx, candidateCompany)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -25,12 +25,17 @@ func (r *CompanyRepository) Save(ctx context.Context, company *entity.Company) (
|
|||
RETURNING id
|
||||
`
|
||||
|
||||
var compType = company.Type
|
||||
if compType == "" {
|
||||
compType = "company"
|
||||
}
|
||||
|
||||
slug := company.Name // TODO: slugify function
|
||||
var id string
|
||||
err := r.db.QueryRowContext(ctx, query,
|
||||
company.Name,
|
||||
slug,
|
||||
"company",
|
||||
compType,
|
||||
company.Document,
|
||||
company.Contact, // mapped to email
|
||||
"{}", // description as JSON
|
||||
|
|
@ -94,7 +99,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
|
||||
|
|
|
|||
|
|
@ -25,10 +25,10 @@ func (s *AdminService) ListCompanies(ctx context.Context, verified *bool, page,
|
|||
offset := (page - 1) * limit
|
||||
|
||||
// Count Total
|
||||
countQuery := `SELECT COUNT(*) FROM companies`
|
||||
countQuery := `SELECT COUNT(*) FROM companies WHERE (type = 'company' OR type = 'COMPANY' OR type IS NULL)`
|
||||
var countArgs []interface{}
|
||||
if verified != nil {
|
||||
countQuery += " WHERE verified = $1"
|
||||
countQuery += " AND verified = $1"
|
||||
countArgs = append(countArgs, *verified)
|
||||
}
|
||||
var total int
|
||||
|
|
@ -40,11 +40,12 @@ 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 = 'company' OR type = 'COMPANY' OR type IS NULL)
|
||||
`
|
||||
|
||||
var args []interface{}
|
||||
if verified != nil {
|
||||
baseQuery += " WHERE verified = $1"
|
||||
baseQuery += " AND verified = $1"
|
||||
args = append(args, *verified)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue