MCPcopy Index your code
hub / github.com/aiprodcoder/MIXAPI / ExportChannels

Function ExportChannels

controller/channel_export.go:13–97  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

11)
12
13func ExportChannels(c *gin.Context) {
14 // 获取所有渠道数据
15 channels, err := model.GetAllChannels(0, 0, true, false)
16 if err != nil {
17 common.ApiError(c, err)
18 return
19 }
20
21 // 创建Excel文件
22 f := excelize.NewFile()
23 defer func() {
24 if err := f.Close(); err != nil {
25 common.SysError("Error closing Excel file: " + err.Error())
26 }
27 }()
28
29 // 创建工作表
30 sheetName := "Channels"
31 f.SetSheetName("Sheet1", sheetName)
32
33 // 设置表头
34 headers := []string{
35 "ID", "名称", "类型", "状态", "密钥", "组织", "测试模型",
36 "权重", "创建时间", "测试时间", "响应时间", "基础URL", "其他",
37 "余额", "余额更新时间", "模型", "分组", "已用配额",
38 "模型映射", "状态码映射", "优先级", "自动禁用", "标签", "额外设置", "参数覆盖",
39 }
40
41 for i, header := range headers {
42 cell, _ := excelize.CoordinatesToCellName(i+1, 1)
43 f.SetCellValue(sheetName, cell, header)
44 }
45
46 // 填充数据
47 for i, channel := range channels {
48 row := i + 2 // 从第二行开始填充数据
49 data := []interface{}{
50 channel.Id,
51 channel.Name,
52 channel.Type,
53 channel.Status,
54 channel.Key,
55 channel.OpenAIOrganization,
56 channel.TestModel,
57 channel.Weight,
58 channel.CreatedTime,
59 channel.TestTime,
60 channel.ResponseTime,
61 channel.BaseURL,
62 channel.Other,
63 channel.Balance,
64 channel.BalanceUpdatedTime,
65 channel.Models,
66 channel.Group,
67 channel.UsedQuota,
68 channel.ModelMapping,
69 channel.StatusCodeMapping,
70 channel.Priority,

Callers

nothing calls this directly

Calls 4

GetAllChannelsFunction · 0.92
ApiErrorFunction · 0.92
SysErrorFunction · 0.92
ErrorMethod · 0.80

Tested by

no test coverage detected