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
7a36aafb
authored
Jul 06, 2020
by
huangchengyi
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
1.0
parent
3e7012c7
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
14 deletions
cmd/test1.go
pkg/gredis/redis.go
service/common_ly_service.go-bak
service/mouser_service.go
cmd/test1.go
View file @
7a36aafb
...
...
@@ -3,7 +3,9 @@ package main
import
(
"flag"
"os"
"fmt"
"search_server/boot"
"search_server/pkg/gredis"
"search_server/service"
)
...
...
@@ -24,6 +26,13 @@ func main() {
//fmt.Println(flag)
//os.Exit(1)
redisConn
:=
gredis
.
Conn
(
"search_r"
)
defer
redisConn
.
Close
()
attrName
,
err
:=
gredis
.
String
(
redisConn
.
Do
(
"GET"
,
"hcy1"
))
fmt
.
Println
(
err
)
fmt
.
Println
(
attrName
)
//os.Exit(1)
dd
:=
service
.
OutLink
(
"LM358"
,
"-1"
)
print
(
"niin"
)
print
(
dd
)
...
...
pkg/gredis/redis.go
View file @
7a36aafb
...
...
@@ -32,6 +32,10 @@ func Setup() (err error) {
return
nil
}
func
String
(
a
interface
{},
err
error
)
(
string
,
error
)
{
return
redis
.
String
(
a
,
err
)
}
func
getConn
(
writeHost
,
password
string
)
(
pool
*
redis
.
Pool
,
err
error
)
{
maxIdle
,
_
:=
config
.
Get
(
"redis.max_idle"
)
.
Int
()
maxActive
,
_
:=
config
.
Get
(
"redis.max_active"
)
.
Int
()
...
...
service/common_ly_service.go-bak
View file @
7a36aafb
...
...
@@ -40,7 +40,7 @@ var brand_name_all string = config.Get("redis_all.BRAND_NAME_ALL").String() /
func
getSkuByGoodsSn
(
goods_list
map
[
string
]*
model
.
LyClearGoodsList
,
supplier_info
*
model
.
SUPPLIER_REDIS_INFO_
)
map
[
string
]
interface
{}{
originGoods
:=
make
(
map
[
string
]
interface
{},
0
)
searredis
:=
gredis
.
Conn
(
"search_r
ead
"
)
searredis
:=
gredis
.
Conn
(
"search_r"
)
defer
searredis
.
Close
()
for
goods_sn
,
info
:=
range
goods_list
{
...
...
@@ -49,7 +49,7 @@ func getSkuByGoodsSn(goods_list map[string]*model.LyClearGoodsList,supplier_info
searredis
.
Do
(
"set"
,
"hcttest"
,
"dddd"
)
sku_id
,
_
:=
gredis
.
get
(
sku_uique_judge
,
sn_sku
)
//
查询唯一值,反查
sku_id
sku_id
,
_
:=
redis
.
String
(
redisConn
.
Do
(
"GET"
,
"hcy1"
))
(
sku_uique_judge
,
sn_sku
)
//
查询唯一值,反查
sku_id
var
sku_flag
bool
=
false
;
//
是否新增或者更新
db
+
redis
,
为
true
则新增
if
sku_id
==
""
{
//
为空,先创建
sku
...
...
service/mouser_service.go
View file @
7a36aafb
...
...
@@ -38,12 +38,11 @@ func OutLink(goodsName string,flag string) map[string]*model.LyClearGoodsList {
apiGoodsList
:=
gjson
.
Get
(
result
,
"SearchResults.Parts"
)
.
Array
()
for
_
,
goods
:=
range
apiGoodsList
{
goodsStr
:=
goods
.
String
()
goodsSn
:=
gjson
.
Get
(
goodsStr
,
"MouserPartNumber"
)
.
String
()
//供应商唯一编码
goodsSn
:=
goods
.
Get
(
"MouserPartNumber"
)
.
String
()
ladderPrice
:=
make
([]
*
model
.
TierItem
,
0
)
//拼接价格梯度
apiPriceTi
:=
g
json
.
Get
(
goodsStr
,
"PriceBreaks"
)
.
Array
()
apiPriceTi
:=
g
oods
.
Get
(
"PriceBreaks"
)
.
Array
()
var
apiLowerPrice
float64
=
0
;
//计算最低价格
for
_
,
priceItem
:=
range
apiPriceTi
{
priceItemStr
:=
priceItem
.
String
();
...
...
@@ -63,16 +62,16 @@ func OutLink(goodsName string,flag string) map[string]*model.LyClearGoodsList {
//拼接联营数据
LyClearGoodsList
:=
model
.
LyClearGoodsList
{
GoodsName
:
g
json
.
Get
(
goodsStr
,
"ManufacturerPartNumber"
)
.
String
(),
BrandName
:
g
json
.
Get
(
goodsStr
,
"Manufacturer"
)
.
String
(),
Desc
:
g
json
.
Get
(
goodsStr
,
"Description"
)
.
String
(),
GoodsName
:
g
oods
.
Get
(
"ManufacturerPartNumber"
)
.
String
(),
BrandName
:
g
oods
.
Get
(
"Manufacturer"
)
.
String
(),
Desc
:
g
oods
.
Get
(
"Description"
)
.
String
(),
GoodsSn
:
goodsSn
,
Docurl
:
g
json
.
Get
(
goodsStr
,
"DataSheetUrl"
)
.
String
(),
Url
:
g
json
.
Get
(
goodsStr
,
"ProductDetailUrl"
)
.
String
(),
GoodsImg
:
g
json
.
Get
(
goodsStr
,
"ImagePath"
)
.
String
(),
Cat
:
g
json
.
Get
(
goodsStr
,
"Category"
)
.
String
(),
Increment
:
g
json
.
Get
(
goodsStr
,
"Mult"
)
.
Uint
(),
RestrictionMessage
:
g
json
.
Get
(
goodsStr
,
"RestrictionMessage"
)
.
String
(),
Docurl
:
g
oods
.
Get
(
"DataSheetUrl"
)
.
String
(),
Url
:
g
oods
.
Get
(
"ProductDetailUrl"
)
.
String
(),
GoodsImg
:
g
oods
.
Get
(
"ImagePath"
)
.
String
(),
Cat
:
g
oods
.
Get
(
"Category"
)
.
String
(),
Increment
:
g
oods
.
Get
(
"Mult"
)
.
Uint
(),
RestrictionMessage
:
g
oods
.
Get
(
"RestrictionMessage"
)
.
String
(),
SinglePrice
:
apiLowerPrice
,
Tiered
:
ladderPrice
,
}
...
...
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