Skip to content

Commit

Permalink
Adding code to store profile vendors
Browse files Browse the repository at this point in the history
  • Loading branch information
la3lma committed Nov 14, 2019
1 parent 6107ddb commit 3535ba6
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions sim-administration/sim-batch-management/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ import (
"strconv"
)



type SimBatchDB struct {
Db *sqlx.DB
}

type Store interface {
GenerateTables() error
DropTables() error
Expand Down Expand Up @@ -61,9 +67,7 @@ func (sdb *SimBatchDB) Begin() *sql.Tx {
return tx
}

type SimBatchDB struct {
Db *sqlx.DB
}


func NewInMemoryDatabase() (*SimBatchDB, error) {
db, err := sqlx.Connect("sqlite3", ":memory:")
Expand Down Expand Up @@ -175,9 +179,9 @@ func (sdb *SimBatchDB) GenerateTables() error {
sql = `CREATE TABLE IF NOT EXISTS PROFILE_VENDOR (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR NOT NULL UNIQUE,
es2PlusCertPath VARCHAR
es2PlusKeyPath VARCHAR
es2PlusHostPath VARCHAR
es2PlusCertPath VARCHAR,
es2PlusKeyPath VARCHAR,
es2PlusHostPath VARCHAR,
es2PlusPort VARCHAR
)`
_, err = sdb.Db.Exec(sql)
Expand All @@ -204,7 +208,7 @@ func (sdb SimBatchDB) CreateProfileVendor(theEntry *model.ProfileVendor) error {

func (sdb SimBatchDB) GetProfileVendorById(id int64) (*model.ProfileVendor, error) {
result := []model.ProfileVendor{}
if err := sdb.Db.Select(&result, "select * from SIM_PROFILE where id = ?", id); err != nil {
if err := sdb.Db.Select(&result, "select * from PROFILE_VENDOR where id = ?", id); err != nil {
return nil, err
}

Expand All @@ -217,7 +221,7 @@ func (sdb SimBatchDB) GetProfileVendorById(id int64) (*model.ProfileVendor, erro

func (sdb SimBatchDB) GetProfileVendorByName(name string) (*model.ProfileVendor, error) {
result := []model.ProfileVendor{}
if err := sdb.Db.Select(&result, "select * from SIM_PROFILE where name = ?", name); err != nil {
if err := sdb.Db.Select(&result, "select * from PROFILE_VENDOR where name = ?", name); err != nil {
return nil, err
}

Expand Down

0 comments on commit 3535ba6

Please sign in to comment.