fix: fix priority not updated & random choice not working

This commit is contained in:
JustSong
2023-09-18 21:43:45 +08:00
parent ecf8a6d875
commit a5647b1ea7
3 changed files with 19 additions and 6 deletions

View File

@@ -23,7 +23,7 @@ type Channel struct {
Group string `json:"group" gorm:"type:varchar(32);default:'default'"`
UsedQuota int64 `json:"used_quota" gorm:"bigint;default:0"`
ModelMapping string `json:"model_mapping" gorm:"type:varchar(1024);default:''"`
Priority int64 `json:"priority" gorm:"bigint;default:0"`
Priority *int64 `json:"priority" gorm:"bigint;default:0"`
}
func GetAllChannels(startIdx int, num int, selectAll bool) ([]*Channel, error) {
@@ -79,6 +79,13 @@ func BatchInsertChannels(channels []Channel) error {
return nil
}
func (channel *Channel) GetPriority() int64 {
if channel == nil {
return 0
}
return *channel.Priority
}
func (channel *Channel) Insert() error {
var err error
err = DB.Create(channel).Error