21 lines
565 B
Go
21 lines
565 B
Go
package model
|
|
|
|
// BotBalanceAccount contains only the fields needed by the notification bot.
|
|
type BotBalanceAccount struct {
|
|
ID int `gorm:"column:id"`
|
|
Status int
|
|
Quota int
|
|
}
|
|
|
|
func FindBotBalanceAccounts(email string, ids []int) ([]BotBalanceAccount, error) {
|
|
accounts := []BotBalanceAccount{}
|
|
query := DB.Model(&User{}).Select("id", "status", "quota")
|
|
if email != "" {
|
|
query = query.Where("LOWER(email) = ?", NormalizeEmail(email)).Limit(2)
|
|
} else {
|
|
query = query.Where("id IN ?", ids)
|
|
}
|
|
err := query.Find(&accounts).Error
|
|
return accounts, err
|
|
}
|