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
337b8350
authored
Oct 27, 2020
by
huangchengyi
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
1.0
parent
5d847e7f
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
88 additions
and
2 deletions
doc/test/mong1.go
doc/test/mq/1.go
go.mod
model/goods.go
service/optimum_service.go
service/query/optimum_query.go
doc/test/mong1.go
0 → 100644
View file @
337b8350
package
main
doc/test/mq/1.go
0 → 100644
View file @
337b8350
package
main
import
(
"fmt"
"github.com/ichunt2019/go-msgserver/utils/rabbitmq"
"time"
)
type
RecvPro
struct
{
}
//// 实现消费者 消费消息失败 自动进入延时尝试 尝试3次之后入库db
func
(
t
*
RecvPro
)
Consumer
(
dataByte
[]
byte
)
error
{
fmt
.
Println
(
string
(
dataByte
))
//return errors.New("顶顶顶顶")
return
nil
}
//消息已经消费3次 失败了 请进行处理
func
(
t
*
RecvPro
)
FailAction
(
dataByte
[]
byte
)
error
{
fmt
.
Println
(
string
(
dataByte
))
fmt
.
Println
(
"任务处理失败了,我要进入db日志库了"
)
fmt
.
Println
(
"任务处理失败了,发送钉钉消息通知主人"
)
return
nil
}
func
main
()
{
//消费者实现 下面接口即可
//type Receiver interface {
// Consumer([]byte) error
//}
print
(
"开始"
)
t
:=
&
RecvPro
{}
queueExchange
:=
&
rabbitmq
.
QueueExchange
{
"szpurchase_message_tasks"
,
"szpurchase_message_tasks"
,
"szpurchase_message_tasks"
,
"direct"
,
"amqp://guest:guest@192.168.2.232:5672/"
,
}
print
(
"3333434"
)
for
{
print
(
""
)
mq
:=
rabbitmq
.
New
(
queueExchange
)
mq
.
RegisterReceiver
(
t
)
err
:=
mq
.
Start
()
if
err
!=
nil
{
fmt
.
Println
(
err
)
}
time
.
Sleep
(
time
.
Second
)
}
}
\ No newline at end of file
go.mod
View file @
337b8350
...
@@ -20,6 +20,7 @@ require (
...
@@ -20,6 +20,7 @@ require (
github.com/grpc-ecosystem/go-grpc-middleware v1.2.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.14.3 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.14.3 // indirect
github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0
github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0
github.com/ichunt2019/go-msgserver v1.0.5 // indirect
github.com/ichunt2019/go-rabbitmq v1.0.1
github.com/ichunt2019/go-rabbitmq v1.0.1
github.com/ichunt2019/logger v1.0.5
github.com/ichunt2019/logger v1.0.5
github.com/imroc/req v0.3.0
github.com/imroc/req v0.3.0
...
@@ -53,6 +54,7 @@ require (
...
@@ -53,6 +54,7 @@ require (
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
gopkg.in/olivere/elastic.v5 v5.0.85
gopkg.in/olivere/elastic.v5 v5.0.85
gopkg.in/yaml.v2 v2.3.0 // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
labix.org/v2/mgo v0.0.0-20140701140051-000000000287 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
xorm.io/core v0.7.2-0.20190928055935-90aeac8d08eb
xorm.io/core v0.7.2-0.20190928055935-90aeac8d08eb
)
)
...
...
model/goods.go
View file @
337b8350
...
@@ -108,6 +108,7 @@ type DullGoodsData struct {
...
@@ -108,6 +108,7 @@ type DullGoodsData struct {
GoodsUrl
string
`json:"goods_url"`
GoodsUrl
string
`json:"goods_url"`
CompanyName
string
`json:"-"`
CompanyName
string
`json:"-"`
ProviderName
string
`json:"-"`
ProviderName
string
`json:"-"`
Attrs
interface
{}
`json:"attrs"`
}
}
type
Attr
struct
{
type
Attr
struct
{
...
...
service/optimum_service.go
View file @
337b8350
...
@@ -185,7 +185,24 @@ func (qs *OptimumService) GetOptimumAttrInfo(ctx *gin.Context) (results model.Ly
...
@@ -185,7 +185,24 @@ func (qs *OptimumService) GetOptimumAttrInfo(ctx *gin.Context) (results model.Ly
}
}
common
.
PrintDebugHtml
(
ctx
,
esResult
)
common
.
PrintDebugHtml
(
ctx
,
esResult
)
goodsIds
:=
GetGoodsIdsByEs
(
esResult
)
goodsIds
:=
make
([]
string
,
0
)
//goods_id
attrs
:=
make
(
map
[
string
][]
map
[
string
]
string
)
//属性
gjArray
:=
gjson
.
Get
(
esResult
,
"hits.hits.#._source"
)
.
Array
()
for
_
,
item
:=
range
gjArray
{
goods_id
:=
item
.
Get
(
"goods_id"
)
.
String
()
goodsIds
=
append
(
goodsIds
,
goods_id
)
temp
:=
make
([]
map
[
string
]
string
,
0
)
for
_
,
attr
:=
range
item
.
Get
(
"attrs"
)
.
Array
()
{
temp
=
append
(
temp
,
map
[
string
]
string
{
"attr_name"
:
attr
.
Get
(
"attr_name"
)
.
String
(),
"attr_value"
:
attr
.
Get
(
"attr_value"
)
.
String
(),
})
}
attrs
[
goods_id
]
=
temp
}
//判断返回总条数
//判断返回总条数
total
:=
gjson
.
Get
(
esResult
,
"hits.total"
)
.
Int
()
total
:=
gjson
.
Get
(
esResult
,
"hits.total"
)
.
Int
()
if
total
==
0
{
if
total
==
0
{
...
@@ -229,6 +246,7 @@ func (qs *OptimumService) GetOptimumAttrInfo(ctx *gin.Context) (results model.Ly
...
@@ -229,6 +246,7 @@ func (qs *OptimumService) GetOptimumAttrInfo(ctx *gin.Context) (results model.Ly
ApiGoods
:
v
,
ApiGoods
:
v
,
GoodsUrl
:
GoodsUrl
,
GoodsUrl
:
GoodsUrl
,
BrandUrl
:
BrandUrl
,
BrandUrl
:
BrandUrl
,
Attrs
:
attrs
[
v
.
GoodsId
],
})
})
}
}
...
...
service/query/optimum_query.go
View file @
337b8350
...
@@ -82,7 +82,7 @@ func GetOptimumAttrQuery(ctx *gin.Context,REQUEST_ATTR *map[string][]string,type
...
@@ -82,7 +82,7 @@ func GetOptimumAttrQuery(ctx *gin.Context,REQUEST_ATTR *map[string][]string,type
}
}
}
}
source
.
FetchSourceContext
(
elastic
.
NewFetchSourceContext
(
true
)
.
Include
(
"goods_id"
))
//显示字段
source
.
FetchSourceContext
(
elastic
.
NewFetchSourceContext
(
true
)
.
Include
(
"goods_id"
,
"attrs"
))
//显示字段
source
.
Size
(
common
.
MyInt
(
page_size
))
source
.
Size
(
common
.
MyInt
(
page_size
))
source
.
From
(
page_from
)
source
.
From
(
page_from
)
...
...
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