Skip to content

Commit

Permalink
fix: JSON parse issue
Browse files Browse the repository at this point in the history
  • Loading branch information
greenhat616 committed Oct 17, 2020
1 parent 8d17ad1 commit 87815fe
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions event/hitokotoPollCreated.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (t *hitokotoPollCreatedEvent) Receiver() *rabbitmq.Receiver {
return err
}
html := fmt.Sprintf(`<h2>您好,%s。</h2>
<p>我们在 %s 创建了一则新投票(id: %s)。</p>
<p>我们在 %s 创建了一则新投票(id: %d)。</p>
<p>句子信息:</p>
<ul>
<li>内容:%s</li>
Expand Down Expand Up @@ -65,6 +65,6 @@ func (t *hitokotoPollCreatedEvent) Receiver() *rabbitmq.Receiver {
type hitokotoPollCreatedMessage struct {
hitokotoAppendedMessage
UserName string `json:"user_name"` // 收信人
Id string `json:"id"` // 投票标识
Id int `json:"id"` // 投票标识
CreatedAt string `json:"created_at"` // 这里是投票创建时间, ISO 时间
}
4 changes: 2 additions & 2 deletions event/hitokotoPollFinished.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (t *hitokotoPollFinishedEvent) Receiver() *rabbitmq.Receiver {
}

html := fmt.Sprintf(`<h2>您好,%s。</h2>
<p>投票(id: %s)于 %s 由系统自动处理。</p>
<p>投票(id: %d)于 %s 由系统自动处理。</p>
<p>句子信息:</p>
<ul>
<li>内容:%s</li>
Expand Down Expand Up @@ -94,7 +94,7 @@ func (t *hitokotoPollFinishedEvent) Receiver() *rabbitmq.Receiver {

type hitokotoPollFinishedMessage struct {
hitokotoAppendedMessage
Id string `json:"id"` // 投票 ID
Id int `json:"id"` // 投票 ID
UpdatedAt string `json:"updated_at"` // 投票更新时间,这里也是结束时间
UserName string `json:"user_name"` // 审核员名字
CreatedAt string `json:"created_at"` // 投票创建时间
Expand Down
4 changes: 2 additions & 2 deletions event/hitokotoReviewed.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (t *hitokotoReviewedEvent) Receiver() *rabbitmq.Receiver {
}
html := fmt.Sprintf(`<h2>您好,%s。</h2>
<p>您于 %s 提交的句子: <b>%s</b> —— %s 「%s」, 已经审核完成。</p>
<p>审核结果为:<strong>%s</strong>,审核员 %s (%s) 于 %s 操作审核%s</p>
<p>审核结果为:<strong>%s</strong>,审核员 %s (%d) 于 %s 操作审核%s</p>
<br />
<p>感谢您的支持,<br />
萌创团队 - 一言项目组<br />
Expand All @@ -80,6 +80,6 @@ type hitokotoReviewedMessage struct {
hitokotoAppendedMessage
OperatedAt string `json:"operated_at"` // 操作时间
ReviewerName string `json:"reviewer_name"` // 审核员名称
ReviewerUid string `json:"reviewer_uid"` // 审核员用户标识
ReviewerUid int `json:"reviewer_uid"` // 审核员用户标识
Status int `json:"status"` // 审核结果: 200 为通过,201 为驳回
}
6 changes: 3 additions & 3 deletions rabbitmq/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ func (m *AmqpClient) Subscribe(exchangeName string, exchangeType string, queueNa
nil, // args
)
failOnError(err, "Failed to register a consumer")
go consumeLoop(msgs, handlerFunc)
go consumeLoop(msgs, consumerName, handlerFunc)
go func() {
KeepAliveLoop:
for {
Expand Down Expand Up @@ -397,7 +397,7 @@ func (m *AmqpClient) SubscribeToQueue(queueName string, consumerName string, han
)
failOnError(err, "Failed to register a consumer")

go consumeLoop(msgs, handlerFunc)
go consumeLoop(msgs,consumerName, handlerFunc)
return nil
}

Expand All @@ -411,7 +411,7 @@ func (m *AmqpClient) Close() {
}
}

func consumeLoop(deliveries <-chan amqp.Delivery, handlerFunc func(d amqp.Delivery) error) {
func consumeLoop(deliveries <-chan amqp.Delivery, consumerName string, handlerFunc func(d amqp.Delivery) error) {
for d := range deliveries {
// Invoke the handlerFunc func we passed as parameter.
err := handlerFunc(d)
Expand Down

0 comments on commit 87815fe

Please sign in to comment.