You've already forked golang-saas-starter-kit
mirror of
https://github.com/raseels-repos/golang-saas-starter-kit.git
synced 2025-08-08 22:36:41 +02:00
Completed updating biz logic packages to use repository pattern
This commit is contained in:
@ -9,25 +9,24 @@ import (
|
||||
"geeks-accelerator/oss/saas-starter-kit/internal/platform/web/webcontext"
|
||||
"geeks-accelerator/oss/saas-starter-kit/internal/user"
|
||||
"geeks-accelerator/oss/saas-starter-kit/internal/user_account"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
|
||||
)
|
||||
|
||||
// Signup performs the steps needed to create a new account, new user and then associate
|
||||
// both records with a new user_account entry.
|
||||
func Signup(ctx context.Context, claims auth.Claims, dbConn *sqlx.DB, req SignupRequest, now time.Time) (*SignupResult, error) {
|
||||
func (repo *Repository) Signup(ctx context.Context, claims auth.Claims, req SignupRequest, now time.Time) (*SignupResult, error) {
|
||||
span, ctx := tracer.StartSpanFromContext(ctx, "internal.signup.Signup")
|
||||
defer span.Finish()
|
||||
|
||||
// Validate the user email address is unique in the database.
|
||||
uniqEmail, err := user.UniqueEmail(ctx, dbConn, req.User.Email, "")
|
||||
uniqEmail, err := user.UniqueEmail(ctx, repo.DbConn, req.User.Email, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ctx = webcontext.ContextAddUniqueValue(ctx, req.User, "Email", uniqEmail)
|
||||
|
||||
// Validate the account name is unique in the database.
|
||||
uniqName, err := account.UniqueName(ctx, dbConn, req.Account.Name, "")
|
||||
uniqName, err := account.UniqueName(ctx, repo.DbConn, req.Account.Name, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -52,7 +51,7 @@ func Signup(ctx context.Context, claims auth.Claims, dbConn *sqlx.DB, req Signup
|
||||
}
|
||||
|
||||
// Execute user creation.
|
||||
resp.User, err = user.Create(ctx, claims, dbConn, userReq, now)
|
||||
resp.User, err = repo.User.Create(ctx, claims, userReq, now)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -73,7 +72,7 @@ func Signup(ctx context.Context, claims auth.Claims, dbConn *sqlx.DB, req Signup
|
||||
}
|
||||
|
||||
// Execute account creation.
|
||||
resp.Account, err = account.Create(ctx, claims, dbConn, accountReq, now)
|
||||
resp.Account, err = repo.Account.Create(ctx, claims, accountReq, now)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -87,7 +86,7 @@ func Signup(ctx context.Context, claims auth.Claims, dbConn *sqlx.DB, req Signup
|
||||
//Status: Use default value
|
||||
}
|
||||
|
||||
_, err = user_account.Create(ctx, claims, dbConn, ua, now)
|
||||
_, err = repo.UserAccount.Create(ctx, claims, ua, now)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user