Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
search_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
75308da1
authored
Jul 22, 2020
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
redis多个
parent
7c4539de
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
13 deletions
conf/redis_config.ini
pkg/config/redis.go
service/goods_service.go
conf/redis_config.ini
View file @
75308da1
...
...
@@ -13,17 +13,9 @@ max_active = 100
idle_timeout
=
20
[api_redis
_read
]
[api_redis]
host
=
192.168.1.235:6379
password
=
icDb29mLy2s
max_idle
=
50
max_active
=
100
idle_timeout
=
20
[api_redis_write]
host
=
192.168.1.235:6379
password
=
icDb29mLy2s
max_idle
=
50
max_active
=
100
idle_timeout
=
20
idle_timeout
=
20
\ No newline at end of file
pkg/config/redis.go
View file @
75308da1
...
...
@@ -25,5 +25,11 @@ func BuildRedisConfgs() (RedisDatabaseMap map[string]RedisDatabase) {
MaxIdle
:
Get
(
"default_redis_read.max_idle"
)
.
String
(),
MaxActive
:
Get
(
"default_redis_read.max_active"
)
.
String
(),
},
"api_redis"
:
{
Host
:
Get
(
"api_redis.host"
)
.
String
(),
Password
:
Get
(
"api_redis.password"
)
.
String
(),
MaxIdle
:
Get
(
"api_redis.max_idle"
)
.
String
(),
MaxActive
:
Get
(
"api_redis.max_active"
)
.
String
(),
},
}
}
service/goods_service.go
View file @
75308da1
...
...
@@ -40,8 +40,17 @@ func GetGoodsInfoByApi(goodsIdsStr string) (goodsList []model.ApiGoods, err erro
//isMap:是否以字典形式返回值,默认是数组
func
CurlGoodsInfo
(
goodsIdsStr
string
,
params
req
.
Param
)
(
goodsList
[]
model
.
ApiGoods
,
goodsListMap
map
[
string
]
model
.
ApiGoods
,
err
error
)
{
goodsIdList
:=
strings
.
Split
(
goodsIdsStr
,
","
)
if
len
(
goodsIdList
)
==
0
{
return
}
//req.Debug = true
goodsServerUrl
:=
config
.
Get
(
"goods.api_url"
)
.
String
()
var
goodsServerUrl
string
if
len
(
goodsIdList
[
0
])
>
7
{
goodsServerUrl
=
config
.
Get
(
"goods.api_url"
)
.
String
()
}
else
{
goodsServerUrl
=
config
.
Get
(
"goods.sz_api_url"
)
.
String
()
}
resp
,
err
:=
req
.
Post
(
goodsServerUrl
+
"/synchronization"
,
params
)
if
err
!=
nil
{
return
...
...
@@ -50,7 +59,6 @@ func CurlGoodsInfo(goodsIdsStr string, params req.Param) (goodsList []model.ApiG
//先判断返回的data是不是字典,不是字典代表可能是返回字符串了
if
gjson
.
Get
(
resp
.
String
(),
"data"
)
.
IsObject
()
{
//排序操作
goodsIdList
:=
strings
.
Split
(
goodsIdsStr
,
","
)
for
_
,
goodsId
:=
range
goodsIdList
{
for
_
,
data
:=
range
gjson
.
Get
(
resp
.
String
(),
"data"
)
.
Map
()
{
if
goodsId
==
data
.
Get
(
"goods_id"
)
.
String
()
{
...
...
@@ -193,7 +201,7 @@ func CurlGoodsInfo(goodsIdsStr string, params req.Param) (goodsList []model.ApiG
func
CheckIsNewCustomer
(
userId
int
)
(
isNewCustomer
,
isMember
bool
)
{
//判断新客价
if
userId
!=
0
{
redisConn
:=
gredis
.
Conn
(
"
search_r
"
)
redisConn
:=
gredis
.
Conn
(
"
api_redis
"
)
defer
redisConn
.
Close
()
userInfoStr
,
err
:=
redis
.
String
(
redisConn
.
Do
(
"HGET"
,
"api_user"
,
userId
))
if
err
!=
nil
{
...
...
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