Implement storage logic
This commit is contained in:
parent
deda3fc12d
commit
cb8435b652
|
@ -37,3 +37,26 @@ func InsertCardPrinting(db *sql.DB, cardPrinting CardPrinting) error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetAllCardPrintings(db *sql.DB) ([]CardPrinting, error) {
|
||||
var cardPrintings []CardPrinting
|
||||
|
||||
query := `SELECT Id, Name, SetCode, IsFoil, IsPromo, CollectorNumber, Language FROM CardPrinting;`
|
||||
rows, err := db.Query(query)
|
||||
defer rows.Close()
|
||||
if err != nil {
|
||||
return cardPrintings, err
|
||||
}
|
||||
|
||||
var printing CardPrinting
|
||||
for rows.Next() {
|
||||
err := rows.Scan(&printing.Id, &printing.Name, &printing.SetCode, &printing.IsFoil, &printing.IsPromo, &printing.CollectorNumber, &printing.Language)
|
||||
if err != nil {
|
||||
return cardPrintings, err
|
||||
}
|
||||
|
||||
cardPrintings = append(cardPrintings, printing)
|
||||
}
|
||||
|
||||
return cardPrintings, nil
|
||||
}
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
package operations
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"sevenkeys/database/entities"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func GetCardSearchOptions(db *sql.DB) ([]string, error) {
|
||||
var searchOptions []string
|
||||
|
||||
query := "SELECT Id, Name, SetCode, HasFoil, HasNonFoil, CollectorNumber, Language FROM CardPrinting;"
|
||||
rows, err := db.Query(query)
|
||||
defer rows.Close()
|
||||
if err != nil {
|
||||
return searchOptions, err
|
||||
}
|
||||
|
||||
var printing entities.CardPrinting
|
||||
for rows.Next() {
|
||||
err := rows.Scan(&printing.Id,
|
||||
&printing.Name,
|
||||
&printing.SetCode,
|
||||
&printing.HasFoil,
|
||||
&printing.HasNonFoil,
|
||||
&printing.CollectorNumber,
|
||||
&printing.Language)
|
||||
if err != nil {
|
||||
return searchOptions, err
|
||||
}
|
||||
|
||||
// TODO: Make this configurable to be able to handle non-English cards
|
||||
if printing.Language != "en" {
|
||||
continue
|
||||
}
|
||||
|
||||
if printing.HasNonFoil {
|
||||
searchOption := fmt.Sprintf("%s | %s (%s %s)",
|
||||
printing.Id,
|
||||
printing.Name,
|
||||
strings.ToUpper(printing.SetCode),
|
||||
printing.CollectorNumber)
|
||||
searchOptions = append(searchOptions, searchOption)
|
||||
}
|
||||
|
||||
if printing.HasFoil {
|
||||
searchOption := fmt.Sprintf("%s | %s (%s %s) FOIL",
|
||||
printing.Id,
|
||||
printing.Name,
|
||||
strings.ToUpper(printing.SetCode),
|
||||
printing.CollectorNumber)
|
||||
searchOptions = append(searchOptions, searchOption)
|
||||
}
|
||||
}
|
||||
|
||||
return searchOptions, nil
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package logic
|
||||
|
||||
import "fmt"
|
||||
|
||||
func GetStorageLocation() string {
|
||||
fmt.Print("Enter storage location: ")
|
||||
|
||||
var response string
|
||||
fmt.Scan(&response)
|
||||
|
||||
return response
|
||||
}
|
|
@ -36,4 +36,10 @@ func main() {
|
|||
} else {
|
||||
fmt.Println("No update required.")
|
||||
}
|
||||
|
||||
storageLocation := logic.GetStorageLocation()
|
||||
|
||||
for {
|
||||
//name := logic.GetCardName
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue