uuid used

This commit is contained in:
2026-02-20 15:06:15 +02:00
parent 35e83ed705
commit 8546ad496f
31 changed files with 265 additions and 238 deletions
+17 -17
View File
@@ -12,16 +12,16 @@ import (
// CreateGrant
type CreateGrantParams struct {
AccountID string `json:"accountID"`
Username string `json:"username"`
Right string `json:"operation"`
Pattern string `json:"pattern"`
AccountID auxuuid.UUID `json:"accountID"`
Username string `json:"username"`
Right string `json:"operation"`
Pattern string `json:"pattern"`
}
type CreateGrantResult struct {
GrantID string `json:"grantId"`
GrantID auxuuid.UUID `json:"grantId"`
}
func (oper *Operator) CreateGrant(ctx context.Context, operID string, params *CreateGrantParams) (*CreateGrantResult, error) {
func (oper *Operator) CreateGrant(ctx context.Context, operatorID auxuuid.UUID, params *CreateGrantParams) (*CreateGrantResult, error) {
var err error
res := &CreateGrantResult{}
@@ -86,8 +86,8 @@ func (oper *Operator) CreateGrant(ctx context.Context, operID string, params *Cr
Pattern: params.Pattern,
CreatedAt: now,
UpdatedAt: now,
CreatedBy: operID,
UpdatedBy: operID,
CreatedBy: operatorID,
UpdatedBy: operatorID,
}
err = oper.mdb.InsertGrant(ctx, grantDescr)
if err != nil {
@@ -99,12 +99,12 @@ func (oper *Operator) CreateGrant(ctx context.Context, operID string, params *Cr
// UpdateGrant
type UpdateGrantParams struct {
GrantID string
GrantID auxuuid.UUID
NewPattern string
}
type UpdateGrantResult struct{}
func (oper *Operator) UpdateGrant(ctx context.Context, operID string, params *UpdateGrantParams) (*UpdateGrantResult, error) {
func (oper *Operator) UpdateGrant(ctx context.Context, operatorID auxuuid.UUID, params *UpdateGrantParams) (*UpdateGrantResult, error) {
var err error
res := &UpdateGrantResult{}
@@ -130,7 +130,7 @@ func (oper *Operator) UpdateGrant(ctx context.Context, operID string, params *Up
now := auxtool.TimeNow()
if params.NewPattern != "" {
grantDescr.UpdatedAt = now
grantDescr.UpdatedBy = operID
grantDescr.UpdatedBy = operatorID
grantDescr.Pattern = params.NewPattern
}
err = oper.mdb.UpdateGrantByID(ctx, grantDescr.ID, grantDescr)
@@ -142,11 +142,11 @@ func (oper *Operator) UpdateGrant(ctx context.Context, operID string, params *Up
// DeleteGrant
type DeleteGrantParams struct {
GrantID string `json:"grantId"`
GrantID auxuuid.UUID `json:"grantId"`
}
type DeleteGrantResult struct{}
func (oper *Operator) DeleteGrant(ctx context.Context, operID string, params *DeleteGrantParams) (*DeleteGrantResult, error) {
func (oper *Operator) DeleteGrant(ctx context.Context, operatorID auxuuid.UUID, params *DeleteGrantParams) (*DeleteGrantResult, error) {
var err error
res := &DeleteGrantResult{}
@@ -176,13 +176,13 @@ func (oper *Operator) DeleteGrant(ctx context.Context, operID string, params *De
// ListGrants
type ListGrantsParams struct {
Username string
AccountID string
AccountID auxuuid.UUID
}
type ListGrantsResult struct {
Grants []descr.Grant `json:"grants"`
}
func (oper *Operator) ListGrants(ctx context.Context, operID string, params *ListGrantsParams) (*ListGrantsResult, error) {
func (oper *Operator) ListGrants(ctx context.Context, operatorID auxuuid.UUID, params *ListGrantsParams) (*ListGrantsResult, error) {
var err error
res := &ListGrantsResult{
Grants: make([]descr.Grant, 0),
@@ -223,13 +223,13 @@ func (oper *Operator) ListGrants(ctx context.Context, operID string, params *Lis
// Get Grants
type GetGrantParams struct {
GrantID string `json:"grantId"`
GrantID auxuuid.UUID `json:"grantId"`
}
type GetGrantResult struct {
Grant *descr.Grant `json:"grant"`
}
func (oper *Operator) GetGrant(ctx context.Context, operID string, params *GetGrantParams) (*GetGrantResult, error) {
func (oper *Operator) GetGrant(ctx context.Context, operatorID auxuuid.UUID, params *GetGrantParams) (*GetGrantResult, error) {
var err error
res := &GetGrantResult{}