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 {
|
type Company struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
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"`
|
Contact *string `json:"contact,omitempty"`
|
||||||
Status string `json:"status"` // "ACTIVE", "INACTIVE"
|
Status string `json:"status"` // "ACTIVE", "INACTIVE"
|
||||||
|
|
@ -18,6 +19,7 @@ func NewCompany(id, name string, document, contact *string) *Company {
|
||||||
return &Company{
|
return &Company{
|
||||||
ID: id,
|
ID: id,
|
||||||
Name: name,
|
Name: name,
|
||||||
|
Type: "COMPANY",
|
||||||
Document: document,
|
Document: document,
|
||||||
Contact: contact,
|
Contact: contact,
|
||||||
Status: "ACTIVE",
|
Status: "ACTIVE",
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ func (uc *RegisterCandidateUseCase) Execute(ctx context.Context, input dto.Regis
|
||||||
nil, // No document for candidates
|
nil, // No document for candidates
|
||||||
nil, // No contact - will use user's contact info
|
nil, // No contact - will use user's contact info
|
||||||
)
|
)
|
||||||
|
candidateCompany.Type = "CANDIDATE_WORKSPACE"
|
||||||
|
|
||||||
savedCompany, err := uc.companyRepo.Save(ctx, candidateCompany)
|
savedCompany, err := uc.companyRepo.Save(ctx, candidateCompany)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -25,12 +25,17 @@ func (r *CompanyRepository) Save(ctx context.Context, company *entity.Company) (
|
||||||
RETURNING id
|
RETURNING id
|
||||||
`
|
`
|
||||||
|
|
||||||
|
var compType = company.Type
|
||||||
|
if compType == "" {
|
||||||
|
compType = "company"
|
||||||
|
}
|
||||||
|
|
||||||
slug := company.Name // TODO: slugify function
|
slug := company.Name // TODO: slugify function
|
||||||
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",
|
compType,
|
||||||
company.Document,
|
company.Document,
|
||||||
company.Contact, // mapped to email
|
company.Contact, // mapped to email
|
||||||
"{}", // description as JSON
|
"{}", // description as JSON
|
||||||
|
|
@ -94,7 +99,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
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,10 @@ func (s *AdminService) ListCompanies(ctx context.Context, verified *bool, page,
|
||||||
offset := (page - 1) * limit
|
offset := (page - 1) * limit
|
||||||
|
|
||||||
// Count Total
|
// 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{}
|
var countArgs []interface{}
|
||||||
if verified != nil {
|
if verified != nil {
|
||||||
countQuery += " WHERE verified = $1"
|
countQuery += " AND verified = $1"
|
||||||
countArgs = append(countArgs, *verified)
|
countArgs = append(countArgs, *verified)
|
||||||
}
|
}
|
||||||
var total int
|
var total int
|
||||||
|
|
@ -40,11 +40,12 @@ 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 = 'company' OR type = 'COMPANY' OR type IS NULL)
|
||||||
`
|
`
|
||||||
|
|
||||||
var args []interface{}
|
var args []interface{}
|
||||||
if verified != nil {
|
if verified != nil {
|
||||||
baseQuery += " WHERE verified = $1"
|
baseQuery += " AND verified = $1"
|
||||||
args = append(args, *verified)
|
args = append(args, *verified)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue