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
6779c613
authored
Jul 19, 2023
by
SUDPTDUBLXEROFX\Administrator
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'hcy-2023.7.14-spu分离' into dev
parents
35a3ad79
9e23d484
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
31 additions
and
5 deletions
conf/dev/redis.ini
pkg/config/redis.go
service/service_ly.go
service/service_spu.go
service/service_zy.go
service/service_zy_common.go
conf/dev/redis.ini
View file @
6779c613
...
...
@@ -13,5 +13,14 @@ max_idle = 2000
max_active
=
5000
idle_timeout
=
20
;新spu redis
[default_redis_spu]
host
=
192.168.1.234:6379
password
=
icDb29mLy1s
max_idle
=
2000
max_active
=
5000
idle_timeout
=
20
;存放redis所有键
[redis_all]
\ No newline at end of file
pkg/config/redis.go
View file @
6779c613
...
...
@@ -16,6 +16,8 @@ func BuildRedisConfigs() (RedisDatabaseMap map[string]RedisDatabase) {
redisReadMaxActive
,
_
:=
Get
(
"default_redis_read.max_active"
)
.
Int
()
redisWriteMaxIdle
,
_
:=
Get
(
"default_redis_write.max_idle"
)
.
Int
()
redisWriteMaxActive
,
_
:=
Get
(
"default_redis_write.max_active"
)
.
Int
()
redisSpuMaxIdle
,
_
:=
Get
(
"default_redis_spu.max_idle"
)
.
Int
()
redisSpuMaxActive
,
_
:=
Get
(
"default_redis_spu.max_active"
)
.
Int
()
return
map
[
string
]
RedisDatabase
{
"search_r"
:
{
Host
:
Get
(
"default_redis_read.host"
)
.
String
(),
...
...
@@ -35,5 +37,11 @@ func BuildRedisConfigs() (RedisDatabaseMap map[string]RedisDatabase) {
MaxIdle
:
redisWriteMaxIdle
,
MaxActive
:
redisWriteMaxActive
,
},
"spu"
:
{
Host
:
Get
(
"default_redis_spu.host"
)
.
String
(),
Password
:
Get
(
"default_redis_spu.password"
)
.
String
(),
MaxIdle
:
redisSpuMaxIdle
,
MaxActive
:
redisSpuMaxActive
,
},
}
}
service/service_ly.go
View file @
6779c613
...
...
@@ -32,8 +32,10 @@ type Power struct {
*/
func
(
ls
*
LyService
)
LyGoodsDetail
(
ctx
*
gin
.
Context
,
goodsIds
[]
string
,
ch
chan
sync
.
Map
)
{
redisConn
:=
gredis
.
Conn
(
"search_r"
)
redisConnSpu
:=
gredis
.
Conn
(
"spu"
)
defer
func
()
{
redisConn
.
Close
()
redisConnSpu
.
Close
()
}()
fast
:=
ctx
.
Request
.
FormValue
(
"power[fast]"
)
//是否展示属性
...
...
@@ -59,7 +61,7 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
//读取包装字段的缓存
if
sku
.
SupplierId
==
7
||
sku
.
SupplierId
==
13
{
//sku_raw_map哪里写入(成意写的)
packing
,
_
:=
redis
.
String
(
redisConn
.
Do
(
"HGET"
,
"sku_raw_map"
,
goodsId
))
packing
,
_
:=
redis
.
String
(
redisConn
Spu
.
Do
(
"HGET"
,
"sku_raw_map"
,
goodsId
))
sku
.
Packing
=
gjson
.
Get
(
packing
,
"pack"
)
.
String
()
}
sku
=
ls
.
GetGoodsImages
(
sku
,
spu
)
...
...
service/service_spu.go
View file @
6779c613
...
...
@@ -16,6 +16,6 @@ func (ss *SpuService) getSpuList(skuArr map[string]string) (spuList map[string]s
spuIds
=
append
(
spuIds
,
spuId
)
}
//批量获取spu详情
spuList
=
gredis
.
Hmget
(
"
default_r
"
,
"spu"
,
spuIds
)
spuList
=
gredis
.
Hmget
(
"
spu
"
,
"spu"
,
spuIds
)
return
}
service/service_zy.go
View file @
6779c613
...
...
@@ -34,9 +34,11 @@ type ZiyingService struct {
*/
func
(
qs
*
ZiyingService
)
ZyGoodsDetail
(
ctx
*
gin
.
Context
,
goodsIds
[]
string
,
ch
chan
sync
.
Map
)
{
redisConn
:=
gredis
.
Conn
(
"search_r"
)
redisConnSpu
:=
gredis
.
Conn
(
"spu"
)
defer
func
()
{
//wg.Done();
redisConn
.
Close
()
redisConnSpu
.
Close
()
}()
skuArr
:=
gredis
.
Hmget
(
"search_r"
,
"Self_SelfGoods"
,
goodsIds
)
//批量获取商品详情
...
...
@@ -108,7 +110,7 @@ func (qs *ZiyingService) ZyGoodsDetail(ctx *gin.Context, goodsIds []string, ch c
var
brandId
int64
var
brandName
string
if
spuId
!=
0
{
spuStr
,
_
:=
gredis
.
String
(
redisConn
.
Do
(
"HGET"
,
"spu"
,
spuId
))
spuStr
,
_
:=
gredis
.
String
(
redisConn
Spu
.
Do
(
"HGET"
,
"spu"
,
spuId
))
brandId
=
gjson
.
Get
(
spuStr
,
"brand_id"
)
.
Int
()
brandName
,
_
=
gredis
.
String
(
redisConn
.
Do
(
"HGET"
,
"brand"
,
brandId
))
var
ly
LyService
...
...
service/service_zy_common.go
View file @
6779c613
...
...
@@ -54,8 +54,12 @@ func (qs *ZiyingService) GetActivity(skuInfo string) (priceActivity model.PriceA
var
standardBrandId
int
spuId
:=
gjson
.
Get
(
skuInfo
,
"spu_id"
)
.
String
()
redisCon
:=
gredis
.
Conn
(
"default_r"
)
spuStr
,
_
:=
redis
.
String
(
redisCon
.
Do
(
"HGET"
,
"spu"
,
spuId
))
defer
redisCon
.
Close
()
redisConSpu
:=
gredis
.
Conn
(
"spu"
)
spuStr
,
_
:=
redis
.
String
(
redisConSpu
.
Do
(
"HGET"
,
"spu"
,
spuId
))
defer
func
()
{
redisCon
.
Close
()
redisConSpu
.
Close
()
}()
if
spuStr
==
""
{
standardBrandId
=
0
}
else
{
...
...
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