geoGo/internal/ai_tool/collect.go

85 lines
2.4 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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"`
}
type CreateReq struct {
// 品牌词,多个用英文逗号隔开
ApiKey string `json:"api_key"`
// 品牌词,多个用英文逗号隔开
Keywords string `json:"keywords"`
// 平台1-deepseek2-豆包3-元宝4-千问5-文心一言6-纳米7-kimi8-智普
Platform int `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纳米7kimi8智普
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(ctx context.Context, 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
}