-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:dwarvesf/template-go
* 'master' of github.com:dwarvesf/template-go: move implement of a service from pg to service (#1)
- Loading branch information
Showing
2 changed files
with
7 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,24 @@ | ||
package postgres | ||
package add | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/jinzhu/gorm" | ||
|
||
"<%= domainDir + _.folderName %>/service/add" | ||
) | ||
|
||
type addStore struct { | ||
type pgStore struct { | ||
db *gorm.DB | ||
} | ||
|
||
// NewAddStore ... | ||
func NewAddStore(db *gorm.DB) *addStore { | ||
return &addStore{ | ||
// NewPGStore create new project store | ||
func NewPGStore(db *gorm.DB) Service { | ||
return &pgStore{ | ||
db: db, | ||
} | ||
} | ||
|
||
// Add just do a plus with 2 vars (X+Y) for the sake of demonstration, in reallity | ||
// you would want to execute a DB query/transaction here | ||
func (s *addStore) Add(ctx context.Context, arg *add.Add) (int, error) { | ||
func (s *pgStore) Add(ctx context.Context, arg *Add) (int, error) { | ||
return arg.X + arg.Y, nil | ||
} |