124 lines
3.3 KiB
Go
124 lines
3.3 KiB
Go
package ai_tool
|
||
|
||
import (
|
||
"context"
|
||
"geo/pkg"
|
||
)
|
||
|
||
type Collect struct {
|
||
apikey string
|
||
}
|
||
|
||
func NewCollect(apikey string) *Collect {
|
||
return &Collect{apikey: apikey}
|
||
}
|
||
|
||
type PlatForm struct {
|
||
Index int `json:"index"`
|
||
PlatFormName string `json:"name"`
|
||
Icon string `json:"icon"`
|
||
}
|
||
|
||
var PlatFormList = []PlatForm{
|
||
{
|
||
Index: 1,
|
||
PlatFormName: "deepseek",
|
||
Icon: "https://attachment-public.oss-cn-hangzhou.aliyuncs.com/geo/platform/deepseek.png",
|
||
},
|
||
{
|
||
Index: 2,
|
||
PlatFormName: "豆包",
|
||
Icon: "https://attachment-public.oss-cn-hangzhou.aliyuncs.com/geo/platform/doubao.png",
|
||
},
|
||
{
|
||
Index: 3,
|
||
PlatFormName: "元宝",
|
||
Icon: "https://attachment-public.oss-cn-hangzhou.aliyuncs.com/geo/platform/yuanbao.png",
|
||
},
|
||
{
|
||
Index: 41,
|
||
PlatFormName: "千问",
|
||
Icon: "https://attachment-public.oss-cn-hangzhou.aliyuncs.com/geo/platform/qianwen.png",
|
||
},
|
||
{
|
||
Index: 5,
|
||
PlatFormName: "文心一言",
|
||
Icon: "https://attachment-public.oss-cn-hangzhou.aliyuncs.com/geo/platform/wenxin.png",
|
||
},
|
||
//{
|
||
// Index: 6,
|
||
// PlatFormName: "纳米",
|
||
//},
|
||
//{
|
||
// Index: 7,
|
||
// PlatFormName: "kimi",
|
||
//}, {
|
||
// Index: 8,
|
||
// PlatFormName: "智普",
|
||
//},
|
||
}
|
||
|
||
type CreateReq struct {
|
||
// 品牌词,多个用英文逗号隔开
|
||
ApiKey string `json:"api_key"`
|
||
// 品牌词,多个用英文逗号隔开
|
||
Keywords string `json:"keywords"`
|
||
// 平台,1-deepseek,2-豆包,3-元宝,4-千问,5-文心一言,6-纳米,7-kimi,8-智普
|
||
Platform int64 `json:"platform"`
|
||
// 问题
|
||
Question string `json:"question"`
|
||
// 建议填第三方的用户id。方便查单
|
||
ThirdID string `json:"third_id,omitempty"`
|
||
}
|
||
|
||
type CreateRes struct {
|
||
Code int `json:"code"`
|
||
Msg string `json:"msg"`
|
||
Time string `json:"time"`
|
||
Data struct {
|
||
RequestId string `json:"request_id"`
|
||
} `json:"data"`
|
||
}
|
||
|
||
func (s *Collect) Create(ctx context.Context, data *CreateReq) (*CreateRes, error) {
|
||
url := "http://8.138.187.158:8082/api/geo/add_shoulu"
|
||
data.ApiKey = s.apikey
|
||
mapInfo, err := pkg.StructToMap(data)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
var res CreateRes
|
||
err = pkg.PostMultipart(url, mapInfo, &res)
|
||
return &res, err
|
||
}
|
||
|
||
type CheckTaskRes struct {
|
||
Code int `json:"code"`
|
||
Msg string `json:"msg"`
|
||
Time string `json:"time"`
|
||
Data struct {
|
||
ShouluDate string `json:"shoulu_date"` //收录日期,格式:2025-12-12
|
||
Platform int `json:"platform"` //AI平台,1ds, 2豆包, 3元宝,4千问,5文心,6纳米,7kimi,8智普
|
||
ScriptTime int `json:"script_time"` //最后查询时间戳
|
||
Question string `json:"question"` //问题
|
||
HitWord string `json:"hit_word"` //品牌词
|
||
Status int `json:"status"` //查询状态,0-查询中,1已收录,2未收录,3查询失败已退款
|
||
ShareUrl string `json:"share_url"` //查询分享链接
|
||
KeywordRes string `json:"keyword_res"` //命中词
|
||
ImgUrl string `json:"img_url"` //查询结果截图
|
||
RequestId string `json:"request_id"` //任务id
|
||
} `json:"data"`
|
||
}
|
||
|
||
func (s *Collect) CheckTask(requestId string) (*CheckTaskRes, error) {
|
||
url := "http://8.138.187.158:8082/api/geo/check_task"
|
||
request := map[string]interface{}{
|
||
"request_id": requestId,
|
||
"api_key": s.apikey,
|
||
}
|
||
|
||
var res CheckTaskRes
|
||
err := pkg.PostMultipart(url, request, &res)
|
||
return &res, err
|
||
}
|