ratio_sync.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package dto
  2. // UpstreamDTO 提交到后端同步倍率的上游渠道信息
  3. // Endpoint 可以为空,后端会默认使用 /api/ratio_config
  4. // BaseURL 必须以 http/https 开头,不要以 / 结尾
  5. // 例如: https://api.example.com
  6. // Endpoint: /api/ratio_config
  7. // 提交示例:
  8. // {
  9. // "name": "openai",
  10. // "base_url": "https://api.openai.com",
  11. // "endpoint": "/ratio_config"
  12. // }
  13. type UpstreamDTO struct {
  14. Name string `json:"name" binding:"required"`
  15. BaseURL string `json:"base_url" binding:"required"`
  16. Endpoint string `json:"endpoint"`
  17. }
  18. type UpstreamRequest struct {
  19. ChannelIDs []int64 `json:"channel_ids"`
  20. Timeout int `json:"timeout"`
  21. }
  22. // TestResult 上游测试连通性结果
  23. type TestResult struct {
  24. Name string `json:"name"`
  25. Status string `json:"status"`
  26. Error string `json:"error,omitempty"`
  27. }
  28. // DifferenceItem 差异项
  29. // Current 为本地值,可能为 nil
  30. // Upstreams 为各渠道的上游值,具体数值 / "same" / nil
  31. type DifferenceItem struct {
  32. Current interface{} `json:"current"`
  33. Upstreams map[string]interface{} `json:"upstreams"`
  34. }
  35. // SyncableChannel 可同步的渠道信息(base_url 不为空)
  36. type SyncableChannel struct {
  37. ID int `json:"id"`
  38. Name string `json:"name"`
  39. BaseURL string `json:"base_url"`
  40. Status int `json:"status"`
  41. }