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

修复相关问题

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