Browse Source

wip:模版消息长度截取

wangkaiyue 1 năm trước cách đây
mục cha
commit
d40f3af9f7
1 tập tin đã thay đổi với 6 bổ sung1 xóa
  1. 6 1
      rpc/internal/common/sendWxTmplMsg.go

+ 6 - 1
rpc/internal/common/sendWxTmplMsg.go

@@ -139,10 +139,15 @@ func (stm *WxTmplPush) getMessage(title, detail, date, row4 string) (map[string]
 		}
 	}
 	bValue := map[string]*qrpc.TmplItem{}
-	fmt.Println("formatValue", formatValue)
 	if err := json.Unmarshal([]byte(formatValue), &bValue); err != nil {
 		return nil, fmt.Errorf("格式化信息内容异常 %s", err.Error())
 	}
+	for _, item := range bValue {
+		val := []rune(item.Value)
+		if len(val) > 20 {
+			item.Value = string(val[:17]) + "..."
+		}
+	}
 	return bValue, nil
 
 }