mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-17 13:43:42 +08:00
♻️ refactor: Refactor chat links
This commit is contained in:
@@ -70,6 +70,7 @@ func InitOptionMap() {
|
||||
common.OptionMap["GroupRatio"] = common.GroupRatio2JSONString()
|
||||
common.OptionMap["TopUpLink"] = common.TopUpLink
|
||||
common.OptionMap["ChatLink"] = common.ChatLink
|
||||
common.OptionMap["ChatLinks"] = common.ChatLinks
|
||||
common.OptionMap["QuotaPerUnit"] = strconv.FormatFloat(common.QuotaPerUnit, 'f', -1, 64)
|
||||
common.OptionMap["RetryTimes"] = strconv.Itoa(common.RetryTimes)
|
||||
common.OptionMap["RetryCooldownSeconds"] = strconv.Itoa(common.RetryCooldownSeconds)
|
||||
@@ -166,6 +167,7 @@ var optionStringMap = map[string]*string{
|
||||
"TurnstileSecretKey": &common.TurnstileSecretKey,
|
||||
"TopUpLink": &common.TopUpLink,
|
||||
"ChatLink": &common.ChatLink,
|
||||
"ChatLinks": &common.ChatLinks,
|
||||
"LarkClientId": &common.LarkClientId,
|
||||
"LarkClientSecret": &common.LarkClientSecret,
|
||||
}
|
||||
|
||||
@@ -115,6 +115,16 @@ func GetTokenById(id int) (*Token, error) {
|
||||
return &token, err
|
||||
}
|
||||
|
||||
func GetTokenByName(name string) (*Token, error) {
|
||||
if name == "" {
|
||||
return nil, errors.New("name 为空!")
|
||||
}
|
||||
token := Token{Name: name}
|
||||
var err error = nil
|
||||
err = DB.First(&token, "name = ?", name).Error
|
||||
return &token, err
|
||||
}
|
||||
|
||||
func (token *Token) Insert() error {
|
||||
if token.ChatCache && !common.ChatCacheEnabled {
|
||||
token.ChatCache = false
|
||||
|
||||
Reference in New Issue
Block a user