MCPcopy
hub / github.com/QuantumNous/new-api / UpdateChannelBalance

Function UpdateChannelBalance

controller/channel-billing.go:424–452  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

422}
423
424func UpdateChannelBalance(c *gin.Context) {
425 id, err := strconv.Atoi(c.Param("id"))
426 if err != nil {
427 common.ApiError(c, err)
428 return
429 }
430 channel, err := model.CacheGetChannel(id)
431 if err != nil {
432 common.ApiError(c, err)
433 return
434 }
435 if channel.ChannelInfo.IsMultiKey {
436 c.JSON(http.StatusOK, gin.H{
437 "success": false,
438 "message": "多密钥渠道不支持余额查询",
439 })
440 return
441 }
442 balance, err := updateChannelBalance(channel)
443 if err != nil {
444 common.ApiError(c, err)
445 return
446 }
447 c.JSON(http.StatusOK, gin.H{
448 "success": true,
449 "message": "",
450 "balance": balance,
451 })
452}
453
454func updateAllChannelsBalance() error {
455 channels, err := model.GetAllChannels(0, 0, true, false)

Callers

nothing calls this directly

Calls 3

ApiErrorFunction · 0.92
CacheGetChannelFunction · 0.92
updateChannelBalanceFunction · 0.70

Tested by

no test coverage detected