database changes
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package psql
|
||||
|
||||
import (
|
||||
"git.nix13.pw/scuroneko/laniakea"
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/vinovest/sqlx"
|
||||
)
|
||||
@@ -36,47 +37,48 @@ type ShopRepository struct {
|
||||
db *sqlx.DB
|
||||
}
|
||||
|
||||
func NewShopRepository(db *sqlx.DB) *ShopRepository {
|
||||
return &ShopRepository{db: db}
|
||||
func NewShopRepository(db *laniakea.DatabaseContext) ShopRepository {
|
||||
return newShopRepository(db.PostgresSQL)
|
||||
}
|
||||
func newShopRepository(db *sqlx.DB) ShopRepository { return ShopRepository{db} }
|
||||
|
||||
func (rep *ShopRepository) GetAllAuto() ([]*ShopAuto, error) {
|
||||
auto := make([]*ShopAuto, 0)
|
||||
func (rep ShopRepository) GetAllAuto() ([]ShopAuto, error) {
|
||||
auto := make([]ShopAuto, 0)
|
||||
err := rep.db.Select(&auto, "SELECT * FROM shop_auto ORDER BY id DESC;")
|
||||
return auto, err
|
||||
}
|
||||
func (rep *ShopRepository) GetAuto(id int32) (*ShopAuto, error) {
|
||||
auto := new(ShopAuto)
|
||||
err := rep.db.Get(auto, "SELECT * FROM shop_auto WHERE id = $1;", id)
|
||||
func (rep ShopRepository) GetAuto(id int32) (ShopAuto, error) {
|
||||
auto := ShopAuto{}
|
||||
err := rep.db.Get(&auto, "SELECT * FROM shop_auto WHERE id = $1;", id)
|
||||
return auto, err
|
||||
}
|
||||
func (rep *ShopRepository) GetAllBusinesses() ([]*ShopBusiness, error) {
|
||||
businesses := make([]*ShopBusiness, 0)
|
||||
func (rep ShopRepository) GetAllBusinesses() ([]ShopBusiness, error) {
|
||||
businesses := make([]ShopBusiness, 0)
|
||||
err := rep.db.Select(&businesses, "SELECT * FROM shop_business ORDER BY id DESC;")
|
||||
return businesses, err
|
||||
}
|
||||
func (rep *ShopRepository) GetBusiness(id int32) (*ShopBusiness, error) {
|
||||
business := new(ShopBusiness)
|
||||
err := rep.db.Get(business, "SELECT * FROM shop_business WHERE id = $1;", id)
|
||||
func (rep ShopRepository) GetBusiness(id int32) (ShopBusiness, error) {
|
||||
business := ShopBusiness{}
|
||||
err := rep.db.Get(&business, "SELECT * FROM shop_business WHERE id = $1;", id)
|
||||
return business, err
|
||||
}
|
||||
func (rep *ShopRepository) GetAllMaids() ([]*ShopMaid, error) {
|
||||
maids := make([]*ShopMaid, 0)
|
||||
func (rep ShopRepository) GetAllMaids() ([]ShopMaid, error) {
|
||||
maids := make([]ShopMaid, 0)
|
||||
err := rep.db.Select(&maids, "SELECT * FROM shop_maid ORDER BY id DESC;")
|
||||
return maids, err
|
||||
}
|
||||
func (rep *ShopRepository) GetMaid(id int32) (*ShopMaid, error) {
|
||||
maid := new(ShopMaid)
|
||||
err := rep.db.Get(maid, "SELECT * FROM shop_maid WHERE id = $1;", id)
|
||||
func (rep ShopRepository) GetMaid(id int32) (ShopMaid, error) {
|
||||
maid := ShopMaid{}
|
||||
err := rep.db.Get(&maid, "SELECT * FROM shop_maid WHERE id = $1;", id)
|
||||
return maid, err
|
||||
}
|
||||
func (rep *ShopRepository) GetAllMiners() ([]*ShopMiner, error) {
|
||||
miners := make([]*ShopMiner, 0)
|
||||
func (rep ShopRepository) GetAllMiners() ([]ShopMiner, error) {
|
||||
miners := make([]ShopMiner, 0)
|
||||
err := rep.db.Select(&miners, "SELECT * FROM shop_miner ORDER BY id DESC;")
|
||||
return miners, err
|
||||
}
|
||||
func (rep *ShopRepository) GetMiner(id int32) (*ShopMiner, error) {
|
||||
miner := new(ShopMiner)
|
||||
err := rep.db.Get(miner, "SELECT * FROM shop_miner WHERE id = $1;", id)
|
||||
func (rep ShopRepository) GetMiner(id int32) (ShopMiner, error) {
|
||||
miner := ShopMiner{}
|
||||
err := rep.db.Get(&miner, "SELECT * FROM shop_miner WHERE id = $1;", id)
|
||||
return miner, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user