fix method GetAccAndPrivilegeByEmail
This commit is contained in:
parent
e1164644b1
commit
2dd6d69acf
@ -322,15 +322,20 @@ func (r *AccountRepository) GetAccAndPrivilegeByEmail(ctx context.Context, email
|
||||
var account model.Account
|
||||
var privileges []model.ShortPrivilege
|
||||
|
||||
row, err := r.queries.GetAccAndPrivilegeByEmail(ctx, email)
|
||||
rows, err := r.queries.GetAccAndPrivilegeByEmail(ctx, email)
|
||||
if err != nil {
|
||||
return account, privileges, err
|
||||
}
|
||||
|
||||
account.ID = row.ID.String()
|
||||
account.UserID = row.UserID
|
||||
account.CreatedAt = row.CreatedAt
|
||||
if len(rows) == 0 {
|
||||
return account, privileges, sql.ErrNoRows
|
||||
}
|
||||
|
||||
account.ID = rows[0].ID.String()
|
||||
account.UserID = rows[0].UserID
|
||||
account.CreatedAt = rows[0].CreatedAt
|
||||
|
||||
for _, row := range rows {
|
||||
if row.ID_2 != 0 {
|
||||
privilege := model.ShortPrivilege{
|
||||
ID: fmt.Sprint(row.ID_2),
|
||||
@ -340,6 +345,7 @@ func (r *AccountRepository) GetAccAndPrivilegeByEmail(ctx context.Context, email
|
||||
}
|
||||
privileges = append(privileges, privilege)
|
||||
}
|
||||
}
|
||||
|
||||
return account, privileges, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user