Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
wang
/
golang-open-platform
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
d3e924d5
authored
Feb 04, 2021
by
wang
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
调整错误码和字段筛选
parent
7c3a6c21
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
23 deletions
controller/sku_controller.go
doc/redis_config_generate.go
model/filter.go
open/Code.go
open/dao.go
service/service_sku.go
controller/sku_controller.go
View file @
d3e924d5
...
...
@@ -33,7 +33,7 @@ func GetSkuListFull(ctx *gin.Context) {
e
.
CheckError
(
model
.
ValidateBind
(
ctx
,
req
))
rsp
,
err
:=
service
.
NewSkuService
()
.
GetSkuListFull
(
req
)
e
.
CheckError
(
err
)
common
.
NResponse
(
""
,
20
0
,
rsp
)
.
OutPut
(
ctx
)
common
.
NResponse
(
""
,
0
,
rsp
)
.
OutPut
(
ctx
)
}
/**
...
...
@@ -44,5 +44,5 @@ func GetSkuListPrice(ctx *gin.Context) {
e
.
CheckError
(
model
.
ValidateBind
(
ctx
,
req
))
rsp
,
err
:=
service
.
NewSkuService
()
.
GetSkuListPrice
(
req
)
e
.
CheckError
(
err
)
common
.
NResponse
(
""
,
20
0
,
rsp
)
.
OutPut
(
ctx
)
common
.
NResponse
(
""
,
0
,
rsp
)
.
OutPut
(
ctx
)
}
doc/redis_config_generate.go
View file @
d3e924d5
...
...
@@ -85,12 +85,12 @@ func businessInterfaceList() {
config
:=
map
[
string
]
interface
{}{
jdToken
+
"_"
+
GetSkuListByClass
:
map
[
string
]
interface
{}{
"dayMaxNum"
:
10000000
,
"minMaxNum"
:
5
0
,
"minMaxNum"
:
5
,
"totalMaxNum"
:
10000
,
},
jdToken
+
"_"
+
GetSkuListFull
:
map
[
string
]
interface
{}{
"dayMaxNum"
:
10000000
,
"minMaxNum"
:
5
0
,
"minMaxNum"
:
5
,
"totalMaxNum"
:
10000
,
},
jdToken
+
"_"
+
GetSkuListPrice
:
map
[
string
]
interface
{}{
...
...
model/filter.go
View file @
d3e924d5
...
...
@@ -33,6 +33,8 @@ func filterData(remoteData RemoteSkuData,filterField []string)(data RemoteSkuDat
if
(
field
==
"ladder_price"
){
newItem
[
field
]
=
filterLadder
(
info
[
field
])
}
}
else
{
common
.
PrintStdout
()
.
Printf
(
"skuId:%s,字段:%s 不存在"
,
string
(
skuId
),
field
)
}
}
remoteData
[
skuId
]
=
newItem
...
...
open/Code.go
View file @
d3e924d5
...
...
@@ -2,28 +2,31 @@ package open
const
(
//开放平台错误码
BUSINESSERR1
=
10007505
//读取商家列表 redis错误
BUSINESSERR2
=
10007404
//商家不存在 token不存在
BUSINESSERR3
=
10007406
//平台没有配置商家列表
//======================开放平台错误码,81开头========================
//商家配置 811
BUSINESSERR1
=
81105
//读取商家列表 redis错误
BUSINESSERR2
=
81104
//商家不存在 token不存在
BUSINESSERR3
=
81106
//平台没有配置商家列表
BUSINESSCONFIG1
=
10007407
//读取商家与接口关系 redis错误(openBusinessInterface)
BUSINESSCONFIG2
=
10007408
//平台没有配置 商家与接口关系 (redis hash openBusinessInterface 空)
BUSINESSCONFIG3
=
10007409
//商家没有此接口的权限
//接口配置812
BUSINESSCONFIG1
=
81205
//读取商家与接口关系 redis错误(openBusinessInterface)
BUSINESSCONFIG2
=
81206
//平台没有配置 商家与接口关系 (redis hash openBusinessInterface 空)
BUSINESSCONFIG3
=
812409
//商家没有此接口的权限
WHILTREDISEERR1
=
10008505
//白名单读取redis错误
WHILTREDISEERR2
=
10008404
//ip不在白名单里面
WHILTREDISEERR3
=
10008406
//没有设置白名单
//白名单配置813
WHILTREDISEERR1
=
813505
//白名单读取redis错误
WHILTREDISEERR2
=
813404
//ip不在白名单里面
WHILTREDISEERR3
=
813406
//没有设置白名单
FLOWERR1
=
10009505
//流量控制操作 redis错误
FLOWERR3
=
10009406
//触发分钟级流量限制
FLOWERR4
=
10009407
//触发天级流量限制
//白名单配置814
FLOWERR1
=
814505
//流量控制操作 redis错误
FLOWERR3
=
814406
//触发分钟级流量限制
FLOWERR4
=
814407
//触发天级流量限制
//获取sku错误码
//
sku接口===================================== 80开头
获取sku错误码
PARAM1
=
80001
//参数问题(缺失or数据格式不对)
OTHERERROR
=
80500
//其他错误,比如读取redis出错
REMOTESKUINFO
=
80501
//调用远程商详接口报错
)
open/dao.go
View file @
d3e924d5
...
...
@@ -23,7 +23,7 @@ func (this *Dao) getOpenWhiteList()(whitestr string,err error){
common
.
PrintStdout
()
.
Printf
(
strconv
.
Itoa
(
WHILTREDISEERR1
)
+
":读取redis 白名单错误"
+
err
.
Error
())
return
""
,
e
.
NewApiError
(
"white err"
,
WHILTREDISEERR1
)
}
return
return
whitestr
,
nil
}
//获取商家列表 openTokenBusinessList
...
...
service/service_sku.go
View file @
d3e924d5
...
...
@@ -33,7 +33,7 @@ func (this *SkuService)GetSkuListByClass(req *model.QuerySkuCreq) (rsp *model.Qu
}
if
(
req
.
Page
>
0
){
//验证下page是否有效
if
(
math
.
Ceil
(
float64
(
pageData
.
Count
/
rsp
.
Limit
))
<
float64
(
pageData
.
Page
)){
if
(
math
.
Ceil
(
float64
(
pageData
.
Count
/
rsp
.
Limit
))
<
float64
(
req
.
Page
)){
return
nil
,
e
.
NewApiError
(
"page invalid"
,
open
.
PARAM1
)
}
mongoOpenSku
,
err
:=
dao
.
GetMongoOpenSku
(
req
.
ClassId
,
req
.
Page
)
...
...
@@ -53,7 +53,8 @@ func (this *SkuService)GetSkuListByClass(req *model.QuerySkuCreq) (rsp *model.Qu
common
.
PrintStdout
()
.
Printf
(
"获取远程商详接口报错 msg:"
+
err
.
Error
())
return
nil
,
e
.
NewApiError
(
"service err"
,
open
.
REMOTESKUINFO
)
}
field
:=
[]
string
{
"goods_id"
,
"spu_id"
,
"brand_id"
,
"brand_name"
,
"goods_name"
,
"stock"
,
"moq"
,
"mpq"
,
"class_id1"
,
"class_name"
,
"attrs"
,
"ladder_price"
,}
field
:=
[]
string
{
"goods_id"
,
"spu_id"
,
"brand_id"
,
"brand_name"
,
"goods_name"
,
"stock"
,
"moq"
,
"mpq"
,
"class_id1"
,
"class_id2"
,
"class_id1_name"
,
"class_id2_name"
,
"attrs"
,
"ladder_price"
,}
//field:=[]string{"spu_id","attrs","supplier_name","goods_images","hk_delivery_time"}
rsp
.
SkuData
=
model
.
SkuFilter
(
*
remoteData
,
field
)
...
...
@@ -67,7 +68,12 @@ func (this *SkuService) GetSkuListFull(req * model.QuerySkuReq)(rsp *model.Query
//skuIds
rsp
=&
model
.
QuerySkuRsp
{}
remoteData
,
err
:=
this
.
getRemoteSku
(
req
.
GoodsIds
)
field
:=
[]
string
{
"goods_id"
,
"spu_id"
,
"brand_id"
,
"brand_name"
,
"goods_name"
,
"stock"
,
"moq"
,
"mpq"
,
"class_id1"
,
"class_name"
,
"attrs"
,
"ladder_price"
,}
//"class_id1": 10014,
// "class_id2": 10031,
// "class_id1_name": "处理器及微控制器",
// "class_id2_name": "ADI(亚德诺)",
field
:=
[]
string
{
"goods_id"
,
"spu_id"
,
"brand_id"
,
"brand_name"
,
"goods_name"
,
"stock"
,
"moq"
,
"mpq"
,
"class_id1"
,
"class_id2"
,
"class_id1_name"
,
"class_id2_name"
,
"attrs"
,
"ladder_price"
,}
rsp
.
SkuData
=
model
.
SkuFilter
(
*
remoteData
,
field
)
return
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment