mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-10-15 15:30:26 +00:00
feat: able to test all enabled channels (#59)
This commit is contained in:
@@ -19,10 +19,14 @@ type Channel struct {
|
||||
Other string `json:"other"`
|
||||
}
|
||||
|
||||
func GetAllChannels(startIdx int, num int) ([]*Channel, error) {
|
||||
func GetAllChannels(startIdx int, num int, selectAll bool) ([]*Channel, error) {
|
||||
var channels []*Channel
|
||||
var err error
|
||||
err = DB.Order("id desc").Limit(num).Offset(startIdx).Omit("key").Find(&channels).Error
|
||||
if selectAll {
|
||||
err = DB.Order("id desc").Find(&channels).Error
|
||||
} else {
|
||||
err = DB.Order("id desc").Limit(num).Offset(startIdx).Omit("key").Find(&channels).Error
|
||||
}
|
||||
return channels, err
|
||||
}
|
||||
|
||||
@@ -82,6 +86,13 @@ func (channel *Channel) UpdateResponseTime(responseTime int64) {
|
||||
}
|
||||
}
|
||||
|
||||
func (channel *Channel) UpdateStatus(status int) {
|
||||
err := DB.Model(channel).Update("status", status).Error
|
||||
if err != nil {
|
||||
common.SysError("failed to update response time: " + err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func (channel *Channel) Delete() error {
|
||||
var err error
|
||||
err = DB.Delete(channel).Error
|
||||
|
Reference in New Issue
Block a user