Upstream sync
This commit is contained in:
@@ -20,16 +20,17 @@ var (
|
||||
|
||||
// Conn is the MySQL connection manager
|
||||
type Conn struct {
|
||||
db *sql.DB
|
||||
users *userRepo
|
||||
rides *rideRepo
|
||||
visit *visitRepo
|
||||
provider *providerRepo
|
||||
notification *notificationRepo
|
||||
profile *profileRepo
|
||||
organization *organizationRepo
|
||||
zipcodes *zipcodeRepo
|
||||
plan *planRepo
|
||||
db *sql.DB
|
||||
users *userRepo
|
||||
rides *rideRepo
|
||||
visit *visitRepo
|
||||
provider *providerRepo
|
||||
notification *notificationRepo
|
||||
profile *profileRepo
|
||||
organization *organizationRepo
|
||||
zipcodes *zipcodeRepo
|
||||
plan *planRepo
|
||||
passwordReset *passwordResetRepo
|
||||
}
|
||||
|
||||
// Begin starts a transaction
|
||||
@@ -90,6 +91,10 @@ func (c *Conn) Plans() contract.PlanRepo {
|
||||
return c.plan
|
||||
}
|
||||
|
||||
func (c *Conn) PasswordReset() contract.PasswordResetRepo {
|
||||
return c.passwordReset
|
||||
}
|
||||
|
||||
// Instance returns an instance of a DataManager
|
||||
func Instance(cfg *config.Config) (contract.DataManager, error) {
|
||||
once.Do(func() {
|
||||
@@ -123,6 +128,7 @@ func Instance(cfg *config.Config) (contract.DataManager, error) {
|
||||
instance.organization = newOrganizationRepo(db)
|
||||
instance.zipcodes = newZipcodeRepo(db)
|
||||
instance.plan = newPlanRepo(db)
|
||||
instance.passwordReset = newPasswordResetRepo(db)
|
||||
})
|
||||
|
||||
return instance, connErr
|
||||
|
||||
@@ -8,16 +8,17 @@ import (
|
||||
)
|
||||
|
||||
type transaction struct {
|
||||
tx *sql.Tx
|
||||
users *userRepo
|
||||
rides *rideRepo
|
||||
visits *visitRepo
|
||||
provider *providerRepo
|
||||
notification *notificationRepo
|
||||
profile *profileRepo
|
||||
organization *organizationRepo
|
||||
zipcodes *zipcodeRepo
|
||||
plan *planRepo
|
||||
tx *sql.Tx
|
||||
users *userRepo
|
||||
rides *rideRepo
|
||||
visits *visitRepo
|
||||
provider *providerRepo
|
||||
notification *notificationRepo
|
||||
profile *profileRepo
|
||||
organization *organizationRepo
|
||||
zipcodes *zipcodeRepo
|
||||
plan *planRepo
|
||||
passwordReset *passwordResetRepo
|
||||
}
|
||||
|
||||
func newTransaction(tx *sql.Tx) *transaction {
|
||||
@@ -34,6 +35,7 @@ func newTransaction(tx *sql.Tx) *transaction {
|
||||
t.organization = newOrganizationRepo(tx)
|
||||
t.zipcodes = newZipcodeRepo(tx)
|
||||
t.plan = newPlanRepo(tx)
|
||||
t.passwordReset = newPasswordResetRepo(tx)
|
||||
|
||||
return t
|
||||
}
|
||||
@@ -81,6 +83,10 @@ func (t transaction) Plans() contract.PlanRepo {
|
||||
return t.plan
|
||||
}
|
||||
|
||||
func (t transaction) PasswordReset() contract.PasswordResetRepo {
|
||||
return t.passwordReset
|
||||
}
|
||||
|
||||
func (t *transaction) Commit() error {
|
||||
|
||||
err := t.tx.Commit()
|
||||
|
||||
@@ -48,6 +48,32 @@ func (c *userRepo) GetByMemberID(memberID string) (entity.User, error) {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *userRepo) GetByEmail(email string) (entity.User, error) {
|
||||
finalQuery := c.getQuery() + " AND b.email = ?"
|
||||
|
||||
user, err := c.parseSet(c.conn.Query(finalQuery, email))
|
||||
if err != nil {
|
||||
return entity.User{}, err
|
||||
}
|
||||
|
||||
if len(user) > 0 {
|
||||
retVal := user[0]
|
||||
retVal.Contacts, err = c.GetContacts(retVal.ID)
|
||||
if err != nil {
|
||||
return entity.User{}, err
|
||||
}
|
||||
|
||||
retVal.Addresses = nil
|
||||
retVal.Addresses, err = c.getAddressByUserID(retVal.ID)
|
||||
if err != nil {
|
||||
return entity.User{}, err
|
||||
}
|
||||
return retVal, nil
|
||||
} else {
|
||||
return entity.User{}, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *userRepo) GetByUUID(uuid string, profile string) (entity.User, error) {
|
||||
params := make([]interface{}, 0)
|
||||
params = append(params, uuid)
|
||||
|
||||
Reference in New Issue
Block a user