Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
bom_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
277a4563
authored
Jan 29, 2021
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
temp
parent
9d4889cb
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
0 deletions
go.mod
go.sum
internal/logic/encap.go
internal/logic/search.go
go.mod
View file @
277a4563
...
@@ -4,6 +4,7 @@ go 1.13
...
@@ -4,6 +4,7 @@ go 1.13
require (
require (
github.com/360EntSecGroup-Skylar/excelize v1.4.1
github.com/360EntSecGroup-Skylar/excelize v1.4.1
github.com/garyburd/redigo v1.6.0
github.com/gin-gonic/gin v1.6.3
github.com/gin-gonic/gin v1.6.3
github.com/go-ini/ini v1.56.0
github.com/go-ini/ini v1.56.0
github.com/go-kratos/kratos v0.5.0
github.com/go-kratos/kratos v0.5.0
...
...
go.sum
View file @
277a4563
...
@@ -68,6 +68,7 @@ github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8
...
@@ -68,6 +68,7 @@ github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/garyburd/redigo v1.6.0 h1:0VruCpn7yAIIu7pWVClQC8wxCJEcG3nyzpMSHKi1PQc=
github.com/garyburd/redigo v1.6.0/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY=
github.com/garyburd/redigo v1.6.0/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
...
...
internal/logic/encap.go
0 → 100644
View file @
277a4563
package
logic
import
(
"bom_server/internal/mapping"
"bom_server/internal/pkg/gredis"
"github.com/garyburd/redigo/redis"
"regexp"
)
//转换封装
func
TransformEncap
(
encap
string
)
(
attrValue
string
)
{
numberR
,
_
:=
regexp
.
Compile
(
mapping
.
PureNumberRegular
)
pureNumber
:=
numberR
.
FindString
(
encap
)
//判断是多少位数字,如果是3位,则代表可能需要往前面补零
if
len
(
pureNumber
)
==
3
{
encapCheck
:=
"0"
+
pureNumber
//补全完以后,去sku_map2尝试获取值,如果存在的话,就代表是正确的封装
attrName
,
_
:=
redis
.
String
(
gredis
.
HGet
(
"sku_map2"
,
encapCheck
))
if
attrName
!=
""
{
pureNumber
=
encapCheck
}
}
//再去找对应属性
attrValue
=
"封装"
+
"€"
+
pureNumber
return
attrValue
}
internal/logic/search.go
View file @
277a4563
...
@@ -82,6 +82,7 @@ func search(index string, bomId int, bomItems []model.BomItem, deliveryType, sor
...
@@ -82,6 +82,7 @@ func search(index string, bomId int, bomItems []model.BomItem, deliveryType, sor
func
getSearchParams
(
index
string
,
bomItem
model
.
BomItem
,
sort
int
,
flag
bool
)
(
searchRequest
*
es
.
SearchRequest
)
{
func
getSearchParams
(
index
string
,
bomItem
model
.
BomItem
,
sort
int
,
flag
bool
)
(
searchRequest
*
es
.
SearchRequest
)
{
fmt
.
Println
(
"商品名称 : "
,
bomItem
.
GoodsName
)
fmt
.
Println
(
"商品名称 : "
,
bomItem
.
GoodsName
)
fmt
.
Println
(
"参数列表 : "
,
bomItem
.
AttrList
)
fmt
.
Println
(
"参数列表 : "
,
bomItem
.
AttrList
)
bomItem
.
Encap
=
TransformEncap
(
bomItem
.
Encap
)
fmt
.
Println
(
"封装 : "
,
bomItem
.
Encap
)
fmt
.
Println
(
"封装 : "
,
bomItem
.
Encap
)
query
:=
getTermQuery
(
bomItem
,
sort
,
flag
)
query
:=
getTermQuery
(
bomItem
,
sort
,
flag
)
source
:=
es
.
NewSearchSource
()
.
Query
(
query
)
source
:=
es
.
NewSearchSource
()
.
Query
(
query
)
...
...
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