ratio_sync.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. CustomChannels []UpstreamDTO `json:"custom_channels"`
  21. Timeout int `json:"timeout"`
  22. }
  23. // TestResult 上游测试连通性结果
  24. type TestResult struct {
  25. Name string `json:"name"`
  26. Status string `json:"status"`
  27. Error string `json:"error,omitempty"`
  28. }
  29. // DifferenceItem 差异项
  30. // Current 为本地值,可能为 nil
  31. // Upstreams 为各渠道的上游值,具体数值 / "same" / nil
  32. type DifferenceItem struct {
  33. Current interface{} `json:"current"`
  34. Upstreams map[string]interface{} `json:"upstreams"`
  35. }
  36. // SyncableChannel 可同步的渠道信息(base_url 不为空)
  37. type SyncableChannel struct {
  38. ID int `json:"id"`
  39. Name string `json:"name"`
  40. BaseURL string `json:"base_url"`
  41. Status int `json:"status"`
  42. }