Commit 5cc11c43 authored by 赵文静's avatar 赵文静

修复相关问题

parent db1b0c50
package model package model
import "encoding/json"
type SpeechDomainParams struct { type SpeechDomainParams struct {
SpeechWsResp *SpeechWsResp SpeechWsResp *SpeechWsResp
Query string Query string
...@@ -121,3 +123,7 @@ type Result struct { ...@@ -121,3 +123,7 @@ type Result struct {
Year int `json:"year"` Year int `json:"year"`
Event string `json:"event"` Event string `json:"event"`
} }
type ExtraParams struct {
Content json.RawMessage `json:"content"`
}
...@@ -432,6 +432,24 @@ func alarmDomain(params *model.SpeechDomainParams) []byte { ...@@ -432,6 +432,24 @@ func alarmDomain(params *model.SpeechDomainParams) []byte {
extra := params.SpeechWsResp.Dm.Command.Param.Extra extra := params.SpeechWsResp.Dm.Command.Param.Extra
object := params.SpeechWsResp.Dm.Command.Param.Object object := params.SpeechWsResp.Dm.Command.Param.Object
var extraParam model.ExtraParams
if err := json.Unmarshal([]byte(extra), &extraParam); err != nil {
global.Logger.WithFields(logger.Fields{
"requestId": params.RequestId,
"mac": params.Mac,
"mid": params.Mid,
"vender": params.MidType,
}).Errorf("json.Unmarshal error: %v", err)
}
if len(extraParam.Content) > 0 {
var content map[string]interface{}
if err := json.Unmarshal(extraParam.Content, &content); err == nil {
if len(content) == 0 {
return Marshal(params, &result)
}
}
}
if object == "闹钟" { if object == "闹钟" {
result.Header.Semantic.Domain = "alarm" result.Header.Semantic.Domain = "alarm"
} else { } else {
......
...@@ -37,14 +37,14 @@ type FeedBackResp struct { ...@@ -37,14 +37,14 @@ type FeedBackResp struct {
Source string `json:"source"` Source string `json:"source"`
} }
func FeedBackNews(actionType, duration int, ip, sid, uid string) (*FeedBackResp, error) { func FeedBackNews(actionType, duration int, sid, uid string) (*FeedBackResp, error) {
url := "http://apis.duiopen.com/feedback/letingv4?productId=279629895&apikey=0c74988953dd4ed4bf31955527802cf3&uid=111" url := "http://apis.duiopen.com/feedback/letingv4?productId=279629895&apikey=0c74988953dd4ed4bf31955527802cf3&uid=111"
//url := global.SpeechSetting.FeedBackUrl + "?productId=" + global.SpeechSetting.ProductId + "&apikey=" + global.SpeechSetting.ApiKey + "&uid=" + uid //url := global.SpeechSetting.FeedBackUrl + "?productId=" + global.SpeechSetting.ProductId + "&apikey=" + global.SpeechSetting.ApiKey + "&uid=" + uid
request := FeedBackReq{ request := FeedBackReq{
ActionType: actionType, ActionType: actionType,
Timestamp: time.Now().Unix(), Timestamp: time.Now().Unix(),
ClientIp: ip, //ip //ClientIp: ip, //ip
Brand: "gree", Brand: "gree",
Data: []map[string]interface{}{ Data: []map[string]interface{}{
{ {
"sid": sid, //"m6J2LW-4z-H2dtxea5Sv6_voziweppX1K_aGb7fKtdjq3y36awwXd_NeoKgBXD7a" "sid": sid, //"m6J2LW-4z-H2dtxea5Sv6_voziweppX1K_aGb7fKtdjq3y36awwXd_NeoKgBXD7a"
......
...@@ -194,8 +194,8 @@ func (c *Consumer) Consume() { ...@@ -194,8 +194,8 @@ func (c *Consumer) Consume() {
// 处理消息逻辑 // 处理消息逻辑
state, offset, mediaId := parseData(&resp) state, offset, mediaId := parseData(&resp)
uid := util.EncodeMD5(resp.Mac) uid := util.EncodeMD5(resp.Mac)
ip := "14.215.222.17" //todo:待改 //ip := "14.215.222.17" //todo:待改
if _, err := FeedBackNews(state, offset, ip, mediaId, uid); err != nil { if _, err := FeedBackNews(state, offset, mediaId, uid); err != nil {
global.Logger.Errorf("Feedback error: %v", err) global.Logger.Errorf("Feedback error: %v", err)
_ = d.Nack(false, true) _ = d.Nack(false, true)
continue continue
......
...@@ -51,6 +51,7 @@ func register() { ...@@ -51,6 +51,7 @@ func register() {
DomainRegister(HOLIDAY, holidayDomain) DomainRegister(HOLIDAY, holidayDomain)
DomainRegister(RELATION, speechOtherDomain) DomainRegister(RELATION, speechOtherDomain)
DomainRegister(WASTESORTING, speechOtherDomain) DomainRegister(WASTESORTING, speechOtherDomain)
DomainRegister("", speechOtherDomain)
// //
//DomainRegisterV2(CHAT, chatDomainV2) //DomainRegisterV2(CHAT, chatDomainV2)
......
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 to comment