Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录
切换导航
L
library
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
stbz
library
Commits
dbf8070d
提交
dbf8070d
authored
2月 22, 2023
作者:
张立波
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
京东搜索
上级
f38c8611
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
102 行增加
和
8 行删除
+102
-8
ali.go
upstream/ali/ali.go
+3
-4
gome.go
upstream/gome/gome.go
+3
-4
jingdong_goods.go
upstream/jingdong/jingdong_goods.go
+96
-0
没有找到文件。
upstream/ali/ali.go
浏览文件 @
dbf8070d
...
...
@@ -9,7 +9,6 @@ import (
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/os/gtime"
"github.com/gogf/gf/util/gconv"
"gitlab.jxhh.com/stbz/library.git/logs"
"sort"
"strings"
"time"
...
...
@@ -31,7 +30,7 @@ type CommonRes struct {
var
server
*
Config
const
p
kgName
=
"ali"
const
P
kgName
=
"ali"
const
WebSite
=
"1688"
func
New
(
config
*
Config
)
{
...
...
@@ -87,9 +86,9 @@ func (s *Config) Post(ctx context.Context, method string, params g.Map) (str str
ctx
=
context
.
WithValue
(
ctx
,
"Method"
,
"POST"
)
ctx
=
context
.
WithValue
(
ctx
,
"URI"
,
Url
)
if
err
!=
nil
{
logs
.
Errorf
(
ctx
,
pkgName
,
logs
.
FormatErr
,
paramStr
,
err
.
Error
(),
gtime
.
TimestampMilli
()
-
Start
)
g
.
Log
()
.
Cat
(
PkgName
)
.
Ctx
(
ctx
)
.
Infof
(
"参数【%v】错误【%v】响应时间【%v】"
,
paramStr
,
err
.
Error
(),
gtime
.
TimestampMilli
()
-
Start
)
}
else
{
logs
.
Infof
(
ctx
,
pkgName
,
logs
.
FormatSuc
,
paramStr
,
str
,
gtime
.
TimestampMilli
()
-
Start
)
g
.
Log
()
.
Cat
(
PkgName
)
.
Ctx
(
ctx
)
.
Infof
(
"参数【%v】响应【%v】响应时间【%v】"
,
str
,
gtime
.
TimestampMilli
()
-
Start
)
}
}()
str
=
resp
.
ReadAllString
()
...
...
upstream/gome/gome.go
浏览文件 @
dbf8070d
...
...
@@ -10,7 +10,6 @@ import (
"github.com/gogf/gf/text/gstr"
"github.com/gogf/gf/util/gconv"
"github.com/gogf/gf/util/gutil"
"gitlab.jxhh.com/stbz/library.git/logs"
"time"
)
...
...
@@ -58,7 +57,7 @@ type CommonRes struct {
var
server
*
Client
const
p
kgName
=
"gome"
const
P
kgName
=
"gome"
const
CacheKey
=
"gome:token"
func
New
(
config
*
Config
)
{
...
...
@@ -93,9 +92,9 @@ func (s *Client) post(ctx context.Context, method string, req interface{}) (str
ctx
=
context
.
WithValue
(
ctx
,
"Method"
,
"POST"
)
ctx
=
context
.
WithValue
(
ctx
,
"URI"
,
method
)
if
err
!=
nil
{
logs
.
Errorf
(
ctx
,
pkgName
,
logs
.
FormatErr
,
paramStr
,
err
.
Error
(),
gtime
.
TimestampMilli
()
-
Start
)
g
.
Log
()
.
Cat
(
PkgName
)
.
Ctx
(
ctx
)
.
Infof
(
"参数【%v】错误【%v】响应时间【%v】"
,
paramStr
,
err
.
Error
(),
gtime
.
TimestampMilli
()
-
Start
)
}
else
{
logs
.
Infof
(
ctx
,
pkgName
,
logs
.
FormatSuc
,
paramStr
,
str
,
gtime
.
TimestampMilli
()
-
Start
)
g
.
Log
()
.
Cat
(
PkgName
)
.
Ctx
(
ctx
)
.
Infof
(
"参数【%v】响应【%v】响应时间【%v】"
,
paramStr
,
str
,
gtime
.
TimestampMilli
()
-
Start
)
}
}()
str
=
resp
.
ReadAllString
()
...
...
upstream/jingdong/jingdong_goods.go
浏览文件 @
dbf8070d
...
...
@@ -339,3 +339,99 @@ func (*goodsJD) QueryByPage(ctx context.Context, pageNum, pageNo, offset interfa
err
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
return
}
type
GoodsSearchReq
struct
{
Keyword
string
`json:"Keyword"`
//搜索关键字,需要编码
Cid1
string
`json:"cid1,omitempty"`
//一级分类
Cid2
string
`json:"cid2,omitempty"`
//二级分类
CatId
string
`json:"catId,omitempty"`
//分类Id,只支持三级类目Id
PageIndex
int
`json:"pageIndex"`
//当前第几页
PageSize
int
`json:"pageSize"`
//当前页显示
Min
string
`json:"Min,omitempty"`
//价格区间搜索,低价
Max
string
`json:"Max,omitempty"`
//价格区间搜索,高价
Brands
string
`json:"Brands,omitempty"`
//品牌搜索 多个品牌以逗号分隔,需要编码
PriceCol
string
`json:"priceCol,omitempty"`
//价格汇总 priceCol=”yes”
ExtAttrCol
string
`json:"extAttrCol,omitempty"`
//扩展属性汇总 extAttrCol=”yes”
MergeSku
bool
`json:"mergeSku,omitempty"`
//true:合并同一产品不同规格sku;false:不合并同一产品不同规格sku
SortType
string
`json:"sortType,omitempty"`
//销量降序="sale_desc"; 价格升序="price_asc"; 价格降序="price_desc"; 上架时间降序="winsdate_desc";
//按销量排序_15天销售额="sort_totalsales15_desc"; 按15日销量排序="sort_days_15_qtty_desc"; 按30日销量排序="sort_days_30_qtty_desc";
//按15日销售额排序="sort_days_15_gmv_desc"; 按30日销售额排序="sort_days_30_gmv_desc";
}
type
GoodsSearchRes
struct
{
CommonRes
Result
struct
{
ResultCount
int
`json:"resultCount"`
PageSize
int
`json:"pageSize"`
PageIndex
int
`json:"pageIndex"`
PageCount
int
`json:"pageCount"`
BrandAggregate
struct
{
PinyinAggr
[]
string
`json:"pinyinAggr"`
BrandList
[]
struct
{
Id
string
`json:"id"`
Pinyin
string
`json:"pinyin"`
Name
string
`json:"name"`
}
`json:"brandList"`
}
`json:"brandAggregate"`
PriceIntervalAggregate
[]
struct
{
Min
int
`json:"min"`
Max
int
`json:"max"`
}
`json:"priceIntervalAggregate"`
CategoryAggregate
struct
{
FirstCategory
[]
struct
{
CatId
int
`json:"catId"`
Count
int
`json:"count"`
ParentId
int
`json:"parentId"`
Field
string
`json:"field"`
Name
string
`json:"name"`
Weight
int
`json:"weight"`
}
`json:"firstCategory"`
SecondCategory
[]
struct
{
CatId
int
`json:"catId"`
Count
int
`json:"count"`
ParentId
int
`json:"parentId"`
Field
string
`json:"field"`
Name
string
`json:"name"`
Weight
int
`json:"weight"`
}
`json:"secondCategory"`
ThridCategory
[]
struct
{
CatId
int
`json:"catId"`
Count
int
`json:"count"`
ParentId
int
`json:"parentId"`
Field
string
`json:"field"`
Name
string
`json:"name"`
Weight
int
`json:"weight"`
}
`json:"thridCategory"`
}
`json:"categoryAggregate"`
ExpandAttrAggregate
interface
{}
`json:"expandAttrAggregate"`
HitResult
[]
struct
{
WareId
string
`json:"wareId"`
WarePId
string
`json:"warePId"`
BrandId
string
`json:"brandId"`
Brand
string
`json:"brand"`
WareName
string
`json:"wareName"`
CatName
interface
{}
`json:"catName"`
ImageUrl
string
`json:"imageUrl"`
CatId
string
`json:"catId"`
Cid1
string
`json:"cid1"`
Cid2
string
`json:"cid2"`
Cid1Name
interface
{}
`json:"cid1Name"`
Cid2Name
interface
{}
`json:"cid2Name"`
Wstate
string
`json:"wstate"`
Wyn
string
`json:"wyn"`
Synonyms
interface
{}
`json:"synonyms"`
}
`json:"hitResult"`
}
`json:"result"`
}
//Search 搜索商品
func
(
*
goodsJD
)
Search
(
ctx
context
.
Context
,
req
GoodsSearchReq
)
(
res
*
GoodsSearchRes
,
err
error
)
{
method
:=
"/search/search"
result
,
err
:=
server
.
requestApi
(
ctx
,
method
,
gconv
.
Map
(
req
))
if
err
!=
nil
{
return
}
err
=
gjson
.
New
(
result
)
.
Scan
(
&
res
)
return
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论