working commit

This commit is contained in:
2026-06-09 14:10:53 +02:00
parent ee30858d11
commit 6e92720e69
26 changed files with 339 additions and 165 deletions
+8 -8
View File
@@ -8,9 +8,9 @@ import (
func (db *Database) InsertGrant(ctx context.Context, grant *descr.Grant) error {
var err error
request := `INSERT INTO grant(id, account_id, operation, created_at)
request := `INSERT INTO grant(id, account_id, grantname, created_at)
VALUES ($1, $2, $3, $4)`
_, err = db.db.Exec(request, grant.ID, grant.AccountID, grant.Operation, grant.CreatedAt)
_, err = db.db.Exec(request, grant.ID, grant.AccountID, grant.Grantname, grant.CreatedAt)
if err != nil {
return err
}
@@ -39,12 +39,12 @@ func (db *Database) ListGrants(ctx context.Context) ([]descr.Grant, error) {
return res, err
}
func (db *Database) GetGrant(ctx context.Context, accountID, operation string) (bool, *descr.Grant, error) {
func (db *Database) GetGrant(ctx context.Context, accountID, grantname string) (bool, *descr.Grant, error) {
var err error
res := &descr.Grant{}
request := `SELECT * FROM grant WHERE account_id = $1 AND operation = $2 LIMIT 1`
request := `SELECT * FROM grant WHERE account_id = $1 AND grantname = $2 LIMIT 1`
dbRes := make([]descr.Grant, 0)
err = db.db.Select(&dbRes, request, accountID, operation)
err = db.db.Select(&dbRes, request, accountID, grantname)
if err != nil {
return false, res, err
}
@@ -56,10 +56,10 @@ func (db *Database) GetGrant(ctx context.Context, accountID, operation string) (
return true, res, err
}
func (db *Database) DeleteGrantByAccountID(ctx context.Context, grantID, operation string) error {
func (db *Database) DeleteGrantByAccountID(ctx context.Context, grantID, grantname string) error {
var err error
request := `DELETE FROM grant WHERE account_id = $1 AND operation = $2`
_, err = db.db.Exec(request, grantID, operation)
request := `DELETE FROM grant WHERE account_id = $1 AND grantname = $2`
_, err = db.db.Exec(request, grantID, grantname)
if err != nil {
return err
}