right type used
This commit is contained in:
+11
-10
@@ -12,8 +12,9 @@ package maindb
|
||||
import (
|
||||
"context"
|
||||
|
||||
"mstore/pkg/auxuuid"
|
||||
"mstore/pkg/descr"
|
||||
"mstore/pkg/terms"
|
||||
"mstore/pkg/uuid"
|
||||
)
|
||||
|
||||
func (db *Database) InsertGrant(ctx context.Context, grant *descr.Grant) error {
|
||||
@@ -28,7 +29,7 @@ func (db *Database) InsertGrant(ctx context.Context, grant *descr.Grant) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (db *Database) UpdateGrantByID(ctx context.Context, grantID auxuuid.UUID, grant *descr.Grant) error {
|
||||
func (db *Database) UpdateGrantByID(ctx context.Context, grantID uuid.UUID, grant *descr.Grant) error {
|
||||
var err error
|
||||
request := `UPDATE grants SET pattern = $1, updated_at = $2, updated_by = $3 WHERE id = $4`
|
||||
_, err = db.db.Exec(request, grant.Pattern, grant.UpdatedAt, grant.UpdatedBy, grantID)
|
||||
@@ -38,7 +39,7 @@ func (db *Database) UpdateGrantByID(ctx context.Context, grantID auxuuid.UUID, g
|
||||
return err
|
||||
}
|
||||
|
||||
func (db *Database) ListGrantsByAccountID(ctx context.Context, accountID auxuuid.UUID) ([]descr.Grant, error) {
|
||||
func (db *Database) ListGrantsByAccountID(ctx context.Context, accountID uuid.UUID) ([]descr.Grant, error) {
|
||||
var err error
|
||||
request := `SELECT * FROM grants WHERE account_id = $1`
|
||||
res := make([]descr.Grant, 0)
|
||||
@@ -60,7 +61,7 @@ func (db *Database) ListGrants(ctx context.Context) ([]descr.Grant, error) {
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (db *Database) GetGrantByID(ctx context.Context, id auxuuid.UUID) (bool, *descr.Grant, error) {
|
||||
func (db *Database) GetGrantByID(ctx context.Context, id uuid.UUID) (bool, *descr.Grant, error) {
|
||||
var err error
|
||||
res := &descr.Grant{}
|
||||
request := `SELECT * FROM grants WHERE id = $1 LIMIT 1`
|
||||
@@ -77,7 +78,7 @@ func (db *Database) GetGrantByID(ctx context.Context, id auxuuid.UUID) (bool, *d
|
||||
return true, res, err
|
||||
}
|
||||
|
||||
func (db *Database) GetGrantByAccoundIDRight(ctx context.Context, accountID auxuuid.UUID, right string) (bool, *descr.Grant, error) {
|
||||
func (db *Database) GetGrantByAccoundIDRight(ctx context.Context, accountID uuid.UUID, right terms.Right) (bool, *descr.Grant, error) {
|
||||
var err error
|
||||
res := &descr.Grant{}
|
||||
request := `SELECT * FROM grants WHERE account_id = $1 AND right = $2 LIMIT 1`
|
||||
@@ -94,7 +95,7 @@ func (db *Database) GetGrantByAccoundIDRight(ctx context.Context, accountID auxu
|
||||
return true, res, err
|
||||
}
|
||||
|
||||
func (db *Database) ListGrantsByAccoundIDRight(ctx context.Context, accountID auxuuid.UUID, right string) (bool, []descr.Grant, error) {
|
||||
func (db *Database) ListGrantsByAccoundIDRight(ctx context.Context, accountID uuid.UUID, right terms.Right) (bool, []descr.Grant, error) {
|
||||
var err error
|
||||
request := `SELECT * FROM grants WHERE account_id = $1 AND right = $2`
|
||||
res := make([]descr.Grant, 0)
|
||||
@@ -108,7 +109,7 @@ func (db *Database) ListGrantsByAccoundIDRight(ctx context.Context, accountID au
|
||||
return true, res, err
|
||||
}
|
||||
|
||||
func (db *Database) GetGrantByAccoundIDRightPattern(ctx context.Context, accountID auxuuid.UUID, right, pattern string) (bool, *descr.Grant, error) {
|
||||
func (db *Database) GetGrantByAccoundIDRightPattern(ctx context.Context, accountID uuid.UUID, right terms.Right, pattern string) (bool, *descr.Grant, error) {
|
||||
var err error
|
||||
res := &descr.Grant{}
|
||||
request := `SELECT * FROM grants WHERE account_id = $1 AND right = $2 AND pattern = $3 LIMIT 1`
|
||||
@@ -125,7 +126,7 @@ func (db *Database) GetGrantByAccoundIDRightPattern(ctx context.Context, account
|
||||
return true, res, err
|
||||
}
|
||||
|
||||
func (db *Database) DeleteGrantByAccountIDRightPattern(ctx context.Context, accountID auxuuid.UUID, right, pattern string) error {
|
||||
func (db *Database) DeleteGrantByAccountIDRightPattern(ctx context.Context, accountID uuid.UUID, right, pattern string) error {
|
||||
var err error
|
||||
request := `DELETE FROM grants WHERE account_id = $1 AND right = $2 AND pattern = $3`
|
||||
_, err = db.db.Exec(request, accountID, right, pattern)
|
||||
@@ -135,7 +136,7 @@ func (db *Database) DeleteGrantByAccountIDRightPattern(ctx context.Context, acco
|
||||
return err
|
||||
}
|
||||
|
||||
func (db *Database) DeleteGrantByID(ctx context.Context, grantID auxuuid.UUID) error {
|
||||
func (db *Database) DeleteGrantByID(ctx context.Context, grantID uuid.UUID) error {
|
||||
var err error
|
||||
request := `DELETE FROM grants WHERE id = $1`
|
||||
_, err = db.db.Exec(request, grantID)
|
||||
@@ -145,7 +146,7 @@ func (db *Database) DeleteGrantByID(ctx context.Context, grantID auxuuid.UUID) e
|
||||
return err
|
||||
}
|
||||
|
||||
func (db *Database) DeleteAllGrantsForAccountID(ctx context.Context, grantID auxuuid.UUID) error {
|
||||
func (db *Database) DeleteAllGrantsForAccountID(ctx context.Context, grantID uuid.UUID) error {
|
||||
var err error
|
||||
request := `DELETE FROM grants WHERE account_id = $1`
|
||||
_, err = db.db.Exec(request, grantID)
|
||||
|
||||
Reference in New Issue
Block a user