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
d1cfe9f1
authored
Nov 11, 2025
by
hcy
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
并发问题
parent
0f7d1c1a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
17 deletions
controller/sku_controller.go
service/service_ly.go
service/service_spu.go
controller/sku_controller.go
View file @
d1cfe9f1
...
...
@@ -96,7 +96,7 @@ func CommonController(ctx *gin.Context) map[string]interface{} {
redisZySkuArr
=
gredis
.
Hmget
(
"default_r"
,
"Self_SelfGoods"
,
zyGoodsId
)
}
//批量查询归档sku
if
len
(
preSkuIds
)
>
0
{
if
len
(
preSkuIds
)
==
0
{
var
prevSkuArr
[]
bson
.
M
prevSkuMongo
:=
mongo
.
Conn
(
"pre_sku"
)
...
...
@@ -176,6 +176,8 @@ func CommonController(ctx *gin.Context) map[string]interface{} {
temp
[
goodsId
]
=
false
continue
}
gredis
.
GetPoolStats
(
"default_r"
)
wg
.
Add
(
1
)
semaphore
<-
struct
{}{}
// 获取信号量
// 启动协程,传递独立的 context 和参数,而不是 gin.Context
...
...
service/service_ly.go
View file @
d1cfe9f1
...
...
@@ -7,7 +7,6 @@ import (
"github.com/tidwall/gjson"
"go_sku_server/model"
"go_sku_server/pkg/common"
"go_sku_server/pkg/gredis"
"go_sku_server/pkg/logger"
"go_sku_server/pkg/mongo"
"go_sku_server/service/sorter"
...
...
@@ -38,13 +37,13 @@ type Power struct {
func
(
ls
*
LyService
)
LyGoodsDetail
(
ctx
context
.
Context
,
params
RequestParams
,
skuStr
,
goodsId
,
spuStr
string
,
ch
chan
sync
.
Map
,
tag
int
)
{
start_time
:=
common
.
ProTime
()
redisConn
:=
gredis
.
Conn
(
"search_r"
)
redisConnSpu
:=
gredis
.
Conn
(
"spu"
)
// 连接prev_sku MongoDB
defer
func
()
{
redisConn
.
Close
()
redisConnSpu
.
Close
()
}()
//
redisConn := gredis.Conn("search_r")
//
redisConnSpu := gredis.Conn("spu")
//
//
连接prev_sku MongoDB
//
defer func() {
// //
redisConn.Close()
// //
redisConnSpu.Close()
//
}()
//各种展示条件(从参数中获取,而不是从 gin.Context)
//是否快速展示
...
...
service/service_spu.go
View file @
d1cfe9f1
...
...
@@ -165,8 +165,6 @@ func (ss *SpuService) SetInit(redisLySkuArr, redisLySpuArr map[string]string, zy
//批量获取标签b
GoodsLabelTags
=
gredis
.
Hmget
(
"default_r"
,
"goods_label_tags"
,
[]
string
{
"0"
,
"1"
,
"2"
,
"3"
,
"4"
,
"5"
,
"6"
})
//BatchErpTax(erpMd5Key) //批量查询品牌
var
wg
sync
.
WaitGroup
//
wg
.
Add
(
1
)
...
...
@@ -174,12 +172,12 @@ func (ss *SpuService) SetInit(redisLySkuArr, redisLySpuArr map[string]string, zy
defer
wg
.
Done
()
BatchLyClassName
(
ClassIds
)
//批量查询分类
}()
//
//
wg.Add(1)
//
go func() {
//
defer wg.Done()
//
BatchErpTax(erpMd5Key) //批量查询品牌
//
}()
wg
.
Add
(
1
)
go
func
()
{
defer
wg
.
Done
()
BatchErpTax
(
erpMd5Key
)
//批量查询品牌
}()
wg
.
Add
(
1
)
go
func
()
{
...
...
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