♻️ refactor: Refactor chat links

This commit is contained in:
Martial BE
2024-04-27 20:50:36 +08:00
parent c6a0c87ad1
commit 801b98d6fc
18 changed files with 574 additions and 41 deletions

View File

@@ -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,
},
})
}

View File

@@ -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")