Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄成意
/
go_sku_server
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
aaee156b
authored
Jan 15, 2021
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
修复无法接收post参数的问题
parent
08779c31
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
15 deletions
controller/sku_controller.go
service/service_ly.go
controller/sku_controller.go
View file @
aaee156b
...
...
@@ -32,24 +32,30 @@ const goods_slice_count = 10 //每多少个型号id开启一个协程
*/
func
CommonController
(
ctx
*
gin
.
Context
)
map
[
string
]
interface
{}{
func
CommonController
(
ctx
*
gin
.
Context
)
map
[
string
]
interface
{}
{
common
.
PrintDebugHeader
(
ctx
)
//开启debug调试
zyService
:=
service
.
ZiyingService
{}
//实例化自营查询
lyService
:=
service
.
LyService
{}
//实例化自营查询
var
goodsIdArr
[]
string
//抽取自营 或者联营 goods_id
GoodsIdStr
:=
ctx
.
Request
.
FormValue
(
"goods_id"
)
if
GoodsIdStr
==
""
{
goodsIdMap
:=
ctx
.
PostFormMap
(
"goods_id"
)
for
_
,
goodsId
:=
range
goodsIdMap
{
goodsIdArr
=
append
(
goodsIdArr
,
goodsId
)
}
}
else
{
goodsIdArr
=
php2go
.
Explode
(
","
,
GoodsIdStr
)
}
if
len
(
goodsIdArr
)
==
0
{
common
.
Output
(
ctx
,
1001
,
"查询型号ID不得为空"
,
""
)
return
nil
}
goodsIdArr
:=
php2go
.
Explode
(
","
,
GoodsIdStr
)
//wg := sync.WaitGroup{} //协程
ch
:=
make
(
chan
sync
.
Map
)
//管道
p
:=
0
//总共协程
zyGoodsId
:=
make
([]
string
,
0
)
lyGoodsId
:=
make
([]
string
,
0
)
for
_
,
goodsId
:=
range
goodsIdArr
{
...
...
@@ -114,14 +120,14 @@ func CommonController(ctx *gin.Context) map[string]interface{}{
return
temp
}
func
Synchronization
(
ctx
*
gin
.
Context
)
{
func
Synchronization
(
ctx
*
gin
.
Context
)
{
res
:=
CommonController
(
ctx
)
res
:=
CommonController
(
ctx
)
common
.
Output
(
ctx
,
0
,
"success"
,
res
)
}
func
Synchronization1
(
ctx
*
gin
.
Context
)
{
func
Synchronization1
(
ctx
*
gin
.
Context
)
{
res
:=
CommonController
(
ctx
)
res
:=
CommonController
(
ctx
)
common
.
Output
(
ctx
,
0
,
"success"
,
res
)
}
...
...
@@ -134,8 +140,8 @@ func Hbsdata(ctx *gin.Context) {
/*
测试redis
*/
func
Testr
(
ctx
*
gin
.
Context
)
{
*/
func
Testr
(
ctx
*
gin
.
Context
)
{
time1
:=
time
.
Now
()
.
UnixNano
()
/
1e6
...
...
@@ -145,11 +151,10 @@ func Testr(ctx *gin.Context) {
}()
goods_ids
:=
ctx
.
Request
.
FormValue
(
"goods_ids"
)
skuArr
:=
gredis
.
Hmget
(
"default_r"
,
"sku"
,
php2go
.
Explode
(
","
,
goods_ids
))
;
skustr
,
_
:=
json
.
Marshal
(
skuArr
)
skuArr
:=
gredis
.
Hmget
(
"default_r"
,
"sku"
,
php2go
.
Explode
(
","
,
goods_ids
))
skustr
,
_
:=
json
.
Marshal
(
skuArr
)
time2
:=
time
.
Now
()
.
UnixNano
()
/
1e6
ctx
.
String
(
200
,
"查询redis开始时间毫秒:"
+
gconv
.
String
(
time1
)
+
" 结束时间毫秒:"
+
gconv
.
String
(
time2
)
+
" 查询时间毫秒:"
+
gconv
.
String
(
time2
-
time1
)
+
" "
+
string
(
skustr
))
ctx
.
String
(
200
,
"查询redis开始时间毫秒:"
+
gconv
.
String
(
time1
)
+
" 结束时间毫秒:"
+
gconv
.
String
(
time2
)
+
" 查询时间毫秒:"
+
gconv
.
String
(
time2
-
time1
)
+
" "
+
string
(
skustr
))
}
service/service_ly.go
View file @
aaee156b
...
...
@@ -164,7 +164,6 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
//用spuInfo补全信息
sku
=
ls
.
CombineSup
(
sku
,
spu
)
//最后一步,将sku的全部信息放到有序map里面
GoodsRes
.
Store
(
goodsId
,
sku
)
//(*goodsRes)[goodsId] = A
...
...
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