project flow completed

This commit is contained in:
hysn99
2024-04-15 14:50:36 +03:00
parent a5612d6d9e
commit bfcb484104
9 changed files with 143 additions and 58 deletions

View File

@@ -5,6 +5,7 @@ import (
)
type Company struct {
Id int `db:"id"`
Name string `db:"name"`
MemberNumber string `db:"member_number"`
Username string `db:"username"`
@@ -24,6 +25,17 @@ VALUES (:name, :member_number, :username, :password)
_, err := run.DB.NamedExec(sq, &c)
return err
}
func (c *Company) Edit() error {
sq := `
UPDATE company SET
name = :name,
member_number = :member_number,
username = :username,
password = :password
WHERE id = :id;`
_, err := run.DB.NamedExec(sq, &c)
return err
}
//func GetCompany(companyName string) (Company, error) {
// sq := `
@@ -37,13 +49,13 @@ VALUES (:name, :member_number, :username, :password)
//}
//
func GetCompany(companyName string) (Company, error) {
func GetCompany(companyID float64) (Company, error) {
var company Company
sq := `
SELECT * FROM company WHERE name = ?
SELECT * FROM company WHERE id = ?
`
err := run.DB.Get(&company, sq, companyName)
err := run.DB.Get(&company, sq, companyID)
if err != nil {
return Company{}, err
}