2026-04-25 10:27:43 +08:00
|
|
|
package api
|
2026-04-09 10:01:23 +08:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"cs-agent/internal/pkg/dto/response"
|
2026-04-24 22:24:19 +08:00
|
|
|
"cs-agent/internal/services"
|
2026-04-09 10:01:23 +08:00
|
|
|
|
|
|
|
|
"github.com/kataras/iris/v12"
|
|
|
|
|
"github.com/mlogclub/simple/web"
|
|
|
|
|
)
|
|
|
|
|
|
2026-04-25 10:27:43 +08:00
|
|
|
type ChannelController struct {
|
2026-04-09 10:01:23 +08:00
|
|
|
Ctx iris.Context
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-25 10:27:43 +08:00
|
|
|
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("接入渠道未初始化")
|
|
|
|
|
}
|
2026-04-24 22:24:19 +08:00
|
|
|
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{
|
2026-04-24 22:27:30 +08:00
|
|
|
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)
|
|
|
|
|
}
|