Commit 9d46f31c by huangchengyi

1.0

parent 1fa6d352
Showing with 725 additions and 1071 deletions
......@@ -5,7 +5,6 @@ import (
"github.com/gin-gonic/gin"
"github.com/micro/go-micro/v2/web"
"search_server/boot"
//_ "search_server/controller"
"search_server/pkg/config"
"search_server/routes"
)
......
2020-10-15 11:23:24.344 INFO (ziyin_service.go:service.searchZiYingGoods:336) es搜索查詢條件 {"_source":{"includes":["goods_id","goods_name","sample_max_number","sample_status","sample_class_id"]},"aggregations":{"brand_id":{"terms":{"field":"brand_id","size":1000}},"class_id2":{"terms":{"field":"class_id2","size":1000}},"encap":{"terms":{"field":"encap","size":1000}},"packing":{"terms":{"field":"packing","size":1000}}},"from":0,"query":{"bool":{"must":[{"terms":{"class_id2":[1]}},{"range":{"dc_time":{"from":1578363419,"include_lower":true,"include_upper":true,"to":1578363420}}},{"term":{"goods_status":1}}]}},"size":10,"sort":[{"sort":{"order":"desc"}}]}
2020-10-15 11:23:24.532 INFO (ziyin_service.go:service.searchZiYingGoods:342) 查詢結果:{"took":169,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]},"aggregations":{"class_id2":{"doc_count_error_upper_bound":0,"sum_other_doc_count":0,"buckets":[]},"encap":{"doc_count_error_upper_bound":0,"sum_other_doc_count":0,"buckets":[]},"packing":{"doc_count_error_upper_bound":0,"sum_other_doc_count":0,"buckets":[]},"brand_id":{"doc_count_error_upper_bound":0,"sum_other_doc_count":0,"buckets":[]}}}
2020-10-15 11:23:28.008 INFO (ziyin_service.go:service.searchZiYingGoods:336) es搜索查詢條件 {"_source":{"includes":["goods_id","goods_name","sample_max_number","sample_status","sample_class_id"]},"aggregations":{"brand_id":{"terms":{"field":"brand_id","size":1000}},"class_id2":{"terms":{"field":"class_id2","size":1000}},"encap":{"terms":{"field":"encap","size":1000}},"packing":{"terms":{"field":"packing","size":1000}}},"from":0,"query":{"bool":{"must":[{"range":{"dc_time":{"from":1578363419,"include_lower":true,"include_upper":true,"to":1578363420}}},{"terms":{"class_id2":[1]}},{"term":{"goods_status":1}}]}},"size":10,"sort":[{"sort":{"order":"desc"}}]}
2020-10-15 11:23:28.071 INFO (ziyin_service.go:service.searchZiYingGoods:342) 查詢結果:{"took":34,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]},"aggregations":{"class_id2":{"doc_count_error_upper_bound":0,"sum_other_doc_count":0,"buckets":[]},"encap":{"doc_count_error_upper_bound":0,"sum_other_doc_count":0,"buckets":[]},"packing":{"doc_count_error_upper_bound":0,"sum_other_doc_count":0,"buckets":[]},"brand_id":{"doc_count_error_upper_bound":0,"sum_other_doc_count":0,"buckets":[]}}}
2020-10-15 11:23:28.78 INFO (ziyin_service.go:service.searchZiYingGoods:336) es搜索查詢條件 {"_source":{"includes":["goods_id","goods_name","sample_max_number","sample_status","sample_class_id"]},"aggregations":{"brand_id":{"terms":{"field":"brand_id","size":1000}},"class_id2":{"terms":{"field":"class_id2","size":1000}},"encap":{"terms":{"field":"encap","size":1000}},"packing":{"terms":{"field":"packing","size":1000}}},"from":0,"query":{"bool":{"must":[{"range":{"dc_time":{"from":1578363419,"include_lower":true,"include_upper":true,"to":1578363420}}},{"terms":{"class_id2":[1]}},{"term":{"goods_status":1}}]}},"size":10,"sort":[{"sort":{"order":"desc"}}]}
2020-10-15 11:23:28.786 INFO (ziyin_service.go:service.searchZiYingGoods:342) 查詢結果:{"took":4,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]},"aggregations":{"class_id2":{"doc_count_error_upper_bound":0,"sum_other_doc_count":0,"buckets":[]},"encap":{"doc_count_error_upper_bound":0,"sum_other_doc_count":0,"buckets":[]},"packing":{"doc_count_error_upper_bound":0,"sum_other_doc_count":0,"buckets":[]},"brand_id":{"doc_count_error_upper_bound":0,"sum_other_doc_count":0,"buckets":[]}}}
[web]
port = 9000
mode = debug
cors_domain = http://bom.liexin.com
domain = liexin.com
[message]
api_domain = http://api.ichunt.com/msg/sendMessageByAuto
api_md5_str = fh6y5t4rr351d2c3bryi
[goods]
api_url = http://192.168.2.232:60004
sz_api_url = http://192.168.2.232:60004
[es]
url = http://192.168.2.232:9200
urls = http://192.168.2.232:9200,http://192.168.2.232:9200
index_name = future,rochester,tme,verical,element14,digikey,chip1stop,aipco,arrow,alliedelec,avnet,mouser,zhuanmai,peigenesis,powell,rs,buerklin,liexin_ziying
search_supplier = future,rochester,tme,verical,element14,digikey,chip1stop,aipco,arrow,alliedelec,avnet,mouser,peigenesis,powell,rs,buerklin,zhuanmai
hk_delivery_type_supplier = future,rochester,tme,verical,element14,digikey,chip1stop,aipco,arrow,alliedelec,avnet,mouser,peigenesis,powell,rs,buerklin
attr_index = goods_map
[redis]
write_host = 192.168.1.235:6379
read_host = 192.168.1.235:6379
write_password = icDb29mLy2s
read_password = icDb29mLy2s
max_idle = 10
max_active = 10
idle_timeout = 20
[mongo]
host = 192.168.1.237:27017
username = "ichunt"
password = "huntmon6699"
database = ichunt
maxPoolSize=100
[ZIYING_CACHE]
is_no_ziying_cache=true
#是否是测试环境
[IS_SZ]
is_sz = true
#自营mongodb缓存表 正式线ziying_class_aggs
[AGG_TABLE]
agg_table = ziying_class_aggs
#自营mongodb缓存表 正式线 ziying_first_lists
[FIRSTLISTS_TABLE]
firstLists_table = ziying_first_lists
\ No newline at end of file
[web]
port = 9000
mode = debug
cors_domain = http://bom.liexin.com
[message]
api_domain = http://api.ichunt.com/msg/sendMessageByAuto
api_md5_str = fh6y5t4rr351d2c3bryi
[goods]
api_url = http://192.168.2.232:60004
sz_api_url = http://192.168.2.232:60004
[DINGDING]
SEARCH_API_MONITOR = 6d0fa85e01a02c39347d011ae973fd21b76c6c7ce582d3ea470c6b65a318848d
[database]
user_name = root
password = root
host = 192.168.2.239
database = test
table_prefix =
type = mysql
[mongo]
host = 192.168.1.237:27017
username = "ichunt"
password = "huntmon6699"
database = ichunt
maxPoolSize="100"
[ZIYING_CACHE]
is_no_ziying_cache=true
#是否是测试环境
[IS_SZ]
is_sz = true
#自营mongodb缓存表 正式线ziying_class_aggs
[AGG_TABLE]
agg_table = sz_ziying_class_aggs
#自营mongodb缓存表 正式线 ziying_first_lists
[FIRSTLISTS_TABLE]
firstLists_table = sz_ziying_first_lists
\ No newline at end of file
[gorm]
mode = debug
[spu]
user_name = spu
password = spu
host = 192.168.1.234
database = liexin_spu
table_prefix =lie_
type = mysql
#线上地址
#SupDbUser:Supssy2@@!!@$#yxy@172.18.137.21:3306/liexin_supp
[supp]
user_name = liexin_ass
password = `liexin_ass#zsyM`
host = 192.168.2.232
database = liexin_ass
table_prefix =lie_
type = mysql
[cms]
user_name = ichuntcms
password = `ichuntcms#zsyM`
host = 192.168.2.232
database = ichuntcms
table_prefix =
type = mysql
[gorm]
mode = debug
[spu]
user_name = spu
password = spu
host = 192.168.1.234
database = liexin_spu
table_prefix =lie_
type = mysql
[supp]
user_name = liexin_ass
password = `liexin_ass#zsyM`
host = 192.168.2.232
database = liexin_ass
table_prefix =lie_
type = mysql
[cms]
user_name = ichuntcms
password = `ichuntcms#zsyM`
host = 192.168.2.232
database = ichuntcms
table_prefix =
type = mysql
;存放es配置
[es]
url = http://192.168.2.232:9200
urls = http://192.168.2.232:9200,http://192.168.2.232:9200
index_name = future,rochester,tme,verical,element14,digikey,chip1stop,aipco,arrow,alliedelec,avnet,mouser,zhuanmai,peigenesis,powell,rs,buerklin,liexin_ziying
search_supplier = future,rochester,tme,verical,element14,digikey,chip1stop,aipco,arrow,alliedelec,avnet,mouser,peigenesis,powell,rs,buerklin,zhuanmai
hk_delivery_type_supplier = future,rochester,tme,verical,element14,digikey,chip1stop,aipco,arrow,alliedelec,avnet,mouser,peigenesis,powell,rs,buerklin
attr_index = goods_map
\ No newline at end of file
;存放mongodb连接信息
[mongo]
host = 192.168.1.237:27017
username = "ichunt"
password = "huntmon6699"
database = ichunt
maxPoolSize=100
\ No newline at end of file
[rabmq]
url = amqp://guest:guest@192.168.2.232:5672/
;存放本系统所有的队列名称
[rabmq_all]
; bom任务id
MQ_BOM_ITEMS_LIST=bom_items_list
; bom更新数据队列
MQ_BOM_SKU_LIST=bom_sku_list
;联营数据更新-推送入队列-》go后台任务消费(斌哥脚本)
SEARCH_SKU_UPDATE_LIST=search_sku_update_list
;联营数据新增-推送入队列-》go后台任务消费(斌哥脚本)
SEARCH_SKU_LIST=search_sku_list
; bom任务id
ZIYING_MQ_BOM_ITEMS_LIST=ziying_bom_items_list
; bom更新数据队列
;存放本系统所有rabmq配置
[rabmq]
url = amqp://guest:guest@192.168.2.232:5672/
;存放本系统所有的队列名称
[rabmq_all]
; bom任务id
MQ_BOM_ITEMS_LIST=bom_items_list
; bom更新数据队列
MQ_BOM_SKU_LIST=bom_sku_list
;联营数据更新-推送入队列-》go后台任务消费(斌哥脚本)
SEARCH_SKU_UPDATE_LIST=search_sku_update_list
;联营数据新增-推送入队列-》go后台任务消费(斌哥脚本)
SEARCH_SKU_LIST=search_sku_list
; bom任务id
ZIYING_MQ_BOM_ITEMS_LIST=ziying_bom_items_list
; bom更新数据队列
ZIYING_MQ_BOM_SKU_LIST=ziying_bom_sku_list
\ No newline at end of file
;存放本系统所有的redis键值对和解析
[redis_all]
;供应商redis的首key
SUPPLIER_REDIS_PRE=SUPPLIER_REDIS_INFO_
;需要展示的供应商列表
SUPPLIER_REDIS_LIST_PRE=SUPPLIER_REDIS_LIST_INFO_
;新增sku时判读sku是否存在
SKU_UNIQUE_JUDGE=sku_unique_judge
;新增sku时判读sku是否存在
SPU_UNIQUE_JUDGE=sku_unique_judge
;品牌信息判断,根据md5后的品牌名称获取id
BRAND_NAME_ALL=brand_name_all
;品牌id,获取品牌名称
BRAND=brand
;供应商品牌信息判断,存在多对一的情况,根据md5后的品牌名称获取标准品牌id
SUPPLIER_BRAND_ALL=supplier_brand_all
;统计调用外联接口的次数的key的前缀 后面接mouser、verical、arrow、master
SEARCH_API_TOTAL_PRE=search_api_total_
;统计调用外联接口失败的次数的key的前缀 后面接mouser、verical、arrow、master
SEARCH_API_ERORR_PRE=search_api_overtime_
;曝光时间记录哈希集合
SEARCH_SHOW_SKU_TIME=search_show_sku_time
;获取关税信息,根据goods_name,brand_name获取
TAX_CUSTOMS_INFO=tax_customs_info
;存放联营外链原始映射
SKU_RAW_MAP=sku_raw_map
[redis_ziyin]
AGG_TABLE=sz_ziying_class_aggs
FIRST_LISTS_TABLE=ziying_first_lists
ZIYING_CLASS_KEY=ziying_class_string
TAX_CUSTOMS_INFO=tax_customs_info
;存放联营所有sku
SKU=sku
;存放联营所有spu
SPU=SPU
;存放digikey 型号映射
SKU_RAW_MAP=sku_raw_map
POOL_ALIKE_GOODS=pool_alike_goods
;redis连接信息
[default_redis_read]
host = 192.168.1.235:6379
password = icDb29mLy2s
max_idle = 500
max_active = 500
idle_timeout = 20
[default_redis_write]
host = 192.168.1.235:6379
password = icDb29mLy2s
max_idle = 500
max_active = 500
idle_timeout = 20
[api_redis]
host = 192.168.1.235:6379
password = icDb29mLy2s
max_idle = 50
max_active = 100
idle_timeout = 20
;存放本系统所有的redis键值对和解析
[redis_all]
;供应商redis的首key
SUPPLIER_REDIS_PRE=SUPPLIER_REDIS_INFO_
;需要展示的供应商列表
SUPPLIER_REDIS_LIST_PRE=SUPPLIER_REDIS_LIST_INFO_
;新增sku时判读sku是否存在
SKU_UNIQUE_JUDGE=sku_unique_judge
;新增sku时判读sku是否存在
SPU_UNIQUE_JUDGE=spu_unique_judge
;品牌信息判断,根据md5后的品牌名称获取id
BRAND_NAME_ALL=brand_name_all
;所有联营sku缓存
SKU=sku
;所有联营spu缓存
SPU=spu
;品牌id,获取品牌名称
BRAND=brand
;供应商品牌信息判断,存在多对一的情况,根据md5后的品牌名称获取标准品牌id
SUPPLIER_BRAND_ALL=supplier_brand_all
;统计调用外联接口的次数的key的前缀 后面接mouser、verical、arrow、master
SEARCH_API_TOTAL_PRE=search_api_total_
;统计调用外联接口失败的次数的key的前缀 后面接mouser、verical、arrow、master
SEARCH_API_ERORR_PRE=search_api_overtime_
;曝光时间记录哈希集合
SEARCH_SHOW_SKU_TIME=search_show_sku_time
;获取关税信息,根据goods_name,brand_name获取
TAX_CUSTOMS_INFO=tax_customs_info
;存放联营外链原始映射
SKU_RAW_MAP=sku_raw_map
;digikey秘钥
digikey_access_token=digikey_access_token
;查属性id获取属性名称 ,表 lie_class_attr eg: hget("class_attr_by_id",101) = "容差"
class_attr_by_id = class_attr_by_id
;查属名称性获取属性id ,对应表 lie_class_attr eg: hget("class_attr_by_val", "容差") = 101
class_attr_by_val=class_attr_by_val
;查 参数值id 获取 参数值,表lie_class_attr_value eg: hget("class_attr_value_by_id",65) = "1.8W"
class_attr_value_by_id=class_attr_value_by_id
;查 参数值 获取 参数id,表lie_class_attr_value eg: hget("class_attr_value_by_val", "1.8W") = 65
class_attr_value_by_val=class_attr_value_by_val
[redis_ziyin]
AGG_TABLE=sz_ziying_class_aggs
FIRST_LISTS_TABLE=ziying_first_lists
ZIYING_CLASS_KEY=ziying_class_string
TAX_CUSTOMS_INFO=tax_customs_info
;存放联营所有sku
SKU=sku
;存放联营所有spu
SPU=SPU
;存放digikey 型号映射
SKU_RAW_MAP=sku_raw_map
POOL_ALIKE_GOODS=pool_alike_goods
[SUPPLIER_ALL]
1 = future
2 = powerandsignal
3 = rochester
4 = tme
5 = verical
6 = element14
7 = digikey
8 = chip1stop
9 = aipco
10 = arrow
11 = bisco
12 = alliedelec
13 = avnet
14 = mouser
#16 = liexin_lianying1
17 = zhuanmai
18 = liexin_ti
19 = peigenesis
20 = powell
21 = rs
1676 = buerklin
[SEARCH_SUPPLIER_MERGE]
17 = zhuanmai
1 = future
3 = rochester
6 = element14
7 = digikey
8 = chip1stop
9 = aipco
12 = alliedelec
13 = avnet
19 = peigenesis
20 = powell
21 = rs
[SEARCH_SUPPLIER]
1 = future
#2 = powerandsignal
3 = rochester
4 = tme
5 = verical
6 = element14
7 = digikey
8 = chip1stop
9 = aipco
10 = arrow
#11 = bisco
12 = alliedelec
13 = avnet
14 = mouser
#15 = company
#16 = liexin_lianying1
17 = zhuanmai
#18 = liexin_ti
19 = peigenesis
20 = powell
21 = rs
#22 = liexin_sell
#100 = ziying
#101 = liexin_jingdiao
1676 = buerklin
#相似物料供应商
[ALIKE_SUPPLIER]
1 = ti
[common]
MOUSER_API = 'http://footstone.liexin.net/webapi/handle_mouser'
[BRAND]
IS_NOT_TI = 0
TI_LY_BRAND_IDS = 23,45069,7754,17484,43215,13421,5220,7636,44534,43556,44543,9429,758,9470,10430,10653,10707,11227,11276,11819,12608,12965,12997,13327,13675,13680,13752
TI_ZY_BRAND_IDS = 23
[supplier]
# 供应商redis的首key
SUPPLIER_REDIS_PRE = SUPPLIER_REDIS_INFO_
[ZIYING_BRAND_REPLACE]
FH = FH(风华)
BL = BL(上海贝岭)
TE = TE(泰科)
FM = FM(富满)
CJ = CJ(长电)
ST = ST(意法)
SK = SK(时科)
ON = ON(安森美)
TM = TM(天微)
TP = TP(拓微)
TI = TI(德州仪器)
MD = MD(明达)
EG = EG(屹晶微)
HF = HF(宏发)
DY = DY(迪一)
MK = MK(米客方德)
国民 = Nationz(国民技术)
中芯 = SMIC(中芯国际)
富士 = Fuji Electric(富士电机)
国星 = Nationstar(国星光电)
贝岭 = BL(上海贝岭)
[ZIYING_CONFIG]
Index = liexin_ziying
[SEARCH_KEYWORD_MAPPING]
`^(.* )?([\d\.]+)(欧|欧姆|R|r)( .*)?$` = ${1}${2}Ω${4}
`^(.* )?([\d\.]+)(U|u|μ)(.?)( .*)?$` = ${1}${2}Μ${4}${5}
`COG` = C0G
`NPO` = NP0
`华科|华新科技|华新科` = 华新
[mathExactGoodsName]
0=M7
1=M1
2=M4
3=M2
4=A7
5=F7
6=X2
7=G4
8=X4
9=m7
10=m1
11=m4
12=m2
13=a7
14=f7
15=x2
16=g4
17=x4
;自营以某些单位进行搜索时,进行特殊处理
[ZIYING_MEASURE]
0=kΩ
1=uf
2=v
3=kg
4=MHz
5=pf
6=pin
7=ppm
8=kw
[OFFICIAL_WEBSITE]
1 = https://www.futureelectronics.cn/search/?text=liexin
2 = http://www.powerandsignal.com/Products/Search?searchBox=liexin
3 = https://www.rocelec.com/search?q=liexin
4 = https://www.tme.eu/zh/katalog/#search=liexin
5 = https://www.verical.com/s/liexin/
6 = https://cn.element14.com/search?st=liexin
7 = https://www.digikey.com/products/en?keywords=liexin
8 = https://www.chip1stop.com/CHN/zh/view/searchResult/SearchResultTop?keyword=liexin
9 = http://www.aipco.com/search.php?pn=liexin
10 = https://www.arrow.com/en/products/search?cat=&q=liexin
11 = https://www.biscoind.com?SEARCHTEXT=liexin
12 = https://www.alliedelec.com/view/search?keyword=liexin
13 = https://www.avnet.com/shop/apac/search/liexin
14 = https://www.mouser.com/Search/Refine?Keyword=liexin
15 =
16 =
18 =
19 = https://www.peigenesis.cn/cn/shop/f/liexin.html
20 = https://www.powell.com/e2wItemQuickSearch.aspx?searchText=liexin
21 = https://uk.rs-online.com/web/c/semiconductors/amplifiers-comparators/op-amps/?searchTerm=liexin
22 =
1672 = https://www.masterelectronics.com/parts.aspx?text=liexin
1673 = https://www.rutronik24.com/search-result/qs:liexin
1675 = https://www.zaikostore.com/zaikostore/stockList?productName_forFind=liexin
1676 = https://www.buerklin.com/en/search?text=liexin
1677 = https://www.microchipdirect.com/product/search/all/liexin
1678 = https://estore.heilindasia.com/search.asp?p=liexin
1680 = http://shop.wpgam.com/WPGAStore/index.php?route=product/search&filter_description=true&filter_name=liexin
[AUTH]
SUPER_AUTH_KEY = fh6y5t4rr351d2c3bryi
SEARCH_TOKEN_EXPIRE_TIME = 30
[UNIT_SUPPLIER_LOG_CODE]
333333 = arrow
444444 = master
555555 = mouser
666666 = verical
777777 = tme
888888 = buerklin
999999 = zhuanmai
[SEARCH_API_LOG]
SEARCH_API_ERROR_PRE = search_api_overtime_
\ No newline at end of file
;存放搜索相关配置
[SUPPLIER_ALL]
1 = future
2 = powerandsignal
3 = rochester
4 = tme
5 = verical
6 = element14
7 = digikey
8 = chip1stop
9 = aipco
10 = arrow
11 = bisco
12 = alliedelec
13 = avnet
14 = mouser
#16 = liexin_lianying1
17 = zhuanmai
18 = liexin_ti
19 = peigenesis
20 = powell
21 = rs
1676 = buerklin
[SEARCH_SUPPLIER_MERGE]
17 = zhuanmai
1 = future
3 = rochester
6 = element14
7 = digikey
8 = chip1stop
9 = aipco
12 = alliedelec
13 = avnet
19 = peigenesis
20 = powell
21 = rs
[SEARCH_SUPPLIER]
1 = future
#2 = powerandsignal
3 = rochester
4 = tme
5 = verical
6 = element14
7 = digikey
8 = chip1stop
9 = aipco
10 = arrow
#11 = bisco
12 = alliedelec
13 = avnet
14 = mouser
#15 = company
#16 = liexin_lianying1
17 = zhuanmai
#18 = liexin_ti
19 = peigenesis
20 = powell
21 = rs
#22 = liexin_sell
#100 = ziying
#101 = liexin_jingdiao
1676 = buerklin
#相似物料供应商
[ALIKE_SUPPLIER]
1 = ti
[common]
MOUSER_API = 'http://footstone.liexin.net/webapi/handle_mouser'
[BRAND]
IS_NOT_TI = 0
TI_LY_BRAND_IDS = 23,45069,7754,17484,43215,13421,5220,7636,44534,43556,44543,9429,758,9470,10430,10653,10707,11227,11276,11819,12608,12965,12997,13327,13675,13680,13752
TI_ZY_BRAND_IDS = 23
[supplier]
# 供应商redis的首key
SUPPLIER_REDIS_PRE = SUPPLIER_REDIS_INFO_
[ZIYING_BRAND_REPLACE]
FH = FH(风华)
BL = BL(上海贝岭)
TE = TE(泰科)
FM = FM(富满)
CJ = CJ(长电)
ST = ST(意法)
SK = SK(时科)
ON = ON(安森美)
TM = TM(天微)
TP = TP(拓微)
TI = TI(德州仪器)
MD = MD(明达)
EG = EG(屹晶微)
HF = HF(宏发)
DY = DY(迪一)
MK = MK(米客方德)
国民 = Nationz(国民技术)
中芯 = SMIC(中芯国际)
富士 = Fuji Electric(富士电机)
国星 = Nationstar(国星光电)
贝岭 = BL(上海贝岭)
[ZIYING_CONFIG]
Index = liexin_ziying
[SEARCH_KEYWORD_MAPPING]
`^(.* )?([\d\.]+)(欧|欧姆|R|r)( .*)?$` = ${1}${2}Ω${4}
`^(.* )?([\d\.]+)(U|u|μ)(.?)( .*)?$` = ${1}${2}Μ${4}${5}
`COG` = C0G
`NPO` = NP0
`华科|华新科技|华新科` = 华新
[mathExactGoodsName]
0=M7
1=M1
2=M4
3=M2
4=A7
5=F7
6=X2
7=G4
8=X4
9=m7
10=m1
11=m4
12=m2
13=a7
14=f7
15=x2
16=g4
17=x4
;自营以某些单位进行搜索时,进行特殊处理
[ZIYING_MEASURE]
0=
1=uf
2=v
3=kg
4=MHz
5=pf
6=pin
7=ppm
8=kw
[OFFICIAL_WEBSITE]
1 = https://www.futureelectronics.cn/search/?text=liexin
2 = http://www.powerandsignal.com/Products/Search?searchBox=liexin
3 = https://www.rocelec.com/search?q=liexin
4 = https://www.tme.eu/zh/katalog/#search=liexin
5 = https://www.verical.com/s/liexin/
6 = https://cn.element14.com/search?st=liexin
7 = https://www.digikey.com/products/en?keywords=liexin
8 = https://www.chip1stop.com/CHN/zh/view/searchResult/SearchResultTop?keyword=liexin
9 = http://www.aipco.com/search.php?pn=liexin
10 = https://www.arrow.com/en/products/search?cat=&q=liexin
11 = https://www.biscoind.com?SEARCHTEXT=liexin
12 = https://www.alliedelec.com/view/search?keyword=liexin
13 = https://www.avnet.com/shop/apac/search/liexin
14 = https://www.mouser.com/Search/Refine?Keyword=liexin
15 =
16 =
18 =
19 = https://www.peigenesis.cn/cn/shop/f/liexin.html
20 = https://www.powell.com/e2wItemQuickSearch.aspx?searchText=liexin
21 = https://uk.rs-online.com/web/c/semiconductors/amplifiers-comparators/op-amps/?searchTerm=liexin
22 =
1672 = https://www.masterelectronics.com/parts.aspx?text=liexin
1673 = https://www.rutronik24.com/search-result/qs:liexin
1675 = https://www.zaikostore.com/zaikostore/stockList?productName_forFind=liexin
1676 = https://www.buerklin.com/en/search?text=liexin
1677 = https://www.microchipdirect.com/product/search/all/liexin
1678 = https://estore.heilindasia.com/search.asp?p=liexin
1680 = http://shop.wpgam.com/WPGAStore/index.php?route=product/search&filter_description=true&filter_name=liexin
[AUTH]
SUPER_AUTH_KEY = fh6y5t4rr351d2c3bryi
SEARCH_TOKEN_EXPIRE_TIME = 30
[UNIT_SUPPLIER_LOG_CODE]
333333 = arrow
444444 = master
555555 = mouser
666666 = verical
777777 = tme
888888 = buerklin
999999 = zhuanmai
[SEARCH_API_LOG]
SEARCH_API_ERROR_PRE = search_api_overtime_
[LY_UPDATE_LIMIT]
;联营是否开启立刻更新:0否 1是
isUpdate = 0
[web]
port = 9000
mode = debug
cors_domain = http://bom.liexin.com
[message]
api_domain = http://api.ichunt.com/msg/sendMessageByAuto
api_md5_str = fh6y5t4rr351d2c3bryi
[goods]
api_url = http://192.168.2.232:60004
[es]
url = http://192.168.2.232:9200
urls = http://192.168.2.232:9200,http://192.168.2.232:9200
index_name = future,rochester,tme,verical,element14,digikey,chip1stop,aipco,arrow,alliedelec,avnet,mouser,zhuanmai,peigenesis,powell,rs,buerklin,liexin_ziying
search_supplier = future,rochester,tme,verical,element14,digikey,chip1stop,aipco,arrow,alliedelec,avnet,mouser,peigenesis,powell,rs,buerklin,zhuanmai
hk_delivery_type_supplier = future,rochester,tme,verical,element14,digikey,chip1stop,aipco,arrow,alliedelec,avnet,mouser,peigenesis,powell,rs,buerklin
attr_index = goods_map
[database]
user_name = root
password = root
host = 192.168.2.239
database = test
table_prefix =
type = mysql
[redis]
write_host = 192.168.1.235:6379
read_host = 192.168.1.235:6379
write_password = icDb29mLy2s
read_password = icDb29mLy2s
max_idle = 10
max_active = 10
idle_timeout = 20
[mongo]
host = 127.0.0.1:27017
database = liexin_config
[brand]
#是否开启排除品牌
IS_NOT_TI = 1
TI_LY_BRAND_IDS = 23,45069,7754,17484,43215,13421,5220,7636,44534,43556,44543,9429,758,9470,10430,10653,10707,11227,11276,11819,12608,12965,12997,13327,13675,13680,13752
ti_zy_brand_id = 23
\ No newline at end of file
[DINGDING]
SEARCH_API_MONITOR = 6d0fa85e01a02c39347d011ae973fd21b76c6c7ce582d3ea470c6b65a318848d
\ No newline at end of file
[default_redis_read]
host = 192.168.1.235:6379
password = icDb29mLy2s
max_idle = 50
max_active = 100
idle_timeout = 20
[default_redis_write]
host = 192.168.1.235:6379
password = icDb29mLy2s
max_idle = 50
max_active = 100
idle_timeout = 20
[api_redis]
host = 192.168.1.235:6379
password = icDb29mLy2s
max_idle = 50
max_active = 100
idle_timeout = 20
\ No newline at end of file
[web]
port = 10001
mode = release
cors_domain = https://bom.ichunt.com
domain = ichunt.com
[message]
api_domain = http://api.ichunt.com/msg/sendMessageByAuto
api_md5_str = fh6y5t4rr351d2c3bryi
[goods]
api_url = http://47.106.60.211:60004
sz_api_url = http://47.106.60.211:60004
[es]
url = http://172.18.137.29:9211
urls = http://172.18.137.29:9211,http://172.18.137.30:9211
index_name = future,rochester,tme,verical,element14,digikey,chip1stop,aipco,arrow,alliedelec,avnet,mouser,zhuanmai,peigenesis,powell,rs,buerklin,liexin_ziying
search_supplier = future,rochester,tme,verical,element14,digikey,chip1stop,aipco,arrow,alliedelec,avnet,mouser,peigenesis,powell,rs,buerklin,zhuanmai
hk_delivery_type_supplier = future,rochester,tme,verical,element14,digikey,chip1stop,aipco,arrow,alliedelec,avnet,mouser,peigenesis,powell,rs,buerklin
attr_index = goods_map
[redis]
write_host = 172.18.137.38:6379
read_host = 172.18.137.39:6379
write_password = icDb29mLy2s
read_password = icDb29mLy2s
max_idle = 10
max_active = 10
idle_timeout = 20
[mongo]
host = 172.18.137.23:27017
username = "ichunt"
password = "huntmon66499"
database = ichunt
maxPoolSize=100
[ZIYING_CACHE]
is_no_ziying_cache=true
#是否是测试环境
[IS_SZ]
is_sz = false
#自营mongodb缓存表 正式线ziying_class_aggs
[AGG_TABLE]
agg_table = ziying_class_aggs
#自营mongodb缓存表 正式线 ziying_first_lists
[FIRSTLISTS_TABLE]
firstLists_table = ziying_first_lists
\ No newline at end of file
[gorm]
mode = debug
#线上地址
#mysql://LxiCSpu:Mysx3Tyzlo00oxlmlly@172.18.137.29:3306
[spu]
user_name = LxiCSpu
password = Mysx3Tyzlo00oxlmlly
host = 172.18.137.29
database = liexin_spu
table_prefix =lie_
type = mysql
#线上地址
#SupDbUser:Supssy2@@!!@$#yxy@172.18.137.21:3306/liexin_supp
[supp]
user_name = SupDbUser
password = `Supssy2@@!!@$#yxy`
host = 172.18.137.21
database = liexin_supp
table_prefix =lie_
type = mysql
#线上地址
#mysql://dtuserread:dAtaL#ym2902m2lLX2y33@172.18.137.22:3306/icdata#utf8
[cms]
user_name = dtuser
password = `dAtaL#ym2902m2lLX2y33`
host = appdb-master.ichunt.db
database = icdata
table_prefix =
type = mysql
[DINGDING]
SEARCH_API_MONITOR = cd1661d0ce733a8ff0b603b532b317aae9de6dbaf39186b0352f272e47a860e8
\ No newline at end of file
[rabmq]
url = amqp://huntweb:xMtMi29zTm@119.23.79.136:5672/
;存放本系统所有的队列名称
[rabmq_all]
; bom任务id
MQ_BOM_ITEMS_LIST=bom_items_list
; bom更新数据队列
MQ_BOM_SKU_LIST=bom_sku_list
;联营数据更新-推送入队列-》go后台任务消费(斌哥脚本)
SEARCH_SKU_UPDATE_LIST=search_sku_update_list
;联营数据新增-推送入队列-》go后台任务消费(斌哥脚本)
SEARCH_SKU_LIST=search_sku_list
; bom任务id
ZIYING_MQ_BOM_ITEMS_LIST=ziying_bom_items_list
; bom更新数据队列
ZIYING_MQ_BOM_SKU_LIST=ziying_bom_sku_list
\ No newline at end of file
[default_redis_read]
host = 172.18.137.39:6379
password = icDb29mLy2s
max_idle = 50
max_active = 100
idle_timeout = 20
[default_redis_write]
host = 172.18.137.38:6379
password = icDb29mLy2s
max_idle = 50
max_active = 100
idle_timeout = 20
[api_redis_read]
host = 172.18.137.38:6379
password = icDb29mLy2s
max_idle = 50
max_active = 100
idle_timeout = 20
[api_redis_write]
host = 172.18.137.39:6379
password = icDb29mLy2s
max_idle = 50
max_active = 100
idle_timeout = 20
;存放本系统所有的redis键值对和解析
[redis_all]
;供应商redis的首key
SUPPLIER_REDIS_PRE=SUPPLIER_REDIS_INFO_
;需要展示的供应商列表
SUPPLIER_REDIS_LIST_PRE=SUPPLIER_REDIS_LIST_INFO_
;新增sku时判读sku是否存在
SKU_UNIQUE_JUDGE=sku_unique_judge
;新增sku时判读sku是否存在
SPU_UNIQUE_JUDGE=sku_unique_judge
;品牌信息判断,根据md5后的品牌名称获取id
BRAND_NAME_ALL=brand_name_all
;品牌id,获取品牌名称
BRAND=brand
;供应商品牌信息判断,存在多对一的情况,根据md5后的品牌名称获取标准品牌id
SUPPLIER_BRAND_ALL=supplier_brand_all
;统计调用外联接口的次数的key的前缀 后面接mouser、verical、arrow、master
SEARCH_API_TOTAL_PRE=search_api_total_
;统计调用外联接口失败的次数的key的前缀 后面接mouser、verical、arrow、master
SEARCH_API_ERORR_PRE=search_api_overtime_
;曝光时间记录哈希集合
SEARCH_SHOW_SKU_TIME=search_show_sku_time
;获取关税信息,根据goods_name,brand_name获取
TAX_CUSTOMS_INFO=tax_customs_info
;存放联营外链原始映射
SKU_RAW_MAP=sku_raw_map
[redis_ziyin]
AGG_TABLE=sz_ziying_class_aggs
FIRST_LISTS_TABLE=ziying_first_lists
ZIYING_CLASS_KEY=ziying_class_string
TAX_CUSTOMS_INFO=tax_customs_info
;存放联营所有sku
SKU=sku
;存放联营所有spu
SPU=SPU
;存放digikey 型号映射
SKU_RAW_MAP=sku_raw_map
POOL_ALIKE_GOODS=pool_alike_goods
[SUPPLIER_ALL]
1 = future
2 = powerandsignal
3 = rochester
4 = tme
5 = verical
6 = element14
7 = digikey
8 = chip1stop
9 = aipco
10 = arrow
11 = bisco
12 = alliedelec
13 = avnet
14 = mouser
15 = company
16 = liexin_lianying1
17 = zhuanmai
18 = liexin_ti
19 = peigenesis
20 = powell
21 = rs
22 = liexin_sell
100 = ziying
101 = liexin_jingdiao
1672 = master
1673 = rutronik
1675 = corestaff
1676 = buerklin
1677 = microchip
1678 = heilind
1680 = wpg
1681 = jameco
1679 = ti
1684 = distrelec
1685 = tlc
1686 = adi
#搜索结果页合并供应商
[SEARCH_SUPPLIER_MERGE]
1 = future
3 = rochester
6 = element14
#7 = digikey
8 = chip1stop
9 = aipco
12 = alliedelec
13 = avnet
19 = peigenesis
20 = powell
21 = rs
1675 = corestaff
1677 = microchip
1678 = heilind
1680 = wpg
1681 = jameco
1679 = ti
1684 = distrelec
1685 = tlc
1686 = adi
#相似物料供应商
[ALIKE_SUPPLIER]
1 = ti
[common]
MOUSER_API = 'http://footstone.liexin.net/webapi/handle_mouser'
[BRAND]
IS_NOT_TI = 0
TI_LY_BRAND_IDS = 23,45069,7754,17484,43215,13421,5220,7636,44534,43556,44543,9429,758,9470,10430,10653,10707,11227,11276,11819,12608,12965,12997,13327,13675,13680,13752
TI_ZY_BRAND_IDS = 23
[supplier]
# 供应商redis的首key
SUPPLIER_REDIS_PRE = SUPPLIER_REDIS_INFO_
[ZIYING_BRAND_REPLACE]
FH = FH(风华)
BL = BL(上海贝岭)
TE = TE(泰科)
FM = FM(富满)
CJ = CJ(长电)
ST = ST(意法)
SK = SK(时科)
ON = ON(安森美)
TM = TM(天微)
TP = TP(拓微)
TI = TI(德州仪器)
MD = MD(明达)
EG = EG(屹晶微)
HF = HF(宏发)
DY = DY(迪一)
MK = MK(米客方德)
国民 = Nationz(国民技术)
中芯 = SMIC(中芯国际)
富士 = Fuji Electric(富士电机)
国星 = Nationstar(国星光电)
贝岭 = BL(上海贝岭)
[ZIYING_CONFIG]
Index = liexin_ziying
[SEARCH_KEYWORD_MAPPING]
`^(.* )?([\d\.]+)(欧|欧姆|R|r)( .*)?$` = ${1}${2}Ω${4}
`^(.* )?([\d\.]+)(U|u|μ)(.?)( .*)?$` = ${1}${2}Μ${4}${5}
`COG` = C0G
`NPO` = NP0
`华科|华新科技|华新科` = 华新
[mathExactGoodsName]
0=M7
1=M1
2=M4
3=M2
4=A7
5=F7
6=X2
7=G4
8=X4
9=m7
10=m1
11=m4
12=m2
13=a7
14=f7
15=x2
16=g4
17=x4
;自营以某些单位进行搜索时,进行特殊处理
[ZIYING_MEASURE]
0=kΩ
1=uf
2=v
3=kg
4=MHz
5=pf
6=pin
7=ppm
8=kw
[OFFICIAL_WEBSITE]
1 = https://www.futureelectronics.cn/search/?text=liexin
2 = http://www.powerandsignal.com/Products/Search?searchBox=liexin
3 = https://www.rocelec.com/search?q=liexin
4 = https://www.tme.eu/zh/katalog/#search=liexin
5 = https://www.verical.com/s/liexin/
6 = https://cn.element14.com/search?st=liexin
7 = https://www.digikey.com/products/en?keywords=liexin
8 = https://www.chip1stop.com/CHN/zh/view/searchResult/SearchResultTop?keyword=liexin
9 = http://www.aipco.com/search.php?pn=liexin
10 = https://www.arrow.com/en/products/search?cat=&q=liexin
11 = https://www.biscoind.com?SEARCHTEXT=liexin
12 = https://www.alliedelec.com/view/search?keyword=liexin
13 = https://www.avnet.com/shop/apac/search/liexin
14 = https://www.mouser.com/Search/Refine?Keyword=liexin
15 =
16 =
18 =
19 = https://www.peigenesis.cn/cn/shop/f/liexin.html
20 = https://www.powell.com/e2wItemQuickSearch.aspx?searchText=liexin
21 = https://uk.rs-online.com/web/c/semiconductors/amplifiers-comparators/op-amps/?searchTerm=liexin
22 =
1672 = https://www.masterelectronics.com/parts.aspx?text=liexin
1673 = https://www.rutronik24.com/search-result/qs:liexin
1675 = https://www.zaikostore.com/zaikostore/stockList?productName_forFind=liexin
1676 = https://www.buerklin.com/en/search?text=liexin
1677 = https://www.microchipdirect.com/product/search/all/liexin
1678 = https://estore.heilindasia.com/search.asp?p=liexin
1680 = http://shop.wpgam.com/WPGAStore/index.php?route=product/search&filter_description=true&filter_name=liexin
[AUTH]
SUPER_AUTH_KEY = fh6y5t4rr351d2c3bryi
SEARCH_TOKEN_EXPIRE_TIME = 30
[UNIT_SUPPLIER_LOG_CODE]
333333 = arrow
444444 = master
555555 = mouser
666666 = verical
777777 = tme
888888 = buerklin
999999 = zhuanmai
[SEARCH_API_LOG]
SEARCH_API_ERROR_PRE = search_api_overtime_
......@@ -24,17 +24,17 @@ func AutoSpu(c *gin.Context) {
}
//获取推荐列表
func Recommend(c *gin.Context) {
func Recommend(ctx *gin.Context) {
req := &common.RecommendRequest{}
err := c.Bind(&req) //使用的是post参数
err := ctx.Bind(&req) //使用的是post参数
if err != nil {
logger.Error("%s", err.Error())
}
if req.Flag == 0 {
common.Output(101, "参数不全", nil)
common.Output(ctx,101, "参数不全", nil)
return
}
data := service.Recommend(req)
common.Output(req.Flag, "", data)
data := service.Recommend(ctx,req)
common.Output(ctx,req.Flag, "", data)
return
}
......@@ -19,9 +19,9 @@ import (
"strings"
)
func GetDataIndex(c *gin.Context) {
func GetDataIndex(ctx *gin.Context) {
var r requests.GetDataIndexRequest
_ = c.ShouldBind(&r)
_ = ctx.ShouldBind(&r)
if r.Keyword != "" {
word, _ := php2go.URLDecode(r.Keyword)
r.Keyword = strings.ToUpper(word)
......@@ -33,13 +33,13 @@ func GetDataIndex(c *gin.Context) {
supplierList := config.GetSectionValues("SEARCH_SUPPLIER_MERGE")
supplierName := config.Get("SUPPLIER_ALL." + r.SupplierId).String()
if supplierName == "" && r.IsSort != 2 {
c.JSON(200, common.ErrorResponse(1, "供应商id有误"))
ctx.JSON(200, common.ErrorResponse(1, "供应商id有误"))
return
}
common.PrintDebugHeader()
common.PrintDebugHtml(r.SupplierId)
common.PrintDebugHtml(r.Keyword)
common.PrintDebugHeader(ctx)
common.PrintDebugHtml(ctx,r.SupplierId)
common.PrintDebugHtml(ctx,r.Keyword)
if r.SupplierId != "" && r.IsSort == 2 {
//所有供应商列表
......@@ -54,7 +54,7 @@ func GetDataIndex(c *gin.Context) {
}
if res {
//增加联营外链请求
outLinkDiv(&r.SupplierId,&supplierName,&r.Keyword)
outLinkDiv(ctx,&r.SupplierId,&supplierName,&r.Keyword)
//增加
_, err := redis.Bool(redisCon.Do("INCR", config.Get("redis_all.SEARCH_API_TOTAL_PRE").String()+r.SupplierName))
if err != nil {
......@@ -63,8 +63,8 @@ func GetDataIndex(c *gin.Context) {
}
r.FirstSearchPage = 2
quoteService := service.QuoteService{}
result, _ := quoteService.GetGoodsBySupplier(r.GetGoodsBySupplierRequest)
common.Output(1, "", result)
result, _ := quoteService.GetGoodsBySupplier(ctx,r.GetGoodsBySupplierRequest)
common.Output(ctx,1, "", result)
return
}
}
......@@ -76,12 +76,12 @@ func GetDataIndex(c *gin.Context) {
return
}
goodsIds := service.GetGoodsIdsByEsMsearch(esResult)
goodsList, err := service.GetGoodsInfo(goodsIds)
dullData, err := transformer.DullDataInfo(r.Keyword, goodsList)
goodsList, err := service.GetGoodsInfo(ctx,goodsIds)
dullData, err := transformer.DullDataInfo(ctx,r.Keyword, goodsList)
result := service.GetReturnSupplierData(dullData)
result["total"] = gjson.Get(esResult, "hits.total").Int()
result["took"] = gjson.Get(esResult, "took").Int()
common.Output(0, "", result)
common.Output(ctx,0, "", result)
return
}
......@@ -91,12 +91,12 @@ func GetDataIndex(c *gin.Context) {
@param supplierName 渠道名称
@param keyword 关键词
*/
func outLinkDiv(supplierId *string,supplierName *string,keyWord * string){
func outLinkDiv(ctx *gin.Context,supplierId *string,supplierName *string,keyWord * string){
var apiData map[string]*model.LyClearGoodsList = nil
switch *supplierName {
case "mouser": //调外链拿数据mouser外链请求更新修改
apiData = ly.OutLinkMouser(keyWord)
apiData = ly.OutLinkMouser(ctx,keyWord)
break;
}
......@@ -104,7 +104,7 @@ func outLinkDiv(supplierId *string,supplierName *string,keyWord * string){
//供应商详情
supplierId,_ := strconv.ParseInt(*supplierId, 10, 64)
lycon := ly.CommonLyService{}
lycon.GetSkuByGoodsSn(apiData,&model.SUPPLIER_REDIS_INFO{
lycon.GetSkuByGoodsSn(ctx,apiData,&model.SUPPLIER_REDIS_INFO{
SupplierId:supplierId,
SupplierNickname: *supplierName,
})
......
......@@ -2,33 +2,32 @@ package controller
import (
"github.com/gin-gonic/gin"
"search_server/middleware"
"search_server/model"
"search_server/pkg/common"
"search_server/service/ly"
)
//搜索型号
func GetDigikeyData(c *gin.Context) {
func GetDigikeyData(ctx *gin.Context) {
goodsName := middleware.REQUEST["k"] //关键词
goodsName := ctx.Request.FormValue("k") //关键词
common.PrintDebugHeader() //debug
common.PrintDebugHeader(ctx) //debug
if goodsName == "" {
common.Output(1001, "查询关键词不得为空", "")
common.Output(ctx,1001, "查询关键词不得为空", "")
return
}
//调外链拿数据
apiData := ly.OutLinkDigikey(&goodsName)
apiData := ly.OutLinkDigikey(ctx,&goodsName)
//供应商详情
lycon := new(ly.CommonLyService)
lycon.GetSkuByGoodsSn(apiData, &model.SUPPLIER_REDIS_INFO{
lycon.GetSkuByGoodsSn(ctx,apiData, &model.SUPPLIER_REDIS_INFO{
SupplierId: 14,
SupplierNickname: "mouser",
})
common.PrintDebugHtml("-----执行结束----") //debug
common.PrintDebugHtml(ctx,"-----执行结束----") //debug
}
\ No newline at end of file
......@@ -2,30 +2,29 @@ package controller
import (
"github.com/gin-gonic/gin"
"search_server/middleware"
"search_server/model"
"search_server/pkg/common"
"search_server/service/ly"
)
//搜索型号
func GetMouserData(c *gin.Context) {
func GetMouserData(ctx *gin.Context) {
goodsName := middleware.REQUEST["goods_name"]
goodsName := ctx.Request.FormValue("goods_name")
common.PrintDebugHeader() //debug
common.PrintDebugHeader(ctx) //debug
if goodsName == "" {
common.Output(1001, "查询关键词不得为空", "")
common.Output(ctx,1001, "查询关键词不得为空", "")
return
}
//调外链拿数据
apiData := ly.OutLinkMouser(&goodsName)
apiData := ly.OutLinkMouser(ctx,&goodsName)
//供应商详情
lycon := new(ly.CommonLyService)
err := lycon.GetSkuByGoodsSn(apiData,&model.SUPPLIER_REDIS_INFO{
err := lycon.GetSkuByGoodsSn(ctx,apiData,&model.SUPPLIER_REDIS_INFO{
SupplierId:14,
SupplierNickname: "mouser",
})
......@@ -34,6 +33,6 @@ func GetMouserData(c *gin.Context) {
errCode = 1
}
common.PrintDebugHtml("-----执行结束----") //debug
common.Output(errCode, "查询成功", "")
common.PrintDebugHtml(ctx,"-----执行结束----") //debug
common.Output(ctx,errCode, "查询成功", "")
}
......@@ -2,33 +2,32 @@ package controller
import (
"github.com/gin-gonic/gin"
"search_server/middleware"
"search_server/model"
"search_server/pkg/common"
"search_server/service/ly"
)
//搜索型号
func GetTmeData(c *gin.Context) {
func GetTmeData(ctx *gin.Context) {
goodsName := middleware.REQUEST["k"] //关键词
goodsName := ctx.Request.FormValue("k") //关键词
common.PrintDebugHeader() //debug
common.PrintDebugHeader(ctx) //debug
if goodsName == "" {
common.Output(1001, "查询关键词不得为空", "")
common.Output(ctx,1001, "查询关键词不得为空", "")
return
}
//调外链拿数据
apiData := ly.OutLinkTme(&goodsName)
apiData := ly.OutLinkTme(ctx,&goodsName)
//供应商详情
lycon := new(ly.CommonLyService)
lycon.GetSkuByGoodsSn(apiData, &model.SUPPLIER_REDIS_INFO{
lycon.GetSkuByGoodsSn(ctx,apiData, &model.SUPPLIER_REDIS_INFO{
SupplierId: 4,
SupplierNickname: "tme",
})
common.PrintDebugHtml("-----执行结束----") //debug
common.PrintDebugHtml(ctx,"-----执行结束----") //debug
}
\ No newline at end of file
......@@ -7,23 +7,23 @@ import (
)
//参数分类统计
func OptimumAttr(c *gin.Context) {
common.PrintDebugHeader() //debug
func OptimumAttr(ctx *gin.Context) {
common.PrintDebugHeader(ctx) //debug
optimumservice := service.OptimumService{}
apiData := optimumservice.GetOptimumAttr()
apiData := optimumservice.GetOptimumAttr(ctx)
common.Output(apiData.ErrorCode, apiData.ErrorMsg, apiData.Data)
common.PrintDebugHtml("-----执行结束----") //debug
common.Output(ctx,apiData.ErrorCode, apiData.ErrorMsg, apiData.Data)
common.PrintDebugHtml(ctx,"-----执行结束----") //debug
}
//参数+分类 商品详情
func OptimumGoods(c *gin.Context) {
common.PrintDebugHeader() //debug
func OptimumGoods(ctx *gin.Context) {
common.PrintDebugHeader(ctx) //debug
optimumservice := service.OptimumService{}
apiData := optimumservice.GetOptimumAttrInfo()
apiData := optimumservice.GetOptimumAttrInfo(ctx)
common.Output(apiData.ErrorCode, apiData.ErrorMsg, apiData.Data)
common.PrintDebugHtml("-----执行结束----") //debug
common.Output(ctx,apiData.ErrorCode, apiData.ErrorMsg, apiData.Data)
common.PrintDebugHtml(ctx,"-----执行结束----") //debug
}
\ No newline at end of file
......@@ -10,19 +10,19 @@ import (
)
//查询联营型号是否有库存
func CheckHasStock(c *gin.Context) {
noRule, _ := c.GetPostForm("no_rule")
func CheckHasStock(ctx *gin.Context) {
noRule, _ := ctx.GetPostForm("no_rule")
if noRule != "1122" {
flag := common.CheckSignApi()
flag := common.CheckSignApi(ctx)
if flag > 0 {
common.Output(flag, "验证不通过:", nil)
common.Output(ctx,flag, "验证不通过:", nil)
return
}
}
goodsName, _ := c.GetPostForm("goods_name")
goodsName, _ := ctx.GetPostForm("goods_name")
if goodsName == "" {
common.Output(1001, "型号不存在", nil)
common.Output(ctx,1001, "型号不存在", nil)
return
}
replace, _ := regexp.Compile("[^A-Za-z0-9]+")
......@@ -31,10 +31,10 @@ func CheckHasStock(c *gin.Context) {
otherService := service.OtherService{}
hasStock, err := otherService.CheckHasStock(goodsName)
if err != nil {
common.Output(1, "查询失败,系统报错"+err.Error(), nil)
common.Output(ctx,1, "查询失败,系统报错"+err.Error(), nil)
return
}
common.Output(0, "查询成功:"+goodsName, hasStock)
common.Output(ctx,0, "查询成功:"+goodsName, hasStock)
return
}
......@@ -43,10 +43,10 @@ func ExactGoods(c *gin.Context) {
var r requests.ExactGoodsRequest
c.ShouldBind(&r)
if r.GoodsName == "" {
common.Output(1, "查询型号名称不得为空", nil)
common.Output(c,1, "查询型号名称不得为空", nil)
return
}
//查询条件
otherService := service.OtherService{}
otherService.ExactGoods(r.SupplierId, r.GoodsName)
otherService.ExactGoods(c,r.SupplierId, r.GoodsName)
}
......@@ -18,28 +18,28 @@ import (
//搜索快手搜搜
//check_button=2&pf=1&keyword=123213&supplier_id=7&offset=2&follow_hit=1&p=1&_=1593582814402
func QuoteIndex(c *gin.Context) {
func QuoteIndex(ctx *gin.Context) {
var r requests.QuoteIndexRequest
//绑定参数到结构体
if err := c.ShouldBind(&r); err != nil {
if err := ctx.ShouldBind(&r); err != nil {
logger.Error("%s", err)
}
quoteService := service.QuoteService{}
//检查参数,有错误就返回错误
errCode, errMsg := requests.CheckQuoteRequest(r)
if errCode != 0 {
common.Output(errCode, errMsg, nil)
common.Output(ctx,errCode, errMsg, nil)
return
}
flag := 1
var res map[string]interface{}
if r.FollowHit != 0 && r.FollowHit != 1 {
res, _ = quoteService.GetGoodsBySupplier(r.GetGoodsBySupplierRequest)
res, _ = quoteService.GetGoodsBySupplier(ctx,r.GetGoodsBySupplierRequest)
if res != nil {
flag = 0
common.Output(flag, "", res)
common.Output(ctx,flag, "", res)
} else {
common.Output(flag, "", nil)
common.Output(ctx,flag, "", nil)
}
return
}
......@@ -47,25 +47,25 @@ func QuoteIndex(c *gin.Context) {
supplierNameMap := config.Cfg.Section("SUPPLIER_ALL").KeysHash()
supplierName, exist := supplierNameMap[r.SupplierId]
if !exist {
common.Output(1, "供应商有误", nil)
common.Output(ctx,1, "供应商有误", nil)
return
}
if supplierName == "mouser" {
//mouser同步请求搜索
res, _ = mouserOrg(r.Keyword, r.SupplierId)
res, _ = mouserOrg(ctx,r.Keyword, r.SupplierId)
} else {
r.GetGoodsBySupplierRequest.SupplierName = supplierName
res, _ = quoteService.GetGoodsBySupplierName(r.GetGoodsBySupplierRequest)
res, _ = quoteService.GetGoodsBySupplierName(ctx,r.GetGoodsBySupplierRequest)
}
if len(res) > 0 {
flag = 0
}
common.Output(flag, "", res)
common.Output(ctx,flag, "", res)
return
}
func mouserOrg(keyword, suppliedId string) (result map[string]interface{}, err error) {
mouserRes := ly.OutLinkMouser(&keyword)
func mouserOrg(ctx *gin.Context,keyword, suppliedId string) (result map[string]interface{}, err error) {
mouserRes := ly.OutLinkMouser(ctx,&keyword)
redisCon := gredis.Conn("search_r")
defer redisCon.Close()
skuMouser := make(map[string]string)
......@@ -81,12 +81,12 @@ func mouserOrg(keyword, suppliedId string) (result map[string]interface{}, err e
goodsIds = append(goodsIds, skuId)
}
}
goodsList, err := service.GetGoodsInfo(goodsIds)
goodsList, err := service.GetGoodsInfo(ctx,goodsIds)
if err != nil {
return
}
dullData, err := transformer.DullDataInfo(keyword, goodsList)
dullData, err := transformer.DullDataInfo(ctx,keyword, goodsList)
result = service.GetReturnSupplierData(dullData)
if err != nil {
return
......
......@@ -12,10 +12,10 @@ import (
)
//提供日志接口给日志系统
func SearchLogIndex(c *gin.Context) {
func SearchLogIndex(ctx *gin.Context) {
request := make(map[string]string, 0)
c.MultipartForm()
for name, value := range c.Request.Form {
ctx.MultipartForm()
for name, value := range ctx.Request.Form {
if value[0] != "" {
request[name] = strings.TrimSpace(value[0])
}
......@@ -24,10 +24,10 @@ func SearchLogIndex(c *gin.Context) {
searchLogService := service.SearchLogService{}
result, err := searchLogService.GetIndexData(request)
if err != nil {
common.ReturnData(1, "获取ES数据失败 : "+err.Error(), nil)
common.ReturnData(ctx,1, "获取ES数据失败 : "+err.Error(), nil)
}
common.ReturnData(0, "", result)
common.ReturnData(ctx,0, "", result)
return
}
......@@ -35,7 +35,7 @@ func Scroll(c *gin.Context) {
var r requests.ScrollRequest
c.ShouldBind(&r)
if r.ScrollId == 0 {
common.ReturnData(1, "", nil)
common.ReturnData(c,1, "", nil)
}
params := make(map[string]interface{})
if r.Scroll > 0 {
......@@ -47,16 +47,16 @@ func Scroll(c *gin.Context) {
paramsStr, _ := json.Marshal(params)
_, err := es.ScrollES(string(paramsStr))
if err != nil {
common.ReturnData(1, "Scroll失败 : "+err.Error(), nil)
common.ReturnData(c,1, "Scroll失败 : "+err.Error(), nil)
}
}
//根据搜索日志统计出时间短访问最多的ip'
func SumIp(c *gin.Context) {
//统计品牌下的商品数量
flag := common.CheckSignApi()
flag := common.CheckSignApi(c)
if flag > 0 {
common.ReturnData(flag, "", nil)
common.ReturnData(c,flag, "", nil)
return
}
var r requests.SumIpRequest
......@@ -64,9 +64,9 @@ func SumIp(c *gin.Context) {
searchLogService := service.SearchLogService{}
res, err := searchLogService.GetSumIp(r)
if err != nil {
common.ReturnData(1, err.Error(), nil)
common.ReturnData(c,1, err.Error(), nil)
return
}
common.ReturnData(0, "", res)
common.ReturnData(c,0, "", res)
return
}
......@@ -11,20 +11,20 @@ import (
)
//封禁ip开关
func SetButton(c *gin.Context) {
func SetButton(ctx *gin.Context) {
var r requests.SetButtonRequest
c.ShouldBind(&r)
ctx.ShouldBind(&r)
redisCon := gredis.Conn("search_w")
res, err := redis.Bool(redisCon.Do("SET", "spider_config_button", r.Val))
if err != nil {
common.Output(1, "操作redis失败", err.Error())
common.Output(ctx,1, "操作redis失败", err.Error())
return
}
if res {
common.Output(0, "成功", res)
common.Output(ctx,0, "成功", res)
return
} else {
common.Output(1, "设置开关失败", res)
common.Output(ctx,1, "设置开关失败", res)
return
}
}
......@@ -35,7 +35,7 @@ func GetWbList(c *gin.Context) {
c.ShouldBind(&r)
redisCon := gredis.Conn("search_w")
if r.ListType == 0 {
common.Output(1, "参数为空", nil)
common.Output(c,1, "参数为空", nil)
return
}
keyName := "spider_black_list"
......@@ -45,13 +45,13 @@ func GetWbList(c *gin.Context) {
res, err := redis.Strings(redisCon.Do("SMEMBERS", keyName))
if err != nil {
common.Output(1, "操作redis失败", err.Error())
common.Output(c,1, "操作redis失败", err.Error())
return
}
list := make(map[string]interface{})
list["list"] = res
list["total"] = len(res)
common.Output(0, "成功", list)
common.Output(c,0, "成功", list)
return
}
......@@ -60,7 +60,7 @@ func SetWbList(c *gin.Context) {
var r requests.SetWbListRequest
c.ShouldBind(&r)
if r.Type == "" || r.IpList == "" || r.AddOrRm == "" {
common.Output(1, "参数为空", nil)
common.Output(c,1, "参数为空", nil)
}
redisCon := gredis.Conn("search_w")
keyName := "spider_black_list"
......@@ -78,11 +78,11 @@ func SetWbList(c *gin.Context) {
}
}
common.Output(0, "成功!", nil)
common.Output(c,0, "成功!", nil)
}
//获取自我解禁ip访问频率自增数据
func GetIpalg() {
func GetIpalg(c *gin.Context) {
redisCon := gredis.Conn("search_r")
spiderAlgs, _ := redis.StringMap(redisCon.Do("HGETALL", "spider_connect_count_alg"))
spiderBans, _ := redis.Strings(redisCon.Do("SMEMBERS", "spider_ban"))
......@@ -100,7 +100,7 @@ func GetIpalg() {
list["list"] = dataList
list["total"] = len(dataList)
}
common.Output(0, "成功", list)
common.Output(c,0, "成功", list)
return
}
......@@ -109,7 +109,7 @@ func SetIpalg(c *gin.Context) {
var r requests.SetIpalgRequest
c.ShouldBind(&r)
if r.Ip == "" || r.ListType == 0 {
common.Output(1, "参数为空", nil)
common.Output(c,1, "参数为空", nil)
return
}
......@@ -118,16 +118,16 @@ func SetIpalg(c *gin.Context) {
if r.ListType == 1 {
_, err := redis.Bool(redisCon.Do("HSET", "spider_connect_count_alg", ip, r.Num))
if err != nil {
common.Output(1, "操作redis失败", err.Error())
common.Output(c,1, "操作redis失败", err.Error())
}
} else {
_, err := redis.Bool(redisCon.Do("HDEL", "spider_connect_count_alg", ip))
if err != nil {
common.Output(1, "操作redis失败", err.Error())
common.Output(c,1, "操作redis失败", err.Error())
}
}
common.Output(0, "成功", nil)
common.Output(c,0, "成功", nil)
}
//设置参数配置信息
......
......@@ -29,10 +29,10 @@ func Zyh(ctx *gin.Context){
if err != nil{
zyhResponse.ErrorCode = 1
zyhResponse.ErrorMsg = fmt.Sprintf("%s",err)
common.Output(int(zyhResponse.ErrorCode), zyhResponse.ErrorMsg, zyhResponse.Data)
common.Output(ctx,int(zyhResponse.ErrorCode), zyhResponse.ErrorMsg, zyhResponse.Data)
}
common.Output(int(zyhResponse.ErrorCode), zyhResponse.ErrorMsg, zyhResponse.Data)
common.Output(ctx,int(zyhResponse.ErrorCode), zyhResponse.ErrorMsg, zyhResponse.Data)
}
func Aggs(ctx *gin.Context){
......@@ -53,10 +53,10 @@ func Aggs(ctx *gin.Context){
if err != nil{
zyhResponse.ErrorCode = 1
zyhResponse.ErrorMsg = fmt.Sprintf("%s",err)
common.Output(int(zyhResponse.ErrorCode), zyhResponse.ErrorMsg, zyhResponse.Data)
common.Output(ctx,int(zyhResponse.ErrorCode), zyhResponse.ErrorMsg, zyhResponse.Data)
}
common.Output(int(zyhResponse.ErrorCode), zyhResponse.ErrorMsg, zyhResponse.Data)
common.Output(ctx,int(zyhResponse.ErrorCode), zyhResponse.ErrorMsg, zyhResponse.Data)
}
......@@ -78,7 +78,7 @@ func AggSample(ctx *gin.Context){
zyhResponse = zyServiceImpl.AggSample(ctx,zyhRequest)
common.Output(int(zyhResponse.ErrorCode), zyhResponse.ErrorMsg, zyhResponse.Data)
common.Output(ctx,int(zyhResponse.ErrorCode), zyhResponse.ErrorMsg, zyhResponse.Data)
}
func Index(ctx *gin.Context){
......@@ -94,6 +94,6 @@ func Index(ctx *gin.Context){
zyServiceImpl := service.NewZyServiceImpl()
zyhResponse = zyServiceImpl.Index(ctx,zyhRequest)
common.Output(int(zyhResponse.ErrorCode), zyhResponse.ErrorMsg, zyhResponse.Data)
common.Output(ctx,int(zyhResponse.ErrorCode), zyhResponse.ErrorMsg, zyhResponse.Data)
return
}
\ No newline at end of file
File mode changed
package test
package main
import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/imroc/req"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
"search_server/middleware"
"search_server/model"
"search_server/pkg/common"
"strconv"
......@@ -24,7 +24,7 @@ const tme_token string = "3381c9d5d9663be68eb69ea3ce00af3a2b5789094c7cd488a4"//
const tme_app_secret string = "a1d8647fa38710140628" //账号
//tme请求外链
func OutLinkTme(goodsName *string) map[string]*model.LyClearGoodsList {
func OutLinkTme(ctx *gin.Context,goodsName *string) map[string]*model.LyClearGoodsList {
if *goodsName == "" {
return nil
}
......@@ -33,17 +33,17 @@ func OutLinkTme(goodsName *string) map[string]*model.LyClearGoodsList {
SymbolList string //外链原始数据的goods_sn
);
if middleware.REQUEST["flags"] == "-1" { //原始数据调试
if ctx.Request.FormValue("flags") == "-1" { //原始数据调试
result = `{"Status":"OK","Data":{"ProductList":[{"Symbol":"0402WGF1000TCE","CustomerSymbol":"","OriginalSymbol":"0402WGF1000TCE","Producer":"ROYAL OHM","Description":"Resistor: thick film; SMD; 0402; 100\u03a9; 63mW; \u00b11%; -55\u00f7155\u00b0C","CategoryId":"100578","Category":"0402 SMD resistors","Photo":"\/\/ce8dc832c.cloudimg.io\/fit\/640x480\/n@4760e4647bc7d903de9205a51f321b69cdbed098\/_cdn_\/D9\/C2\/B0\/00\/0\/732317_1.jpg?mark_url=_tme-wrk_%2Ftme_new_render3d.png&mark_pos=center&mark_size=100pp","Thumbnail":"\/\/ce8dc832c.cloudimg.io\/fit\/100x75\/webp@3ec3fbcb8427a46b791b093cd6e191b483328d8a\/_cdn_\/D9\/C2\/B0\/00\/0\/732317_1.jpg","Weight":0.01,"WeightUnit":"g","SuppliedAmount":0,"MinAmount":10000,"Multiples":10000,"ProductStatusList":[],"Unit":"pcs","ProductInformationPage":"\/\/www.tme.eu\/en\/details\/0402wgf1000tce\/0402-smd-resistors\/royal-ohm\/","Guarantee":null,"OfferId":null},{"Symbol":"SMD0402-100R-1%","CustomerSymbol":"","OriginalSymbol":"0402WGF1000TCE","Producer":"ROYAL OHM","Description":"Resistor: thick film; SMD; 0402; 100\u03a9; 63mW; \u00b11%; -55\u00f7155\u00b0C","CategoryId":"100578","Category":"0402 SMD resistors","Photo":"\/\/ce8dc832c.cloudimg.io\/fit\/640x480\/n@4760e4647bc7d903de9205a51f321b69cdbed098\/_cdn_\/D9\/C2\/B0\/00\/0\/732317_1.jpg?mark_url=_tme-wrk_%2Ftme_new_render3d.png&mark_pos=center&mark_size=100pp","Thumbnail":"\/\/ce8dc832c.cloudimg.io\/fit\/100x75\/webp@3ec3fbcb8427a46b791b093cd6e191b483328d8a\/_cdn_\/D9\/C2\/B0\/00\/0\/732317_1.jpg","Weight":0.006,"WeightUnit":"g","SuppliedAmount":0,"MinAmount":100,"Multiples":100,"ProductStatusList":[],"Unit":"pcs","ProductInformationPage":"\/\/www.tme.eu\/en\/details\/smd0402-100r-1%\/0402-smd-resistors\/royal-ohm\/0402wgf1000tce\/","Guarantee":null,"OfferId":null}],"Amount":2,"PageNumber":1,"CategoryList":{"111000":2,"100299":2,"100300":2,"100578":2,"112309":2}}}`;
}else{
params1 := "Country=US&Currency=USD&Language=EN&SearchPlain="+*goodsName+"&Token="+tme_token
param := "POST"+"&"+php2go.Rawurlencode(tme_api_url_product)+"&"+php2go.Rawurlencode(params1)
common.PrintDebugHtml(param)
common.PrintDebugHtml(ctx,param)
sign := common.Sha1(param,tme_app_secret) //生成签名
postParam := params1+"&ApiSignature="+php2go.URLEncode(sign);
common.PrintDebugHtml(postParam)
common.PrintDebugHtml(ctx,postParam)
req.SetTimeout(30 * time.Second)
//resp, err := req.Post(params2,postParam)
......@@ -63,11 +63,11 @@ func OutLinkTme(goodsName *string) map[string]*model.LyClearGoodsList {
}
result = resp.String(); //请求外链拿到结果
}
common.PrintDebugHtml("原始数据:"+result)
common.PrintDebugHtml(ctx,"原始数据:"+result)
productList := make(map[string]*model.LyClearGoodsList,0)
if gjson.Get(result,"Status").String() != "OK" {
common.PrintDebugHtml("请求出错-没有数据")
common.PrintDebugHtml(ctx,"请求出错-没有数据")
return nil
}
apiGoodsList := gjson.Get(result, "Data.ProductList").Array()
......@@ -121,7 +121,7 @@ func OutLinkTme(goodsName *string) map[string]*model.LyClearGoodsList {
fmt.Println(result,SymbolList)
if gjson.Get(result,"Status").String() != "OK" {
common.PrintDebugHtml("请求出错-价格库存")
common.PrintDebugHtml(ctx,"请求出错-价格库存")
return nil
}
......
*
!.gitignore
\ No newline at end of file
package middleware
import (
"github.com/gin-gonic/gin"
"strings"
)
var Context *gin.Context
var REQUEST map[string]string //等同于php 的$_REQUEST,只接收非数组值
var REQUEST_MAP map[string][]string //接收参数的数组,只支持二维
//将gin的上下文放到全局变量
func ContextVars() gin.HandlerFunc {
return func(c *gin.Context) {
//接收所有的变量+值
REQUEST = make(map[string]string)
REQUEST_MAP = make(map[string][]string)
c.MultipartForm()
for requestName, requstValue := range c.Request.Form {
values := make([]string,0);
if len(requstValue) == 1 {
REQUEST[requestName] = strings.TrimSpace(requstValue[0])
REQUEST_MAP[requestName] = append(values,requstValue[0])
}
if len(requstValue) > 1 { //接收多维数组
var i int
for i = 0; i < len(requstValue); i++ {
values = append(values,requstValue[i])
}
REQUEST_MAP[requestName] = values
}
}
//将gin的上下文放到全局变量
Context = c
c.Next()
}
}
......@@ -9,12 +9,14 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
"github.com/gin-gonic/gin"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
"math"
"math/big"
"math/rand"
"reflect"
"regexp"
"search_server/middleware"
"search_server/pkg/config"
"search_server/pkg/vars"
"sort"
......@@ -24,11 +26,28 @@ import (
)
/*
gjson 判断某值是否存在 map
@param json string 分析json字符串
@param arrk string 分析的json键值转成map
@param targetk string 目标ID
*/
func GInArray(json string,arrK string,targetK string) bool{
s := gjson.Get(json,"brand_id").Array()
d := make([]string,0)
for _,a := range s {
c := a.String()
d = append(d,c)
}
return php2go.InArray(targetK,d)
}
/*
sha1加密(tme目前在用)
@param string query 查询字符串
@param string pri_key 加密字符串
@return 返回加密后的字符串
*/
*/
func Sha1(query string, pri_key string) string {
key := []byte(pri_key)
mac := hmac.New(sha1.New, key)
......@@ -40,27 +59,27 @@ func Sha1(query string, pri_key string) string {
/*
输出header
*/
func PrintDebugHeader() {
if middleware.REQUEST["flag"] == "101" {
middleware.Context.Header("Content-Type", "text/html; charset=utf-8")
func PrintDebugHeader(ctx *gin.Context) {
if ctx.Request.FormValue("flag") == "101" {
ctx.Header("Content-Type", "text/html; charset=utf-8")
}
}
/*
格式化数据直接输出浏览器
@parm jsonStr 需要json输出的内容
*/
func PrintDebugHtml(jsonStr interface{}) {
if middleware.REQUEST["flag"] != "101" || jsonStr == "" {
func PrintDebugHtml(ctx *gin.Context,jsonStr interface{}) {
if ctx.Request.FormValue("flag") != "101" || jsonStr == "" {
return
}
if v, p := jsonStr.(string); p {
middleware.Context.String(200,"</br></br>-----------"+v)
ctx.String(200,"</br></br>-----------"+v)
}else{
jsonData,err := json.Marshal(jsonStr)
if err != nil {
fmt.Println("错误:-----",err)
}
middleware.Context.String(200,"</br></br>-----------"+string(jsonData))
ctx.String(200,"</br></br>-----------"+string(jsonData))
}
}
......@@ -208,9 +227,8 @@ func CopyMapString(distmap map[string]string) map[string]string {
}
//反爬虫加密验证
func CheckSignApi() (resNo int) {
func CheckSignApi(ctx *gin.Context) (resNo int) {
params := make(map[string]string)
ctx := middleware.Context
if ctx == nil {
return
}
......@@ -234,7 +252,7 @@ func CheckSignApi() (resNo int) {
}
//如果是内部验证通过,则内部通过
if auth() {
if auth(ctx) {
return 0
}
......@@ -288,8 +306,7 @@ func CheckSignApi() (resNo int) {
}
//内部免验证通过
func auth() bool {
ctx := middleware.Context
func auth(ctx *gin.Context) bool {
if ctx == nil {
return false
}
......@@ -421,4 +438,29 @@ func MyFloat64ToStr(numb float64) string {
func MyInt64ToStr(numb int64) string {
return strconv.FormatInt(numb,10)
}
func MyIntToStr(i int) string {
return strconv.Itoa(i)
}
/*
四舍五入取多少位
@param float64 x 目标分析字符串
@param int wei 取小数多少位
*/
func MyRound(x float64,wei int) float64{
if wei == 0 {
return math.Floor(x + 0.5)
}
weis := map[int]float64{
1:10,
2:100,
3:1000,
4:10000,
5:100000,
6:1000000,
}
weishu := weis[wei]
a := math.Floor(x*weishu + 0.5)/weishu
return a
}
////////////类型转换/////////////////////
\ No newline at end of file
......@@ -2,11 +2,11 @@ package common
import (
"encoding/json"
"github.com/gin-gonic/gin"
"github.com/gomodule/redigo/redis"
"github.com/ichunt2019/logger"
log "github.com/sirupsen/logrus"
"os"
"search_server/middleware"
"search_server/pkg/config"
"search_server/pkg/gredis"
"search_server/pkg/message"
......@@ -27,10 +27,9 @@ type SearchApiLog struct {
Method string `json:"method"`
}
func AnalyzeSearchError(code int, ip, errMsg, file, line, method string) (log SearchApiLog) {
func AnalyzeSearchError(ctx *gin.Context,code int, ip, errMsg, file, line, method string) (log SearchApiLog) {
//获取所有参数
request := make(map[string]string)
ctx := middleware.Context
ctx.MultipartForm()
for name, value := range ctx.Request.Form {
if value[0] != "" {
......
......@@ -2,8 +2,8 @@ package common
import (
"encoding/json"
"github.com/gin-gonic/gin"
"runtime"
"search_server/middleware"
"strconv"
"strings"
)
......@@ -39,7 +39,7 @@ func ErrorResponse(errCode int, errMsg string) Response {
}
//统一输出,里面还要去处理jsonp
func Output(errCode int, errMsg string, data interface{}) {
func Output(ctx *gin.Context,errCode int, errMsg string, data interface{}) {
if data == nil {
data = []string{}
}
......@@ -49,9 +49,8 @@ func Output(errCode int, errMsg string, data interface{}) {
Data: data,
}
if errCode >= 100 {
SearchApiLogger(errCode, errMsg)
SearchApiLogger(ctx,errCode, errMsg)
}
ctx := middleware.Context
if ctx.DefaultQuery("callback", "") != "" {
ctx.JSONP(200, response)
} else {
......@@ -66,7 +65,7 @@ func Output(errCode int, errMsg string, data interface{}) {
}
//简单的返回数据方法
func ReturnData(errCode int, errMsg string, data interface{}) {
func ReturnData(ctx *gin.Context,errCode int, errMsg string, data interface{}) {
if data == nil {
data = []string{}
if errCode == 0 {
......@@ -78,18 +77,16 @@ func ReturnData(errCode int, errMsg string, data interface{}) {
ErrMsg: errMsg,
Data: data,
}
ctx := middleware.Context
ctx.JSON(200, response)
}
//错误的搜索日志记录
func SearchApiLogger(code int, msg string) {
func SearchApiLogger(ctx *gin.Context,code int, msg string) {
pc, file, line, _ := runtime.Caller(2)
f := runtime.FuncForPC(pc)
ctx := middleware.Context
errMsg := "提示信息:" + msg + ",请求url:" + ctx.Request.URL.String()
lineNo := strconv.Itoa(line)
searchLog := AnalyzeSearchError(code, ctx.ClientIP(), errMsg, file, lineNo, f.Name())
searchLog := AnalyzeSearchError(ctx,code, ctx.ClientIP(), errMsg, file, lineNo, f.Name())
searchLogByte, _ := json.Marshal(searchLog)
WriteSearchErrorLog(string(searchLogByte))
}
......@@ -11,8 +11,7 @@ var (
func SetUp(path string) (err error) {
//引入多个文件
Cfg, err = ini.LooseLoad(path+"/config.ini", path+"/search.ini", path+"/redis_key.ini", path+"/rabmq_key.ini", path+"/database.ini",
path+"/redis_config.ini", path+"/message.ini")
Cfg, err = ini.LooseLoad(path+"/config.ini", path+"/database.ini", path+"/elastic.ini", path+"/rabmq.ini", path+"/redis.ini",path+"/search.ini")
return
}
......
......@@ -4,32 +4,30 @@ type RedisDatabase struct {
Password string
Host string
Database string
MaxIdle string
MaxActive string
MaxIdle int
MaxActive int
MaxAIdleTimeoutctive string
Prefix string
}
//多数据库配置
func BuildRedisConfgs() (RedisDatabaseMap map[string]RedisDatabase) {
redis_read_max_idle,_ := Get("default_redis_read.max_idle").Int()
redis_read_max_active,_ := Get("default_redis_read.max_active").Int()
redis_write_max_idle,_ := Get("default_redis_write.max_idle").Int()
redis_write_max_active,_ := Get("default_redis_write.max_active").Int()
return map[string]RedisDatabase{
"search_r": {
Host: Get("default_redis_read.host").String(),
Password: Get("default_redis_read.password").String(),
MaxIdle: Get("default_redis_read.max_idle").String(),
MaxActive: Get("default_redis_read.max_active").String(),
MaxIdle: redis_read_max_idle,
MaxActive: redis_read_max_active,
},
"search_w": {
Host: Get("default_redis_write.host").String(),
Password: Get("default_redis_write.password").String(),
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(),
MaxIdle: redis_write_max_idle,
MaxActive: redis_write_max_active,
},
}
}
......@@ -13,7 +13,11 @@ func InitRouter() *gin.Engine {
r.Use(gin.Logger())
r.Use(gin.Recovery())
r.Use(middleware.Cors())
r.Use(middleware.ContextVars())
//健康监测
r.POST("Health", func(c *gin.Context) {
c.String(200,"ok")
})
//联营参数选择搜索
r.POST("optimum/optimumAttr", controller.OptimumAttr)
......
......@@ -2,6 +2,7 @@ package service
import (
"context"
"github.com/gin-gonic/gin"
"github.com/prometheus/common/log"
"github.com/tidwall/gjson"
"gopkg.in/olivere/elastic.v5"
......@@ -65,7 +66,7 @@ func getTermQuery(goodsName string) (query *elastic.BoolQuery) {
}
//推荐商品搜索
func Recommend(req *common.RecommendRequest) (goodsList []model.ApiGoods) {
func Recommend(ctx *gin.Context,req *common.RecommendRequest) (goodsList []model.ApiGoods) {
var err error
//先去请求参数,看是否是参数,如果是参数的话,需要修改请求的商品名称
var goodsName string
......@@ -102,7 +103,7 @@ func Recommend(req *common.RecommendRequest) (goodsList []model.ApiGoods) {
goodsIdList = append(goodsIdList, goodsId)
}
goodsIdListStr = strings.Join(goodsIdList, ",")
goodsList, err = GetGoodsInfoByApi(goodsIdListStr)
goodsList, err = GetGoodsInfoByApi(ctx,goodsIdListStr)
return goodsList
}
......
package service
import (
"github.com/gin-gonic/gin"
"github.com/gomodule/redigo/redis"
"github.com/imroc/req"
"github.com/tidwall/gjson"
"search_server/middleware"
"search_server/model"
"search_server/pkg/common"
"search_server/pkg/config"
......@@ -14,9 +14,9 @@ import (
)
//获取商品信息,需要传入userId用于判断是否登陆
func GetGoodsInfo(goodsIds []string) (goodsList []model.ApiGoods, err error) {
func GetGoodsInfo(ctx *gin.Context,goodsIds []string) (goodsList []model.ApiGoods, err error) {
var userIdStr string
userIdStr, _ = middleware.Context.Cookie("Yo4teW_uid")
userIdStr, _ = ctx.Cookie("Yo4teW_uid")
userId, _ := strconv.Atoi(userIdStr)
isNewCustomer, isMember := CheckIsNewCustomer(userId)
goodsIdsStr := strings.Join(goodsIds, ",")
......@@ -25,22 +25,22 @@ func GetGoodsInfo(goodsIds []string) (goodsList []model.ApiGoods, err error) {
"power[newCustomer]": isNewCustomer,
"power[member]": isMember,
}
goodsList, _, err = CurlGoodsInfo(goodsIdsStr, params)
goodsList, _, err = CurlGoodsInfo(ctx,goodsIdsStr, params)
return
}
//获取商品信息
func GetGoodsInfoByApi(goodsIdsStr string) (goodsList []model.ApiGoods, err error) {
func GetGoodsInfoByApi(ctx *gin.Context,goodsIdsStr string) (goodsList []model.ApiGoods, err error) {
params := req.Param{
"goods_id": goodsIdsStr,
}
goodsList, _, err = CurlGoodsInfo(goodsIdsStr, params)
goodsList, _, err = CurlGoodsInfo(ctx,goodsIdsStr, params)
return
}
//isMap:是否以字典形式返回值,默认是数组
func CurlGoodsInfo(goodsIdsStr string, params req.Param) (goodsList []model.ApiGoods, goodsListMap map[string]model.ApiGoods, err error) {
func CurlGoodsInfo(ctx *gin.Context,goodsIdsStr string, params req.Param) (goodsList []model.ApiGoods, goodsListMap map[string]model.ApiGoods, err error) {
goodsIdList := strings.Split(goodsIdsStr, ",")
if len(goodsIdList) == 0 {
return
......@@ -54,9 +54,9 @@ func CurlGoodsInfo(goodsIdsStr string, params req.Param) (goodsList []model.ApiG
}
resp, err := req.Post(goodsServerUrl+"/synchronization", params)
common.PrintDebugHtml(goodsServerUrl+"/synchronization") //debug
common.PrintDebugHtml(params) //debug
common.PrintDebugHtml(resp.String()) //debug
common.PrintDebugHtml(ctx,goodsServerUrl+"/synchronization") //debug
common.PrintDebugHtml(ctx,params) //debug
common.PrintDebugHtml(ctx,resp.String()) //debug
if err != nil {
return
......
package ly
import (
"github.com/gin-gonic/gin"
"github.com/imroc/req"
"github.com/tidwall/gjson"
"search_server/middleware"
"search_server/model"
"search_server/pkg/common"
"strconv"
......@@ -18,12 +18,12 @@ const arrow_api_url string = "http://api.arrow.com/itemservice/v3/en/search/toke
/*
单独请求arrow获取数据
*/
func ArrowApi(goodsName *string) string {
func ArrowApi(ctx *gin.Context,goodsName *string) string {
if *goodsName == "" {
return ""
}
var result string;
if middleware.REQUEST["flags"] == "-1" { //原始数据调试
if ctx.Request.FormValue("flags") == "-1" { //原始数据调试
result = `{"itemserviceresult":{"serviceMetaData":[{"version":"3.0.2"}],"transactionArea":[{"response":{"returnCode":"0","returnMsg":"","success":true},"responseSequence":{"transactionTime":"8.395 ms","queryTime":"0 ms","dbTime":"0 ms","totalItems":1,"resources":[],"qq":150}}],"data":[{"resources":[{"type":"search","uri":"https:\/\/www.arrow.com\/en\/products\/search?q=nrc06j240trf"}],"PartList":[{"itemId":1731466,"partNum":"NRC06J240TRF","manufacturer":{"mfrCd":"NIC","mfrName":"NIC Components"},"desc":"Res Thick Film 0603 24 Ohm 5% 0.1W(1\/10W) \u00b1200ppm\/\u00b0C Pad SMD Automotive T\/R","packageType":"","resources":[{"type":"cloud_part_detail","uri":"https:\/\/www.arrow.com\/en\/products\/nrc06j240trf\/nic-components"},{"type":"api_part_detail","uri":"http:\/\/api.arrow.com\/itemservice\/v2\/en\/detail?mfrCd=NIC&partNum=NRC06J240TRF"},{"type":"part_detail","uri":"http:\/\/api.arrow.com\/itemservice\/v2\/en\/detail?pkey=d4reVMqt21-TTjZ2c-CxBfkjR7Jr9jVALOn2A_ewFOo"}],"EnvData":{"compliance":[{"displayLabel":"eurohs","displayValue":"Compliant with Exemption"},{"displayLabel":"cnrohs","displayValue":"Compliant with Exemption"}]},"InvOrg":{"sources":[{"currency":"USD","sourceCd":"VERICAL","displayName":"Verical","sourceParts":[{"packSize":5000,"minimumOrderQuantity":5000,"sourcePartNumber":"","sourcePartId":"20192988","Prices":{"resaleList":[{"displayPrice":"0.0022","price":0.0022,"minQty":22778,"maxQty":99999999}]},"Availability":[{"fohQty":65000,"availabilityCd":"INSTK","availabilityMessage":"In Stock","pipeline":[]}],"customerSpecificPricing":[],"customerSpecificInventory":[],"dateCode":"","resources":[{"type":"detail","uri":"https:\/\/www.verical.com\/pd\/nic-fixed-single---surface-mount-NRC06J240TRF-2087567"},{"type":"add_to_cart","uri":"https:\/\/www.verical.com\/pd\/nic-fixed-single---surface-mount-NRC06J240TRF-2087567"}],"inStock":true,"mfrLeadTime":0,"isNcnr":false,"isNpi":false,"isASA":false,"requestQuantity":0,"productCode":"","iccLevels":[],"cloudMfrCode":"","eccnCode":"EAR99","htsCode":"8533.21.00.30","countryOfOrigin":"TW","locationId":49,"containerType":""},{"packSize":1,"minimumOrderQuantity":16667,"sourcePartNumber":"","sourcePartId":"30238877","Prices":{"resaleList":[{"displayPrice":"0.00050","price":0.0005,"minQty":16667,"maxQty":99999999}]},"Availability":[{"fohQty":18977,"availabilityCd":"INSTK","availabilityMessage":"In Stock","pipeline":[]}],"customerSpecificPricing":[],"customerSpecificInventory":[],"dateCode":"1710","resources":[{"type":"detail","uri":"https:\/\/www.verical.com\/pd\/nic-fixed-single---surface-mount-NRC06J240TRF-2087567"},{"type":"add_to_cart","uri":"https:\/\/www.verical.com\/pd\/nic-fixed-single---surface-mount-NRC06J240TRF-2087567"}],"inStock":true,"mfrLeadTime":0,"isNcnr":false,"isNpi":false,"isASA":false,"requestQuantity":0,"productCode":"","iccLevels":[],"cloudMfrCode":"","eccnCode":"EAR99","htsCode":"8533.21.00.30","countryOfOrigin":"TW","locationId":175,"containerType":""}]},{"currency":"USD","sourceCd":"ACNA","displayName":"Arrow Americas","sourceParts":[{"packSize":5000,"minimumOrderQuantity":5000,"sourcePartNumber":"","sourcePartId":"V36:1790_16243328","Prices":{"resaleList":[{"displayPrice":"0.002","price":0.002,"minQty":5000,"maxQty":999999999}]},"Availability":[{"fohQty":0,"availabilityCd":"NOSTK","availabilityMessage":"No Stock","pipeline":[]}],"customerSpecificPricing":[],"customerSpecificInventory":[],"dateCode":"","resources":[{"type":"detail","uri":"https:\/\/www.arrow.com\/en\/products\/nrc06j240trf\/nic-components"},{"type":"add_to_cart","uri":"https:\/\/www.arrow.com\/en\/products\/nrc06j240trf\/nic-components"}],"inStock":false,"mfrLeadTime":20,"isNcnr":false,"isNpi":false,"isASA":false,"requestQuantity":0,"productCode":"","iccLevels":[],"cloudMfrCode":"","eccnCode":"EAR99","htsCode":"8533.21.00.30","locationId":175,"containerType":""},{"packSize":1,"minimumOrderQuantity":1,"sourcePartNumber":"","sourcePartId":"V72:2272_16243328","Prices":{"resaleList":[{"displayPrice":"0.0046","price":0.0046,"minQty":1,"maxQty":9},{"displayPrice":"0.0025","price":0.0025,"minQty":10,"maxQty":99},{"displayPrice":"0.0012","price":0.0012,"minQty":100,"maxQty":499},{"displayPrice":"0.0011","price":0.0011,"minQty":500,"maxQty":999},{"displayPrice":"0.00070","price":0.0007,"minQty":1000,"maxQty":2999},{"displayPrice":"0.00050","price":0.0005,"minQty":3000,"maxQty":999999999}]},"Availability":[{"fohQty":18977,"availabilityCd":"CSTRP","availabilityMessage":"Cut Strips","pipeline":[]}],"customerSpecificPricing":[],"customerSpecificInventory":[],"dateCode":"1710","resources":[{"type":"detail","uri":"https:\/\/www.arrow.com\/en\/products\/nrc06j240trf\/nic-components"},{"type":"add_to_cart","uri":"https:\/\/www.arrow.com\/en\/products\/nrc06j240trf\/nic-components"}],"inStock":true,"mfrLeadTime":20,"isNcnr":false,"isNpi":false,"isASA":false,"requestQuantity":0,"productCode":"","iccLevels":[],"cloudMfrCode":"","eccnCode":"EAR99","htsCode":"8533.21.00.30","countryOfOrigin":"TW","locationId":175,"containerType":"Cut Strips"}]}]},"hasDatasheet":true}]}]}}`;
}else{
req.SetTimeout(10 * time.Second)
......@@ -34,7 +34,7 @@ func ArrowApi(goodsName *string) string {
}
result = resp.String(); //请求外链拿到结果
}
common.PrintDebugHtml("原始数据:"+result)
common.PrintDebugHtml(ctx,"原始数据:"+result)
return result
}
......@@ -44,14 +44,14 @@ func ArrowApi(goodsName *string) string {
@param string apiResult 请求arrow接口返回的所有数据,关键词查询
@return 返回格式化后的数据
*/
func GetDataArrow(apiResult *string,stype string) map[string]*model.LyClearGoodsList {
func GetDataArrow(ctx *gin.Context,apiResult *string,stype string) map[string]*model.LyClearGoodsList {
if apiResult == nil {
return nil
}
productList := make(map[string]*model.LyClearGoodsList,0)
if gjson.Get(*apiResult,"itemserviceresult.data").String() == "" {
common.PrintDebugHtml("返回数据存在问题"+*apiResult)
common.PrintDebugHtml(ctx,"返回数据存在问题"+*apiResult)
return nil
}
if stype == "1" {
......
package ly
import (
"github.com/gin-gonic/gin"
"github.com/imroc/req"
"github.com/tidwall/gjson"
"search_server/middleware"
"search_server/model"
"search_server/pkg/common"
"strconv"
......@@ -14,13 +14,13 @@ import (
const mouser_api_url string = "https://api.mouser.com/api/v1/search/partnumber?apiKey=0a11fa6f-ddcb-4ddf-9947-e42b2f3b4723"
//mouser请求外链
func OutLinkMouser(goodsName *string) map[string]*model.LyClearGoodsList {
func OutLinkMouser(ctx *gin.Context,goodsName *string) map[string]*model.LyClearGoodsList {
if *goodsName == "" {
return nil
}
var result string;
if middleware.REQUEST["flags"] == "-1" { //原始数据调试
if ctx.Request.FormValue("flags") == "-1" { //原始数据调试
result = `{"Errors":[],"SearchResults":{"NumberOfResult":80,"Parts":[{"Availability":"15242 有庫存","DataSheetUrl":"","Description":"運算放大器 - 運放器 1.2 MHz industry standard dual-channel amplifier with -40C to 85C operation 8-SOIC -40 to 85","FactoryStock":"0","ImagePath":"https://www.mouser.com/images/texasinstruments/images/ITP_TI_SOIC-8_D_t.jpg","Category":"運算放大器 - 運放器","LeadTime":"42 日數","LifecycleStatus":"New Product","Manufacturer":"Texas Instruments","ManufacturerPartNumber":"LM358BIDR","Min":"1","Mult":"1","MouserPartNumber":"595-LM358BIDR","ProductAttributes":[{"AttributeName":"封裝","AttributeValue":"Cut Tape"},{"AttributeName":"封裝","AttributeValue":"MouseReel"},{"AttributeName":"封裝","AttributeValue":"Reel"},{"AttributeName":"標準包裝數量","AttributeValue":"2500"}],"PriceBreaks":[{"Quantity":1,"Price":"$0.44","Currency":"USD"},{"Quantity":10,"Price":"$0.287","Currency":"USD"},{"Quantity":100,"Price":"$0.154","Currency":"USD"}],"AlternatePackagings":null,"ProductDetailUrl":"https://www.mouser.hk/ProductDetail/Texas-Instruments/LM358BIDR?qs=byeeYqUIh0MUqg09TCRNgA%3D%3D","Reeling":true,"ROHSStatus":"RoHS Compliant","SuggestedReplacement":"","MultiSimBlue":0,"ProductCompliance":[{"ComplianceName":"CNHTS","ComplianceValue":"8542339000"},{"ComplianceName":"USHTS","ComplianceValue":"8542330001"},{"ComplianceName":"TARIC","ComplianceValue":"8542330000"},{"ComplianceName":"ECCN","ComplianceValue":"EAR99"}]}]}}`;
}else{
req.SetTimeout(10 * time.Second)
......@@ -31,7 +31,7 @@ func OutLinkMouser(goodsName *string) map[string]*model.LyClearGoodsList {
}
result = resp.String(); //请求外链拿到结果
}
common.PrintDebugHtml("原始数据:"+result)
common.PrintDebugHtml(ctx,"原始数据:"+result)
productList := make(map[string]*model.LyClearGoodsList,0)
......
package ly
import (
"github.com/gin-gonic/gin"
"github.com/imroc/req"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
"search_server/middleware"
"search_server/model"
"search_server/pkg/common"
"strconv"
......@@ -23,7 +23,7 @@ const tme_token string = "3381c9d5d9663be68eb69ea3ce00af3a2b5789094c7cd488a4"//
const tme_app_secret string = "a1d8647fa38710140628" //账号
//tme请求外链
func OutLinkTme(goodsName *string) map[string]*model.LyClearGoodsList {
func OutLinkTme(ctx *gin.Context,goodsName *string) map[string]*model.LyClearGoodsList {
if *goodsName == "" {
return nil
}
......@@ -32,12 +32,12 @@ func OutLinkTme(goodsName *string) map[string]*model.LyClearGoodsList {
SymbolList string //外链原始数据的goods_sn
);
if middleware.REQUEST["flags"] == "-1" { //原始数据调试
if ctx.Request.FormValue("flags") == "-1" { //原始数据调试
result = `{"Status":"OK","Data":{"ProductList":[{"Symbol":"0402WGF1000TCE","CustomerSymbol":"","OriginalSymbol":"0402WGF1000TCE","Producer":"ROYAL OHM","Description":"Resistor: thick film; SMD; 0402; 100\u03a9; 63mW; \u00b11%; -55\u00f7155\u00b0C","CategoryId":"100578","Category":"0402 SMD resistors","Photo":"\/\/ce8dc832c.cloudimg.io\/fit\/640x480\/n@4760e4647bc7d903de9205a51f321b69cdbed098\/_cdn_\/D9\/C2\/B0\/00\/0\/732317_1.jpg?mark_url=_tme-wrk_%2Ftme_new_render3d.png&mark_pos=center&mark_size=100pp","Thumbnail":"\/\/ce8dc832c.cloudimg.io\/fit\/100x75\/webp@3ec3fbcb8427a46b791b093cd6e191b483328d8a\/_cdn_\/D9\/C2\/B0\/00\/0\/732317_1.jpg","Weight":0.01,"WeightUnit":"g","SuppliedAmount":0,"MinAmount":10000,"Multiples":10000,"ProductStatusList":[],"Unit":"pcs","ProductInformationPage":"\/\/www.tme.eu\/en\/details\/0402wgf1000tce\/0402-smd-resistors\/royal-ohm\/","Guarantee":null,"OfferId":null},{"Symbol":"SMD0402-100R-1%","CustomerSymbol":"","OriginalSymbol":"0402WGF1000TCE","Producer":"ROYAL OHM","Description":"Resistor: thick film; SMD; 0402; 100\u03a9; 63mW; \u00b11%; -55\u00f7155\u00b0C","CategoryId":"100578","Category":"0402 SMD resistors","Photo":"\/\/ce8dc832c.cloudimg.io\/fit\/640x480\/n@4760e4647bc7d903de9205a51f321b69cdbed098\/_cdn_\/D9\/C2\/B0\/00\/0\/732317_1.jpg?mark_url=_tme-wrk_%2Ftme_new_render3d.png&mark_pos=center&mark_size=100pp","Thumbnail":"\/\/ce8dc832c.cloudimg.io\/fit\/100x75\/webp@3ec3fbcb8427a46b791b093cd6e191b483328d8a\/_cdn_\/D9\/C2\/B0\/00\/0\/732317_1.jpg","Weight":0.006,"WeightUnit":"g","SuppliedAmount":0,"MinAmount":100,"Multiples":100,"ProductStatusList":[],"Unit":"pcs","ProductInformationPage":"\/\/www.tme.eu\/en\/details\/smd0402-100r-1%\/0402-smd-resistors\/royal-ohm\/0402wgf1000tce\/","Guarantee":null,"OfferId":null}],"Amount":2,"PageNumber":1,"CategoryList":{"111000":2,"100299":2,"100300":2,"100578":2,"112309":2}}}`;
}else{
params1 := "Country=US&Currency=USD&Language=EN&SearchPlain="+*goodsName+"&Token="+tme_token
param := "POST"+"&"+php2go.Rawurlencode(tme_api_url_product)+"&"+php2go.Rawurlencode(params1)
common.PrintDebugHtml(param)
common.PrintDebugHtml(ctx,param)
sign := common.Sha1(param,tme_app_secret) //生成签名
req.SetTimeout(10 * time.Second)
......@@ -57,11 +57,11 @@ func OutLinkTme(goodsName *string) map[string]*model.LyClearGoodsList {
}
result = resp.String(); //请求外链拿到结果
}
common.PrintDebugHtml("原始数据:"+result)
common.PrintDebugHtml(ctx,"原始数据:"+result)
productList := make(map[string]*model.LyClearGoodsList,0)
if gjson.Get(result,"Status").String() != "OK" {
common.PrintDebugHtml("请求出错-没有数据")
common.PrintDebugHtml(ctx,"请求出错-没有数据")
return nil
}
apiGoodsList := gjson.Get(result, "Data.ProductList").Array()
......@@ -104,7 +104,7 @@ func OutLinkTme(goodsName *string) map[string]*model.LyClearGoodsList {
//查询价格库存
params_s2 := "Country=US&Currency=USD&Language=EN"+SymbolList+"&Token="+tme_token
param_s3 := "POST"+"&"+php2go.Rawurlencode(tme_api_url_stock)+"&"+php2go.Rawurlencode(params_s2)
common.PrintDebugHtml(param_s3)
common.PrintDebugHtml(ctx,param_s3)
req.SetTimeout(10 * time.Second)
req.Debug = true
......@@ -118,7 +118,7 @@ func OutLinkTme(goodsName *string) map[string]*model.LyClearGoodsList {
"ApiSignature":common.Sha1(param_s3,tme_app_secret),
}
common.PrintDebugHtml(postParam2)
common.PrintDebugHtml(ctx,postParam2)
resp2, err := req.Post(tme_api_url_stock,req.BodyJSON(postParam2))
if err != nil {
......@@ -127,7 +127,7 @@ func OutLinkTme(goodsName *string) map[string]*model.LyClearGoodsList {
}
result_s2 := resp2.String()
if gjson.Get(result_s2,"Status").String() != "OK" {
common.PrintDebugHtml("请求出错-价格库存:"+result_s2)
common.PrintDebugHtml(ctx,"请求出错-价格库存:"+result_s2)
return nil
}
......
package service
import (
"github.com/gin-gonic/gin"
"github.com/gomodule/redigo/redis"
"github.com/iancoleman/orderedmap"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
"search_server/middleware"
"search_server/model"
"search_server/pkg/common"
"search_server/pkg/config"
"search_server/pkg/es"
"search_server/pkg/gredis"
"search_server/service/query"
"strconv"
"strings"
)
type OptimumService struct {
}
var REQUEST_MAP map[string][]string //接收参数的数组,只支持二维
/*
整理接收数组参数
*/
func (qs *OptimumService) getQueryAttr() (map[string]map[string]string){
func (qs *OptimumService) getQueryAttr(ctx *gin.Context) (map[string]map[string]string){
//接收参数,接收参数搜索
allAttrs := make(map[string]map[string]string,0)
for k,v := range middleware.REQUEST_MAP {
REQUEST_MAP := make(map[string][]string)
ctx.MultipartForm()
for requestName, requstValue := range ctx.Request.Form {
if len(requstValue) > 1 { //接收多维数组
values := make([]string,0);
var i int
for i = 0; i < len(requstValue); i++ {
values = append(values,requstValue[i])
}
REQUEST_MAP[requestName] = values
}
}
for k,v := range REQUEST_MAP {
subAttrs := make(map[string]string,0)
var i int;
for i = 0;i<len(v);i++ {
......@@ -66,10 +81,10 @@ func (qs *OptimumService) getQueryAttr() (map[string]map[string]string){
class_id2=3&attr[brand][]=30485&attr[brand][]=30509&attr[brand][]=37727&attr[1002][]=2001
*/
func (qs *OptimumService) GetOptimumAttr() (results model.LyResponse) {
allAttrs := qs.getQueryAttr()
func (qs *OptimumService) GetOptimumAttr(ctx *gin.Context) (results model.LyResponse) {
allAttrs := qs.getQueryAttr(ctx)
//获取查询条件
queryString, err := query.GetOptimumAttrQuery(allAttrs,1)
queryString, err := query.GetOptimumAttrQuery(ctx,allAttrs,1)
if err != nil {
results.ErrorCode = 1001;
results.ErrorMsg = err.Error()
......@@ -82,7 +97,7 @@ func (qs *OptimumService) GetOptimumAttr() (results model.LyResponse) {
results.ErrorMsg = err.Error()
return
}
common.PrintDebugHtml(esResult)
common.PrintDebugHtml(ctx,esResult)
//判断返回总条数
total := gjson.Get(esResult, "hits.total").Int()
......@@ -139,7 +154,7 @@ func (qs *OptimumService) GetOptimumAttr() (results model.LyResponse) {
attr_value_name := valueMap["key"].String() //属性值:1V
attr_value_id,_ := gredis.String(redisConn.Do("HGET",config.Get("redis_all.class_attr_value_by_val").String(),attr_value_name)) //查询唯一值,反查
ischeck := "0" //是否选中
ischeck := "0" //是否选中redigo
if _, ok := allAttrs[attr_value_id][attr_value_id]; ok {
ischeck = "1"
}
......@@ -158,11 +173,11 @@ func (qs *OptimumService) GetOptimumAttr() (results model.LyResponse) {
/*
返回供应商详情
*/
func (qs *OptimumService) GetOptimumAttrInfo() (results model.LyResponse) {
func (qs *OptimumService) GetOptimumAttrInfo(ctx *gin.Context) (results model.LyResponse) {
//索引字典
allAttrs := qs.getQueryAttr()
allAttrs := qs.getQueryAttr(ctx)
//获取查询条件
queryString, err := query.GetOptimumAttrQuery(allAttrs,2)
queryString, err := query.GetOptimumAttrQuery(ctx,allAttrs,2)
if err != nil {
results.ErrorCode = 1001;
results.ErrorMsg = err.Error()
......@@ -191,14 +206,36 @@ func (qs *OptimumService) GetOptimumAttrInfo() (results model.LyResponse) {
A.Set("took", gjson.Get(esResult, "took").Int()) //查询总条数
//aggs := orderedmap.New() //拼接aggs
common.PrintDebugHtml(goodsIds)
common.PrintDebugHtml(ctx,goodsIds)
//组装商品详情
goodsList, _ := GetGoodsInfo(goodsIds)
//for _,v := range goodsList{
// v.
//}
endArr := make([]model.DullGoodsData,0)
goodsList, _ := GetGoodsInfo(ctx,goodsIds)
for _,v := range goodsList{
GoodsUrl := ""
BrandUrl := ""
referer := ctx.GetHeader("Referer")
if referer != ""{
dome := strings.Split(referer,".com")
if len(dome) > 0{
if v.SupplierName == "猎芯自营" {
GoodsUrl = dome[0]+".com/item/"+v.GoodsId+".html"
BrandUrl = dome[0]+".com/v3/brand/list/"+strconv.Itoa(v.BrandId)+".html"
}else{
GoodsUrl = dome[0]+".com/goods_"+v.GoodsId+".html"
BrandUrl = dome[0]+".com/v3/brand/list/"+strconv.Itoa(v.BrandId)+".html"
}
}
}
endArr = append(endArr,model.DullGoodsData{
ApiGoods:v,
GoodsUrl: GoodsUrl,
BrandUrl: BrandUrl,
})
}
A.Set("goods_lists",goodsList)
A.Set("goods_lists",endArr)
results.Data = A;
return
}
......@@ -2,6 +2,7 @@ package service
import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
"regexp"
......@@ -33,7 +34,7 @@ func (os *OtherService) CheckHasStock(goodsName string) (hasStock int, err error
return
}
func (os *OtherService) ExactGoods(supplierId, goodsName string) {
func (os *OtherService) ExactGoods(ctx *gin.Context,supplierId, goodsName string) {
//获取索引
index := getExactGoodsIndex(supplierId)
r1, _ := regexp.Compile(`/[\x{4e00}-\x{9fff}]+/u`)
......@@ -69,7 +70,7 @@ func (os *OtherService) ExactGoods(supplierId, goodsName string) {
}
result = goodsIds
}
common.Output(0, "", result)
common.Output(ctx,0, "", result)
return
}
......
......@@ -2,8 +2,8 @@ package query
import (
"errors"
"github.com/gin-gonic/gin"
"gopkg.in/olivere/elastic.v5"
"search_server/middleware"
"search_server/pkg/common"
"search_server/pkg/config"
"search_server/pkg/gredis"
......@@ -17,13 +17,13 @@ cat_id=398&attr[brand][]=30485&attr[brand][]=30509&attr[brand][]=37727&attr[bran
@param attrs 前端组装好post参数
@param types int 返回统计还是结果: 1单独返回统计 2单独返回查询结果
*/
func GetOptimumAttrQuery(attrs map[string]map[string]string,types int) (param string, err error){
func GetOptimumAttrQuery(ctx *gin.Context,attrs map[string]map[string]string,types int) (param string, err error){
query := elastic.NewBoolQuery()
query1 := elastic.NewBoolQuery()
query2 := elastic.NewBoolQuery()
//二级分类查询
class_id2 := middleware.REQUEST["class_id2"]
class_id2 := ctx.Request.FormValue("class_id2")
if class_id2 == "" {
return "",errors.New("二级分类不得为空")
}else{
......@@ -59,8 +59,8 @@ func GetOptimumAttrQuery(attrs map[string]map[string]string,types int) (param s
source.Size(0)
}
if types == 2 { //不需要统计,返回分页数据
page := middleware.REQUEST["page"]
page_size := middleware.REQUEST["page_size"]
page := ctx.Request.FormValue("page")
page_size := ctx.Request.FormValue("page_size")
page_from := 1
if page == "" {
page = "1";
......@@ -90,7 +90,7 @@ func GetOptimumAttrQuery(attrs map[string]map[string]string,types int) (param s
searchRequest := elastic.NewSearchRequest().Source(source)
param, _ = searchRequest.Body()
common.PrintDebugHtml(param)
common.PrintDebugHtml(ctx,param)
return
}
/*
......
......@@ -3,6 +3,7 @@ package service
import (
"encoding/json"
"fmt"
"github.com/gin-gonic/gin"
"github.com/imroc/req"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
......@@ -19,7 +20,7 @@ type QuoteService struct {
}
//根据供应商获取商品信息
func (qs *QuoteService) GetGoodsBySupplier(r requests.GetGoodsBySupplierRequest) (result map[string]interface{}, err error) {
func (qs *QuoteService) GetGoodsBySupplier(ctx *gin.Context,r requests.GetGoodsBySupplierRequest) (result map[string]interface{}, err error) {
//索引字典
supplierIndex := query.GetSupplierIndex(r.SupplierId)
//获取查询条件
......@@ -32,8 +33,8 @@ func (qs *QuoteService) GetGoodsBySupplier(r requests.GetGoodsBySupplierRequest)
return
}
goodsIds := GetGoodsIdsByEs(esResult)
goodsList, err := GetGoodsInfo(goodsIds)
dullData, err := transformer.DullDataInfo(r.Keyword, goodsList)
goodsList, err := GetGoodsInfo(ctx,goodsIds)
dullData, err := transformer.DullDataInfo(ctx,r.Keyword, goodsList)
//整合供应商数据
result = GetReturnSupplierData(dullData)
result["total"] = gjson.Get(esResult, "hits.total").Int()
......@@ -44,7 +45,7 @@ func (qs *QuoteService) GetGoodsBySupplier(r requests.GetGoodsBySupplierRequest)
return
}
func (qs *QuoteService) GetGoodsBySupplierName(r requests.GetGoodsBySupplierRequest) (result map[string]interface{}, err error) {
func (qs *QuoteService) GetGoodsBySupplierName(ctx *gin.Context,r requests.GetGoodsBySupplierRequest) (result map[string]interface{}, err error) {
supplierIndex := r.SupplierName
queryString, err := query.GetGoodsBySupplierNameQuery(r)
esResult, err := es.CurlES(supplierIndex, queryString)
......@@ -54,8 +55,8 @@ func (qs *QuoteService) GetGoodsBySupplierName(r requests.GetGoodsBySupplierRequ
fmt.Println(esResult)
goodsIds := GetGoodsIdsByEs(esResult)
fmt.Println(goodsIds)
goodsList, err := GetGoodsInfo(goodsIds)
dullData, err := transformer.DullDataInfo(r.Keyword, goodsList)
goodsList, err := GetGoodsInfo(ctx,goodsIds)
dullData, err := transformer.DullDataInfo(ctx,r.Keyword, goodsList)
quoteTransformer := transformer.QuoteTransformer{}
//还要去转一下阶梯价比例
dullData = quoteTransformer.TransformLadderPrice(dullData)
......
......@@ -2,11 +2,11 @@ package transformer
import (
"encoding/json"
"github.com/gin-gonic/gin"
"github.com/gomodule/redigo/redis"
"github.com/tidwall/gjson"
"regexp"
"search_server/dao"
"search_server/middleware"
"search_server/model"
"search_server/pkg/common"
"search_server/pkg/config"
......@@ -17,7 +17,7 @@ import (
)
//处理商品信息数据
func DullDataInfo(keyword string, goodsList []model.ApiGoods) (result []model.DullGoodsData, err error) {
func DullDataInfo(ctx *gin.Context,keyword string, goodsList []model.ApiGoods) (result []model.DullGoodsData, err error) {
//获取redis链接
redisCon := gredis.Conn("search_r")
defer redisCon.Close()
......@@ -37,11 +37,11 @@ func DullDataInfo(keyword string, goodsList []model.ApiGoods) (result []model.Du
return result, err
}
//在不同的环境组装不同的url
goods = spliceUrlByEnvironment(goods)
goods = spliceUrlByEnvironment(ctx,goods)
//获取汇率相关
goods = getRatio(goods)
//提供给客服报价系统专用
if strings.Contains(middleware.Context.Request.URL.String(), "quote") {
if strings.Contains(ctx.Request.URL.String(), "quote") {
for key, price := range goods.LadderPrice {
if price.PriceUs != 0 {
if goods.SupplierId == 6 {
......@@ -61,10 +61,10 @@ func DullDataInfo(keyword string, goodsList []model.ApiGoods) (result []model.Du
goods.LastSearchTime = common.GetLastSearchTime(goods.GoodsId)
//关税信息
goods.CustomsTax = common.GetCustomsTax(goods.GoodsName, goods.BrandName)
go ShowSku(goods)
go ShowSku(ctx,goods)
//价格等信息混淆
if keyword != "---" {
goods, err = MetGoodsInfo(goods)
goods, err = MetGoodsInfo(ctx,goods)
if err != nil {
return result, err
}
......@@ -77,8 +77,8 @@ func DullDataInfo(keyword string, goodsList []model.ApiGoods) (result []model.Du
}
//在不同的环境组装不同的url
func spliceUrlByEnvironment(goods model.DullGoodsData) model.DullGoodsData {
referer := middleware.Context.Request.Header.Get("referer")
func spliceUrlByEnvironment(ctx *gin.Context,goods model.DullGoodsData) model.DullGoodsData {
referer := ctx.Request.Header.Get("referer")
refererTemp := strings.Split(referer, ".com")
if len(refererTemp) > 0 {
goods.BrandUrl = refererTemp[0] + ".com/v3/brand/list/" + common.ToString(goods.BrandId) + ".html"
......@@ -261,14 +261,14 @@ func arrangeData(goods model.DullGoodsData) model.DullGoodsData {
}
//价格等信息混淆
func MetGoodsInfo(data model.DullGoodsData) (result model.DullGoodsData, err error) {
func MetGoodsInfo(ctx *gin.Context,data model.DullGoodsData) (result model.DullGoodsData, err error) {
type CheckParams struct {
CheckButton int `form:"check_button"`
K1 int `form:"k1"`
K2 int `form:"k2"`
}
var checkParams CheckParams
err = middleware.Context.Bind(&checkParams)
err = ctx.Bind(&checkParams)
if checkParams.CheckButton == 2 || checkParams.K1 != 0 || checkParams.K2 != 0 {
data.StockStr = data.Stock
data.MoqStr = data.Moq
......@@ -297,19 +297,19 @@ func MetGoodsInfo(data model.DullGoodsData) (result model.DullGoodsData, err err
}
//推送搜索商品信息
func ShowSku(goods model.DullGoodsData) {
func ShowSku(ctx *gin.Context,goods model.DullGoodsData) {
//绑定需要接收的参数
type ShowSkuParams struct {
GoodsNameEq string `form:"goods_name/eq"`
Keyword string `form:"keyword"`
}
var params ShowSkuParams
middleware.Context.Bind(&params)
ctx.Bind(&params)
goodsIdLen := len(goods.GoodsId)
if goods.GoodsId == "" || goods.BrandName == "" || goods.SupplierName == "" {
return
}
referer := middleware.Context.Request.Header.Get("referer")
referer := ctx.Request.Header.Get("referer")
if strings.Contains(referer, "www.ichunt.com/s/?k") {
if goods.ProviderName != "" {
goods.BrandName = goods.ProviderName
......@@ -356,7 +356,7 @@ func ShowSku(goods model.DullGoodsData) {
result["moq"] = goods.Moq
result["show_time"] = time.Now().Unix()
//cookie获取
result["adtag"], _ = middleware.Context.Cookie("adtag")
result["adtag"], _ = ctx.Cookie("adtag")
//状态判断
if goodsIdLen < 19 {
result["status"] = 1
......
......@@ -14,7 +14,6 @@ import (
"gopkg.in/olivere/elastic.v5"
"math"
"regexp"
"search_server/middleware"
"search_server/model"
"search_server/pkg/common"
"search_server/pkg/config"
......@@ -61,7 +60,7 @@ func (this *ZyServiceImpl) Zyh(ctx *gin.Context, req map[string]string) (rsp *mo
//设置cookie
setCookie(ctx,req)
rsp = zy(req ,_type,0)
rsp = zy(ctx,req ,_type,0)
return rsp,nil
}
......@@ -72,7 +71,7 @@ func (this *ZyServiceImpl)Aggs(ctx *gin.Context, req map[string]string) (rsp *mo
return rsp,nil
}
rsp = zy(req ,2,1)
rsp = zy(ctx,req ,2,1)
return rsp,nil
}
......@@ -98,7 +97,7 @@ func ajaxReturn(rsp *model.ZyhResponse,err_code int64,err_msg string,data interf
//自营筛选接口数据输出
//@param _type 1:输出所有(属性统计+分类+数据详情),2 只输出属性(属性统计)
func zy(req map[string]string,_type byte,isCheck byte) (rsp *model.ZyhResponse){
func zy(ctx *gin.Context,req map[string]string,_type byte,isCheck byte) (rsp *model.ZyhResponse){
var (
classid int64
err error
......@@ -152,7 +151,7 @@ func zy(req map[string]string,_type byte,isCheck byte) (rsp *model.ZyhResponse){
req2 = common.CopyMapString(req)
zy_orgin_search = common.CopyMapString(req)//原始搜索數據
delete(req2,"class_id/condition")
rsp =searchZiYingGoods(req2,true,zhyClassList,classLight,_type)
rsp =searchZiYingGoods(ctx,req2,true,zhyClassList,classLight,_type)
if _type == 2{
data,ok := rsp.Data.(map[string]interface{})
if ok {
......@@ -171,7 +170,7 @@ func(this *ZyServiceImpl) Index(ctx *gin.Context, req map[string]string) (rsp *m
if ok {
return rsp
}
rsp = searchZiYingGoods(req2,false,nil,nil,1)
rsp = searchZiYingGoods(ctx,req2,false,nil,nil,1)
return rsp
}
......@@ -183,7 +182,7 @@ func(this *ZyServiceImpl) Index(ctx *gin.Context, req map[string]string) (rsp *m
* @param type $class_light 高亮分类
* @param type $type 1:全部输出(属性统计+列表) 2:只输出属性统计 3:只输出列表
*/
func searchZiYingGoods( req map[string]string,zy bool,classList *model.ZhyClassList,classLight []*model.ZhyClassListModel,aType byte) (rsp *model.ZyhResponse){
func searchZiYingGoods(ctx *gin.Context, req map[string]string,zy bool,classList *model.ZhyClassList,classLight []*model.ZhyClassListModel,aType byte) (rsp *model.ZyhResponse){
var (
goods_name_arr []string
keyword string
......@@ -471,7 +470,7 @@ func searchZiYingGoods( req map[string]string,zy bool,classList *model.ZhyClassL
for _,v := range goodsIds{
goodsIdsStrArr = append(goodsIdsStrArr,v.String())
}
goodsList,_ := GetGoodsInfo(goodsIdsStrArr)
goodsList,_ := GetGoodsInfo(ctx,goodsIdsStrArr)
flag = 0
response["total"] = gjson.Get(result,"hits.total").String()
for _ ,esGoodsInfo := range hitsHits{
......@@ -480,7 +479,7 @@ func searchZiYingGoods( req map[string]string,zy bool,classList *model.ZhyClassL
//goods_id := esGoodsInfo.Map()["_id"].Int()
goods_id_str := esGoodsInfo.Map()["_id"].String()
//整理自营数据参数
goodsInfo,ok := dullZiYingGoodsInfo(goods_id_str,keyword,goods_name_arr,goodsList)
goodsInfo,ok := dullZiYingGoodsInfo(ctx,goods_id_str,keyword,goods_name_arr,goodsList)
if !ok {
continue
}
......@@ -513,7 +512,7 @@ func searchZiYingGoods( req map[string]string,zy bool,classList *model.ZhyClassL
}
}
referer := middleware.Context.GetHeader("Referer")
referer := ctx.GetHeader("Referer")
if flag <= 0 && php2go.Stripos(referer,"/s/?k=",0) == -1{
response = getPage(response,length,hitsTotal)
}
......@@ -882,7 +881,7 @@ func makeQuery(query *elastic.BoolQuery,source *elastic.SearchSource,conditions
//整理自营数据参数
func dullZiYingGoodsInfo(goods_id_str string,keyword string,goods_name_arr []string,goods_list []model.ApiGoods) (ziyinGoodsInfo model.ZiyinGoodsInfo, ok bool){
func dullZiYingGoodsInfo(ctx *gin.Context,goods_id_str string,keyword string,goods_name_arr []string,goods_list []model.ApiGoods) (ziyinGoodsInfo model.ZiyinGoodsInfo, ok bool){
isHas := false
for _,goods_info:= range goods_list{
if goods_info.GoodsId == goods_id_str{
......@@ -951,7 +950,7 @@ func dullZiYingGoodsInfo(goods_id_str string,keyword string,goods_name_arr []str
}
referer := middleware.Context.GetHeader("Referer")
referer := ctx.GetHeader("Referer")
if referer != ""{
dome := strings.Split(referer,".com")
if len(dome) > 0{
......@@ -967,7 +966,7 @@ func dullZiYingGoodsInfo(goods_id_str string,keyword string,goods_name_arr []str
ziyinGoodsInfo.LastSearchTime = common.GetLastSearchTime(goods_id_str)
//go transformer.ShowSku(model.DullGoodsData{ApiGoods:ziyinGoodsInfo.ApiGoods})
if keyword != "---"{
dullGoodsData,err:= transformer.MetGoodsInfo(ziyinGoodsInfo.DullGoodsData)
dullGoodsData,err:= transformer.MetGoodsInfo(ctx,ziyinGoodsInfo.DullGoodsData)
if err == nil{
ziyinGoodsInfo.DullGoodsData = dullGoodsData
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment