优化项目 (#75)

* 💄 improve: channel search

* 💄 improve: channel Table

* 💄 improve: add channel batch
This commit is contained in:
Buer
2024-02-26 19:06:18 +08:00
committed by GitHub
parent ec64bf1ad4
commit 6b8ba36213
13 changed files with 889 additions and 96 deletions

View File

@@ -1,6 +1,7 @@
package controller
import (
"errors"
"net/http"
"one-api/common"
"one-api/model"
@@ -11,7 +12,7 @@ import (
)
func GetChannelsList(c *gin.Context) {
var params model.GenericParams
var params model.SearchChannelsParams
if err := c.ShouldBindQuery(&params); err != nil {
common.APIRespondWithError(c, http.StatusOK, err)
return
@@ -145,3 +146,54 @@ func UpdateChannel(c *gin.Context) {
"data": channel,
})
}
func BatchUpdateChannelsAzureApi(c *gin.Context) {
var params model.BatchChannelsParams
err := c.ShouldBindJSON(&params)
if err != nil {
common.APIRespondWithError(c, http.StatusOK, err)
return
}
if params.Ids == nil || len(params.Ids) == 0 {
common.APIRespondWithError(c, http.StatusOK, errors.New("ids不能为空"))
return
}
var count int64
count, err = model.BatchUpdateChannelsAzureApi(&params)
if err != nil {
common.APIRespondWithError(c, http.StatusOK, err)
return
}
c.JSON(http.StatusOK, gin.H{
"data": count,
"success": true,
"message": "更新成功",
})
}
func BatchDelModelChannels(c *gin.Context) {
var params model.BatchChannelsParams
err := c.ShouldBindJSON(&params)
if err != nil {
common.APIRespondWithError(c, http.StatusOK, err)
return
}
if params.Ids == nil || len(params.Ids) == 0 {
common.APIRespondWithError(c, http.StatusOK, errors.New("ids不能为空"))
return
}
var count int64
count, err = model.BatchDelModelChannels(&params)
if err != nil {
common.APIRespondWithError(c, http.StatusOK, err)
return
}
c.JSON(http.StatusOK, gin.H{
"data": count,
"success": true,
"message": "更新成功",
})
}