fix method GetAccAndPrivilegeByEmail
This commit is contained in:
parent
e1164644b1
commit
2dd6d69acf
@ -322,23 +322,29 @@ 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
|
||||
}
|
||||
|
||||
if row.ID_2 != 0 {
|
||||
privilege := model.ShortPrivilege{
|
||||
ID: fmt.Sprint(row.ID_2),
|
||||
PrivilegeID: row.Privilegeid,
|
||||
Amount: uint64(row.Amount),
|
||||
CreatedAt: row.CreatedAt_2,
|
||||
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),
|
||||
PrivilegeID: row.Privilegeid,
|
||||
Amount: uint64(row.Amount),
|
||||
CreatedAt: row.CreatedAt_2,
|
||||
}
|
||||
privileges = append(privileges, privilege)
|
||||
}
|
||||
privileges = append(privileges, privilege)
|
||||
}
|
||||
|
||||
return account, privileges, nil
|
||||
|
Loading…
Reference in New Issue
Block a user