project flow completed
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user