working commit

This commit is contained in:
2026-02-11 20:45:45 +02:00
parent 2e3dbe8f7c
commit d318f39f3c
15 changed files with 337 additions and 90 deletions
+26 -14
View File
@@ -100,15 +100,19 @@ func (oper *Operator) UpdateAccount(ctx context.Context, params *UpdateAccountPa
if err != nil {
return res, err
}
if !accountExists {
err := fmt.Errorf("Account with ID %s dont exists", params.AccountID)
return res, err
}
case params.Username != "":
accountExists, accountDescr, err = oper.mdb.GetAccountByUsername(ctx, params.Username)
if err != nil {
return res, err
}
}
if !accountExists {
err := fmt.Errorf("Account with this is or name dont exists")
return res, err
if !accountExists {
err := fmt.Errorf("Account with name %s dont exists", params.Username)
return res, err
}
}
now := auxtool.TimeNow()
if params.NewUsername != "" {
@@ -150,15 +154,19 @@ func (oper *Operator) DeleteAccount(ctx context.Context, params *DeleteAccountPa
if err != nil {
return res, err
}
if !accountExists {
err := fmt.Errorf("Account with ID %s dont exists", params.AccountID)
return res, err
}
case params.Username != "":
accountExists, accountDescr, err = oper.mdb.GetAccountByUsername(ctx, params.Username)
if err != nil {
return res, err
}
}
if !accountExists {
err := fmt.Errorf("Account with this is or name dont exists")
return res, err
if !accountExists {
err := fmt.Errorf("Account with name %s dont exists", params.Username)
return res, err
}
}
err = oper.mdb.DeleteAllGrantsForAccountID(ctx, accountDescr.ID)
@@ -216,7 +224,7 @@ type GetAccountParams struct {
AccountID string
}
type GetAccountResult struct {
Account *descr.AccountShortDescr `json:"accountDescr"`
Account *descr.AccountShortDescr `json:"account"`
}
func (oper *Operator) GetAccount(ctx context.Context, params *GetAccountParams) (*GetAccountResult, error) {
@@ -227,19 +235,23 @@ func (oper *Operator) GetAccount(ctx context.Context, params *GetAccountParams)
var accountExists bool
switch {
case params.AccountID != "":
accountExists, accountDescr, err = oper.mdb.GetAccountByID(ctx, params.Username)
accountExists, accountDescr, err = oper.mdb.GetAccountByID(ctx, params.AccountID)
if err != nil {
return res, err
}
if !accountExists {
err := fmt.Errorf("Account with ID %s dont exists", params.AccountID)
return res, err
}
case params.Username != "":
accountExists, accountDescr, err = oper.mdb.GetAccountByUsername(ctx, params.Username)
if err != nil {
return res, err
}
}
if !accountExists {
err := fmt.Errorf("Account with this is or name dont exists")
return res, err
if !accountExists {
err := fmt.Errorf("Account with name %s dont exists", params.Username)
return res, err
}
}
accountShortDescr := &descr.AccountShortDescr{
Username: accountDescr.Username,