Company now works

This commit is contained in:
2024-11-04 07:35:24 +01:00
parent ddebbad1c8
commit 51b0641702
12 changed files with 498 additions and 10 deletions

36
db/company.go Normal file
View File

@@ -0,0 +1,36 @@
package db
type Company struct {
ID int
UUID string
Name string
Email string
TaxId string
Password string
}
// InsertCompany inserts a new record into the Company table
func InsertCompany(company Company) (int, error) {
query := `
INSERT INTO Company (UUID, Name, Email, TaxId, Password)
VALUES (?, ?, ?, ?, ?)
RETURNING id
`
stmt, err := db.Prepare(query)
if err != nil {
return -2, err
}
defer stmt.Close()
id := 0
err = stmt.QueryRow(
company.UUID, company.Name, company.Email, company.TaxId, company.Password,
).Scan(&id)
if err != nil {
return -1, err
}
return id, nil
}