Files
ai-agent/internal/controllers/api/channel_controller.go
T

35 lines
802 B
Go
Raw Normal View History

package api
2026-04-09 10:01:23 +08:00
import (
"cs-agent/internal/pkg/dto/response"
"cs-agent/internal/services"
2026-04-09 10:01:23 +08:00
"github.com/kataras/iris/v12"
"github.com/mlogclub/simple/web"
)
type ChannelController struct {
2026-04-09 10:01:23 +08:00
Ctx iris.Context
}
func (c *ChannelController) AnyConfig() *web.JsonResult {
channel := services.ChannelService.GetEnabledChannel(c.Ctx)
2026-04-09 10:01:23 +08:00
if channel == nil {
return web.JsonErrorMsg("接入渠道未初始化")
}
cfg, err := services.ChannelService.ParseWebChannelConfig(channel.ConfigJSON)
if err != nil {
return web.JsonErrorMsg("Web渠道配置不合法")
}
2026-04-09 10:01:23 +08:00
ret := response.WidgetConfigResponse{
ChannelID: channel.ChannelID,
Title: cfg.Title,
Subtitle: cfg.Subtitle,
ThemeColor: cfg.ThemeColor,
Position: cfg.Position,
Width: cfg.Width,
2026-04-09 10:01:23 +08:00
}
return web.JsonData(ret)
}