Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
search_server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e85062c1
authored
Jul 07, 2020
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
添加部分方法
parent
6d1f8af8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
100 additions
and
10 deletions
conf/config_dev.ini
conf/search.ini
dao/supplier_dao.go
model/brand.go
model/goods.go
model/supplier.go
pkg/common/function.go
service/goods_service.go
conf/config_dev.ini
View file @
e85062c1
...
...
@@ -41,6 +41,6 @@ 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
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
conf/search.ini
View file @
e85062c1
...
...
@@ -11,6 +11,11 @@
'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
\ No newline at end of file
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_
dao/supplier_dao.go
0 → 100644
View file @
e85062c1
package
dao
model/brand.go
View file @
e85062c1
...
...
@@ -7,20 +7,20 @@ import (
//获取需要排除的品牌id
//branType = 1 : 联营 2 : 自营
func
GetExcludeBrandIds
(
brandType
int
)
(
excludeBrandIds
[]
int
)
{
isNoTi
:=
config
.
Get
(
"brand.
is_not_ti
"
)
.
String
()
isNoTi
:=
config
.
Get
(
"brand.
IS_NOT_TI
"
)
.
String
()
//如果关闭,直接返回空数据
if
isNoTi
==
"1"
{
return
}
//返回联营的brand_id切片
if
brandType
==
1
{
tiLyBrandIds
:=
config
.
Get
(
"brand.
ti_ly_brand_ids
"
)
.
Ints
(
","
)
tiLyBrandIds
:=
config
.
Get
(
"brand.
TI_LY_BRAND_IDS
"
)
.
Ints
(
","
)
excludeBrandIds
=
tiLyBrandIds
//获取的是字符串
return
}
//返回自营的ti的brand_id切片
tiZyBrandId
:=
config
.
Get
(
"brand.
ti_zy_brand_ids
"
)
.
Ints
(
","
)
tiZyBrandId
:=
config
.
Get
(
"brand.
TI_ZY_BRAND_IDS
"
)
.
Ints
(
","
)
excludeBrandIds
=
tiZyBrandId
return
...
...
model/goods.go
View file @
e85062c1
...
...
@@ -55,11 +55,16 @@ type ApiGoods struct {
ClassId3
int
`json:"class_id3,omitempty"`
SpuName
string
`json:"spu_name,omitempty"`
ImagesL
string
`json:"images_l,omitempty"`
SpuBrief
string
`json:"spu_brief
,omitempty
"`
SpuBrief
string
`json:"spu_brief"`
SpuDetail
string
`json:"spu_detail,omitempty"`
ClassName3
string
`json:"class_name3,omitempty"`
ErpTax
bool
`json:"erp_tax"`
ScmBrand
ScmBrand
`json:"scm_brand,omitempty"`
//额外增加的字段
GoodsNameTemp
string
`json:"goods_name_temp,omitempty"`
Multiple
int
`json:"multiple,omitempty"`
SearchSampleApplication
string
`json:"search_sample_application"`
SearchContactExperts
string
`json:"search_contact_experts"`
}
type
Attr
struct
{
...
...
model/supplier.go
0 → 100644
View file @
e85062c1
package
model
import
(
"github.com/gomodule/redigo/redis"
"search_server/pkg/config"
"search_server/pkg/gredis"
)
type
QuoteSupplier
struct
{
HkDelivery
string
`json:"hk_delivery"`
CnDelivery
string
`json:"cn_delivery"`
PriceJson
string
`json:"price_json"`
AdText
string
`json:"ad_text"`
SupplierLogo
string
`json:"supplier_logo"`
AdUrl
string
`json:"ad_url"`
Sort
int
`json:"sort"`
}
func
getSupplier
(
supplierId
string
)
{
redisCon
:=
gredis
.
Conn
(
"default_r"
)
defer
redisCon
.
Close
()
supplierInfoStr
,
_
:=
redis
.
String
(
redisCon
.
Do
(
"HGET"
,
config
.
Get
(
"supplier.SUPPLIER_REDIS_PRE"
)))
if
supplierInfoStr
!=
""
{
//序列化出来使用
}
else
{
//如果redis找不到,就要去数据库里面取了
}
}
pkg/common/function.go
View file @
e85062c1
...
...
@@ -4,6 +4,7 @@ import (
"crypto/md5"
"encoding/hex"
"github.com/syyongx/php2go"
"regexp"
"strconv"
)
...
...
@@ -58,6 +59,12 @@ func ToString(a interface{}) string {
return
"change to String error"
}
//替换字符串,不区分大小写
func
CaseInsensitiveReplace
(
subject
string
,
search
string
,
replace
string
)
string
{
searchRegex
:=
regexp
.
MustCompile
(
"(?i)"
+
search
)
return
searchRegex
.
ReplaceAllString
(
subject
,
replace
)
}
/**
* 获取联营活动价
*/
...
...
service/goods_service.go
View file @
e85062c1
...
...
@@ -10,6 +10,7 @@ import (
"gopkg.in/olivere/elastic.v5"
"regexp"
"search_server/model"
"search_server/pkg/common"
"search_server/pkg/config"
"search_server/pkg/es"
"search_server/pkg/gredis"
...
...
@@ -40,6 +41,48 @@ func GetGoodsInfoByApi(goodsIdsStr string) (goodsList []*model.ApiGoods, err err
}
//处理商品信息数据
func
DullGoodsInfo
(
keyword
string
,
goodsListMap
map
[
string
]
*
model
.
ApiGoods
)
map
[
string
]
*
model
.
ApiGoods
{
//获取redis链接
redisCon
:=
gredis
.
Conn
(
"default_r"
)
defer
redisCon
.
Close
()
for
key
,
goods
:=
range
goodsListMap
{
fmt
.
Println
(
key
)
fmt
.
Println
(
goods
)
if
goods
.
Mpq
==
0
{
goods
.
Mpq
=
1
}
if
goods
.
GoodsName
==
""
{
goods
.
GoodsName
=
goods
.
SpuName
}
//goods_name_temp
if
keyword
!=
""
{
replaceString
:=
"<b class='f-red'>"
+
strings
.
ToUpper
(
keyword
)
+
"</b>"
goods
.
GoodsNameTemp
=
common
.
CaseInsensitiveReplace
(
goods
.
GoodsName
,
keyword
,
replaceString
)
}
else
{
goods
.
GoodsNameTemp
=
goods
.
GoodsName
}
if
goods
.
Mpq
>
goods
.
Moq
{
goods
.
Multiple
=
goods
.
Moq
}
else
{
goods
.
Multiple
=
goods
.
Mpq
}
//te广告按钮
teSwitch
,
_
:=
redis
.
Int
(
redisCon
.
Do
(
"GET"
,
"TeSwitch"
))
if
goods
.
BrandId
==
161
&&
goods
.
GoodsId
!=
"1152755238555810539"
&&
teSwitch
==
2
{
goods
.
SearchSampleApplication
=
"https://www.te.com.cn/chn-zh/solutions/sg-sample-request-form.html?te_bu=Cor&te_type=other&te_campaign=ich_chn_cor-ich-chn-part-selectmktg-fy19-srp-sample_sma-431_10&elqCampaignId=32896"
goods
.
SearchContactExperts
=
"https://www.te.com.cn/chn-zh/solutions/connectivity.html?te_bu=Cor&te_type=other&te_campaign=ich_chn_cor-ich-chn-part-selectmktg-fy19-srp-contact_sma-431_11&elqCampaignId=32897"
}
//供应商信息,读取redis,来源于基石配置
}
return
nil
}
//isMap:是否以字典形式返回值,默认是数组
func
CurlGoodsInfo
(
goodsIdsStr
string
,
params
req
.
Param
)
(
goodsList
[]
*
model
.
ApiGoods
,
goodsListMap
map
[
string
]
*
model
.
ApiGoods
,
err
error
)
{
//req.Debug = true
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment