1
0
mirror of https://github.com/raseels-repos/golang-saas-starter-kit.git synced 2025-08-08 22:36:41 +02:00

Use interface in the handlers of web-api/web-app

This commit is contained in:
huyng
2019-08-17 11:03:48 +07:00
committed by seta-davenguyen
parent 102ca82125
commit d277b0ec25
26 changed files with 294 additions and 163 deletions

View File

@ -2,8 +2,8 @@ package geonames
import (
"context"
"github.com/huandu/go-sqlbuilder"
"github.com/jmoiron/sqlx"
"github.com/pkg/errors"
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
)
@ -14,7 +14,7 @@ const (
)
// FindCountries ....
func FindCountries(ctx context.Context, dbConn *sqlx.DB, orderBy, where string, args ...interface{}) ([]*Country, error) {
func (repo *Repository) FindCountries(ctx context.Context, orderBy, where string, args ...interface{}) ([]*Country, error) {
span, ctx := tracer.StartSpanFromContext(ctx, "internal.geonames.FindCountries")
defer span.Finish()
@ -32,11 +32,11 @@ func FindCountries(ctx context.Context, dbConn *sqlx.DB, orderBy, where string,
}
queryStr, queryArgs := query.Build()
queryStr = dbConn.Rebind(queryStr)
queryStr = repo.DbConn.Rebind(queryStr)
args = append(args, queryArgs...)
// fetch all places from the db
rows, err := dbConn.QueryContext(ctx, queryStr, args...)
rows, err := repo.DbConn.QueryContext(ctx, queryStr, args...)
if err != nil {
err = errors.Wrapf(err, "query - %s", query.String())
err = errors.WithMessage(err, "find countries failed")