This commit is contained in:
parent
a098baa253
commit
950fa9fd96
4 changed files with 60 additions and 0 deletions
|
|
@ -10,6 +10,7 @@ type Repository interface {
|
|||
getUserId(ctx context.Context, userUuid string) (int64, error)
|
||||
addUser(ctx context.Context, u *userModel) error
|
||||
deleteUser(ctx context.Context, userUuid string, deletedAt sql.NullTime) error
|
||||
getUser(ctx context.Context, userUuid string) (*MeDTO, error)
|
||||
}
|
||||
|
||||
type repo struct {
|
||||
|
|
@ -47,3 +48,14 @@ func (r *repo) deleteUser(ctx context.Context, userUuid string, deletedAt sql.Nu
|
|||
_, err := r.db.Exec(ctx, q, deletedAt, userUuid)
|
||||
return err
|
||||
}
|
||||
|
||||
func (r *repo) getUser(ctx context.Context, userUuid string) (*MeDTO, error) {
|
||||
q := `SELECT uuid FROM users WHERE uuid = $1 AND deleted_at IS NULL LIMIT 1`
|
||||
row := r.db.QueryRow(ctx, q, userUuid)
|
||||
u := &MeDTO{}
|
||||
|
||||
if err := row.Scan(&u.UserUuid); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return u, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue