mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-16 21:23:44 +08:00
♻️ refactor: Refactor chat links
This commit is contained in:
@@ -44,6 +44,7 @@ func GetStatus(c *gin.Context) {
|
||||
"telegram_bot": telegram_bot,
|
||||
"mj_notify_enabled": common.MjNotifyEnabled,
|
||||
"chat_cache_enabled": common.ChatCacheEnabled,
|
||||
"chat_links": common.ChatLinks,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -54,6 +54,39 @@ func GetToken(c *gin.Context) {
|
||||
})
|
||||
}
|
||||
|
||||
func GetPlaygroundToken(c *gin.Context) {
|
||||
tokenName := "sys_playground"
|
||||
token, err := model.GetTokenByName(tokenName)
|
||||
if err != nil {
|
||||
cleanToken := model.Token{
|
||||
UserId: c.GetInt("id"),
|
||||
Name: tokenName,
|
||||
Key: common.GenerateKey(),
|
||||
CreatedTime: common.GetTimestamp(),
|
||||
AccessedTime: common.GetTimestamp(),
|
||||
ExpiredTime: 0,
|
||||
RemainQuota: 0,
|
||||
UnlimitedQuota: true,
|
||||
ChatCache: false,
|
||||
}
|
||||
err = cleanToken.Insert()
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": false,
|
||||
"message": "创建令牌失败,请去系统手动配置一个名称为:sys_playground 的令牌",
|
||||
})
|
||||
return
|
||||
}
|
||||
token = &cleanToken
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": true,
|
||||
"message": "",
|
||||
"data": token.Key,
|
||||
})
|
||||
}
|
||||
|
||||
func GetTokenStatus(c *gin.Context) {
|
||||
tokenId := c.GetInt("token_id")
|
||||
userId := c.GetInt("id")
|
||||
|
||||
Reference in New Issue
Block a user