(c *gin.Context)
| 422 | } |
| 423 | |
| 424 | func 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 | |
| 454 | func updateAllChannelsBalance() error { |
| 455 | channels, err := model.GetAllChannels(0, 0, true, false) |
nothing calls this directly
no test coverage detected