Quellcode durchsuchen

feat:发布信息 nsq 日志

wangshan vor 3 Jahren
Ursprung
Commit
69e571c784
2 geänderte Dateien mit 30 neuen und 5 gelöschten Zeilen
  1. 18 1
      rpc/common/test/html_test.go
  2. 12 4
      rpc/consumer/internal/logic/publishinfologic.go

+ 18 - 1
rpc/common/test/html_test.go

@@ -11,8 +11,25 @@ import (
 func Test_html(t *testing.T) {
 	str1 := `<script>1111</script><p style="text-align: center;">剑鱼研发部泡面供应</p>
 <hr />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 <p style="text-align: left;">加班才有</p>
 <p style="text-align: left;">1人1桶加肠</p>
-<p style="text-align: left;">不吃饿着</p>`
+<p style="text-align: left;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;不吃饿着</p>`
 	log.Println(util.NewCut().ClearHtml(str1))
 }

+ 12 - 4
rpc/consumer/internal/logic/publishinfologic.go

@@ -86,7 +86,7 @@ func (l *PublishInfoLogic) PublishInfo(in *consumerinfo.PublishInfoReq) (*consum
 	}
 	if id < 1 {
 		res.ErrCode = -1
-		res.ErrMsg = "信息发布失败"
+		res.ErrMsg = "信息保存失败"
 		return &res, nil
 	}
 
@@ -105,10 +105,18 @@ func (l *PublishInfoLogic) PublishInfo(in *consumerinfo.PublishInfoReq) (*consum
 	}
 	log.Println("发送nsq敏感词信息", model.NsqConfig, appendInfo)
 	nsq, err := util.NewNsqInfo(model.NsqConfig.Ip, model.NsqConfig.Topic, mc.InterfaceToStr(id), "1", mc.InterfaceToStr(in.MsgType), false, appendInfo)
-	if err != nil || nsq.NsqPushInfo() != nil {
-		log.Println("信息发布失败nsq++++++++++++", model.NsqConfig, appendInfo)
+
+	if err != nil {
+		log.Println("初始化NSQ信息失败")
 		res.ErrCode = -1
-		res.ErrMsg = fmt.Sprintf("信息发布失败")
+		res.ErrMsg = err.Error()
+		return &res, nil
+	}
+	if err := nsq.NsqPushInfo(); err != nil {
+		log.Println("发送nsq敏感词信息失败nsq++++++++++++", model.NsqConfig, appendInfo, err.Error())
+		res.ErrCode = -1
+		res.ErrMsg = err.Error()
+		return &res, nil
 	}
 	if in.MsgType == 3 {
 		entNameKye := fmt.Sprintf("userEntName_%s_%d_%d", in.UserId, id, in.MsgType)