-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
50479e8
commit 5dfdcc7
Showing
10 changed files
with
117 additions
and
121 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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) 2023 Isaque Veras | ||
// Use of this source code is governed by a MIT style | ||
// license that can be found in the LICENSE file. | ||
|
||
package auth | ||
|
||
import ( | ||
"github.com/google/uuid" | ||
"github.com/isaqueveras/powersso/database/postgres" | ||
domain "github.com/isaqueveras/powersso/domain/auth" | ||
infra "github.com/isaqueveras/powersso/infrastructure/persistencie/auth/postgres" | ||
) | ||
|
||
var _ domain.IFlag = (*repoFlag)(nil) | ||
|
||
type repoFlag struct{ pg *infra.PGFlag } | ||
|
||
func NewFlagRepo(tx *postgres.Transaction) domain.IFlag { | ||
return &repoFlag{pg: &infra.PGFlag{DB: tx}} | ||
} | ||
|
||
func (r *repoFlag) Set(userID *uuid.UUID, flag *domain.Flag) error { | ||
return r.pg.Set(userID, flag) | ||
} | ||
|
||
func (r *repoFlag) Get(userID *uuid.UUID) (*int64, error) { | ||
return r.pg.Get(userID) | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package postgres | ||
|
||
import ( | ||
"github.com/google/uuid" | ||
"github.com/isaqueveras/powersso/database/postgres" | ||
"github.com/isaqueveras/powersso/domain/auth" | ||
"github.com/isaqueveras/powersso/oops" | ||
) | ||
|
||
type PGFlag struct{ DB *postgres.Transaction } | ||
|
||
func (pg *PGFlag) Set(userID *uuid.UUID, flag *auth.Flag) error { | ||
if _, err := pg.DB.Builder. | ||
Update("users"). | ||
Set("flag", flag). | ||
Where("id = ?::UUID", userID). | ||
Exec(); err != nil { | ||
return oops.Err(err) | ||
} | ||
return nil | ||
} | ||
|
||
func (pg *PGFlag) Get(userID *uuid.UUID) (flag *int64, err error) { | ||
if err = pg.DB.Builder. | ||
Select("flag"). | ||
From("users"). | ||
Where("id = ?::UUID", userID). | ||
Scan(&flag); err != nil { | ||
return nil, oops.Err(err) | ||
} | ||
return | ||
} |
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 was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.