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
06e7565b
authored
Mar 15, 2021
by
wang
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
增加images字段接口
parent
01371268
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
54 additions
and
9 deletions
controller/sku_controller.go
doc/redis_config_generate.go
open/Code.go
pkg/config/mysql.go
pkg/mysql/mysql.go
routes/router.go
service/service_class.go
service/service_sku.go
controller/sku_controller.go
View file @
06e7565b
...
...
@@ -51,7 +51,7 @@ func GetSkuListPrice(ctx *gin.Context) {
/**
用
goods
_id 获取sku列表价格库存字段
用
classParent
_id 获取sku列表价格库存字段
*/
func
GetClassList
(
ctx
*
gin
.
Context
)
{
parent_id
:=
ctx
.
Request
.
FormValue
(
"parent_id"
)
...
...
@@ -64,3 +64,13 @@ func GetClassList(ctx *gin.Context) {
common
.
NResponse
(
""
,
0
,
rsp
)
.
OutPut
(
ctx
)
}
/**
用goods_id 获取sku列表图片字段
*/
func
GetSkuListImages
(
ctx
*
gin
.
Context
)
{
req
:=&
model
.
QuerySkuReq
{}
e
.
CheckError
(
model
.
ValidateBind
(
ctx
,
req
))
rsp
,
err
:=
service
.
NewSkuService
()
.
GetSkuListImages
(
req
)
e
.
CheckError
(
err
)
common
.
NResponse
(
""
,
0
,
rsp
)
.
OutPut
(
ctx
)
}
doc/redis_config_generate.go
View file @
06e7565b
...
...
@@ -22,6 +22,7 @@ var(
GetSkuListFull
=
"GetSkuListFull"
GetSkuListPrice
=
"GetSkuListPrice"
GetClassList
=
"GetClassList"
GetSkuListImages
=
"GetSkuListImages"
//redis 表key
openWhiteList
=
"openWhiteList"
//白名单
...
...
@@ -81,7 +82,7 @@ func whiteIp() {
"222.92.21.99"
,
"192.168.2.72"
,
"::1"
,
"119.123.7
9.225
"
,
"119.123.7
8.14
"
,
}
/*whiteList:=[]string{
...
...
@@ -119,8 +120,9 @@ func newBusinessList() {
func
newWhiteBlack
()
{
jdWhiteList
:=
jdToken
+
"_"
+
openWhiteList
jdBlackList
:=
jdToken
+
"_"
+
openBlackList
//180.163.220.66
config
:=
map
[
string
]
string
{
jdWhiteList
:
"192.168.2.72 222.92.21.99 192.168.2.129 ::1"
,
jdWhiteList
:
"192.168.2.72 222.92.21.99 192.168.2.129 ::1
119.123.79.225 119.123.78.14
"
,
jdBlackList
:
"::1 "
,
}
...
...
@@ -154,9 +156,16 @@ func businessInterfaceList() {
"dayMaxNum"
:
1000000
,
"minMaxNum"
:
300
,
"totalMaxNum"
:
10000
,
},
jdToken
+
"_"
+
GetSkuListImages
:
map
[
string
]
interface
{}{
"dayMaxNum"
:
1000000
,
"minMaxNum"
:
300
,
"totalMaxNum"
:
10000
,
},
},
/*baiduToken+"_"+getSkuListByClass: map[string]interface{}{
"dayMaxNum":100,
"minMaxNum":500,
...
...
open/Code.go
View file @
06e7565b
...
...
@@ -4,8 +4,8 @@ const (
//======================开放平台错误码,81开头========================
//商家配置 811
BUSINESSERR1
=
81105
//读取商家列表
redis错误
BUSINESSERR2
=
81104
//商家不存在 token不存在
BUSINESSERR1
=
81105
//读取商家列表
BUSINESSERR2
=
81104
//商家不存在
redis错误
token不存在
BUSINESSERR3
=
81106
//平台没有配置商家列表
//接口配置812
...
...
pkg/config/mysql.go
View file @
06e7565b
...
...
@@ -21,7 +21,13 @@ func BuildDatabaseList() (DatabaseList map[string]BaseDatabase) {
Database
:
Get
(
"pool_class.database"
)
.
String
(),
Prefix
:
Get
(
"pool_class.table_prefix"
)
.
String
(),
},
"supp"
:
{
UserName
:
Get
(
"supp.user_name"
)
.
String
(),
Password
:
Get
(
"supp.password"
)
.
String
(),
Host
:
Get
(
"supp.host"
)
.
String
(),
Database
:
Get
(
"supp.database"
)
.
String
(),
Prefix
:
Get
(
"supp.table_prefix"
)
.
String
(),
},
}
}
pkg/mysql/mysql.go
View file @
06e7565b
...
...
@@ -24,6 +24,7 @@ func Setup() error {
dataSourceName
:=
fmt
.
Sprintf
(
"%s:%s@tcp(%s)/%s?charset=utf8"
,
userName
,
password
,
host
,
database
)
DatabaseConMap
[
conName
],
err
=
xorm
.
NewEngine
(
"mysql"
,
dataSourceName
)
//xorm.NewEngineGroup()
if
err
!=
nil
{
return
e
.
NewFatalError
(
err
.
Error
())
//这里返回致命异常
}
...
...
routes/router.go
View file @
06e7565b
...
...
@@ -29,6 +29,8 @@ func InitRouter() *gin.Engine {
controller
.
Open_Middleware
(
"GetSkuListPrice"
),
controller
.
GetSkuListPrice
)
rsku
.
GET
(
"/GetClassList"
,
controller
.
Error_Middleware
(
"sku_query"
),
controller
.
Open_Middleware
(
"GetClassList"
),
controller
.
GetClassList
)
rsku
.
GET
(
"/GetSkuListImages"
,
controller
.
Error_Middleware
(
"sku_query"
),
controller
.
Open_Middleware
(
"GetSkuListImages"
),
controller
.
GetSkuListImages
)
}
/*//用classId获取sku列表
...
...
service/service_class.go
View file @
06e7565b
...
...
@@ -21,6 +21,9 @@ func (this *ClassService) GetClassList(parentId int)(rsp []model.QueryClassRsp,e
return
}
func
NewClassService
()
*
ClassService
{
return
&
ClassService
{}
}
\ No newline at end of file
service/service_sku.go
View file @
06e7565b
...
...
@@ -53,7 +53,7 @@ func (this *SkuService)GetSkuListByClass(req *model.QuerySkuCreq) (rsp *model.Qu
return
rsp
,
e
.
NewApiError
(
"service error"
,
open
.
REMOTESKUINFO
)
}
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"
,
"supplier_name"
,}
"class_id1"
,
"class_id2"
,
"class_id1_name"
,
"class_id2_name"
,
"attrs"
,
"ladder_price"
,
"supplier_name"
,
"goods_images"
,
}
//field:=[]string{"spu_id","attrs","supplier_name","goods_images","hk_delivery_time"}
rsp
.
SkuData
=
model
.
SkuFilter
(
*
remoteData
,
field
)
...
...
@@ -72,7 +72,7 @@ func (this *SkuService) GetSkuListFull(req * model.QuerySkuReq)(rsp *model.Query
return
rsp
,
e
.
NewApiError
(
"service error"
,
open
.
REMOTESKUINFO
)
}
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"
,
"supplier_name"
}
"class_id1"
,
"class_id2"
,
"class_id1_name"
,
"class_id2_name"
,
"attrs"
,
"ladder_price"
,
"supplier_name"
,
"goods_images"
,
}
rsp
.
SkuData
=
model
.
SkuFilter
(
*
remoteData
,
field
)
return
}
...
...
@@ -88,6 +88,19 @@ func (this *SkuService) GetSkuListPrice(req * model.QuerySkuReq)(rsp model.Query
return
}
//获取sku列表 价格库存相关字段
func
(
this
*
SkuService
)
GetSkuListImages
(
req
*
model
.
QuerySkuReq
)(
rsp
model
.
QuerySkuRsp
,
err
error
)
{
remoteData
,
err
:=
this
.
getRemoteSku
(
req
.
GoodsIds
)
if
(
err
!=
nil
){
common
.
PrintStdout
()
.
Printf
(
err
.
Error
())
return
rsp
,
e
.
NewApiError
(
"service error"
,
open
.
REMOTESKUINFO
)
}
field
:=
[]
string
{
"goods_images"
}
rsp
.
SkuData
=
model
.
SkuFilter
(
*
remoteData
,
field
)
return
}
//获取远端商详接口
func
(
this
*
SkuService
)
getRemoteSku
(
ids
string
)
(
remoteData
*
model
.
RemoteSkuData
,
err
error
){
resStr
:=
""
...
...
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