user package
This commit is contained in:
parent
f962cd8cd9
commit
f159014374
4 changed files with 84 additions and 0 deletions
29
internal/user/repository.go
Normal file
29
internal/user/repository.go
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
package user
|
||||
|
||||
import "database/sql"
|
||||
|
||||
type Repository interface {
|
||||
getUserId(userUuid string) (string, error)
|
||||
}
|
||||
|
||||
type repo struct {
|
||||
db *sql.DB
|
||||
}
|
||||
|
||||
func newRepository(db *sql.DB) Repository {
|
||||
return &repo{
|
||||
db: db,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *repo) getUserId(userUuid string) (string, error) {
|
||||
q := `SELECT id FROM users WHERE uuid = $1 AND deleted_at IS NULL LIMIT 1`
|
||||
row := r.db.QueryRow(q, userUuid)
|
||||
|
||||
var id string
|
||||
if err := row.Scan(&id); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return id, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue