update of posotion by trade his

This commit is contained in:
samantha42
2026-03-26 11:42:38 +01:00
parent 3f878c1dc0
commit 2c24ee48b0
7 changed files with 156 additions and 30 deletions

View File

@@ -8,6 +8,22 @@ import (
_ "github.com/mattn/go-sqlite3"
)
func GetCompanyBySymbol(db *sql.DB, symbol string) (*model.Company, error) {
var c model.Company
err := db.QueryRow(
`SELECT id, symbol, shares_outstanding, price, currency_id FROM companies WHERE symbol = ?`,
symbol,
).Scan(&c.ID, &c.Symbol, &c.SharesOutstanding, &c.Price, &c.CurrencyID)
if err == sql.ErrNoRows {
return nil, nil
}
if err != nil {
return nil, fmt.Errorf("query company: %w", err)
}
return &c, nil
}
func GetCompanyByID(db *sql.DB, id int) (*model.Company, error) {
var c model.Company
err := db.QueryRow(