新增获取账号地址的方法
This commit is contained in:
@@ -126,3 +126,18 @@ func (u *TwitterAccountService) GetAvailableImportAccount(params *models.Twitter
|
||||
|
||||
return users
|
||||
}
|
||||
|
||||
// 随机获取一个可用账号
|
||||
func (u *TwitterAccountService) GetRandomAccount(params *models.TwitterAccount) *models.TwitterAccount {
|
||||
var account models.TwitterAccount
|
||||
res := u.db.Model(&models.TwitterAccount{}).Where(`type = ? AND login_status IS NULL AND (status != ? OR status IS NULL)`, params.Type, params.Status)
|
||||
// if params.Username != "" {
|
||||
// res.Where("username LIKE ?", "%"+params.Username+"%")
|
||||
// }
|
||||
res.Order("RAND()").Limit(1).Find(&account)
|
||||
if account.ID == 0 {
|
||||
return nil
|
||||
}
|
||||
u.db.Model(&models.TwitterAccount{}).Where("id = ?", account.ID).Updates(map[string]interface{}{"login_status": "已选择", "update_time": time.Now().Unix()})
|
||||
return &account
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user