pricing.go 764 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package controller
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "one-api/common"
  5. "one-api/model"
  6. )
  7. func GetPricing(c *gin.Context) {
  8. pricing := model.GetPricing()
  9. c.JSON(200, gin.H{
  10. "success": true,
  11. "data": pricing,
  12. "group_ratio": common.GroupRatio,
  13. })
  14. }
  15. func ResetModelRatio(c *gin.Context) {
  16. defaultStr := common.DefaultModelRatio2JSONString()
  17. err := model.UpdateOption("ModelRatio", defaultStr)
  18. if err != nil {
  19. c.JSON(200, gin.H{
  20. "success": false,
  21. "message": err.Error(),
  22. })
  23. return
  24. }
  25. err = common.UpdateModelRatioByJSONString(defaultStr)
  26. if err != nil {
  27. c.JSON(200, gin.H{
  28. "success": false,
  29. "message": err.Error(),
  30. })
  31. return
  32. }
  33. c.JSON(200, gin.H{
  34. "success": true,
  35. "message": "重置模型倍率成功",
  36. })
  37. }