mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-16 13:13:41 +08:00
优化项目 (#75)
* 💄 improve: channel search * 💄 improve: channel Table * 💄 improve: add channel batch
This commit is contained in:
@@ -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(¶ms); 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(¶ms)
|
||||
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(¶ms)
|
||||
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(¶ms)
|
||||
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(¶ms)
|
||||
if err != nil {
|
||||
common.APIRespondWithError(c, http.StatusOK, err)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"data": count,
|
||||
"success": true,
|
||||
"message": "更新成功",
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user