|
@@ -2,6 +2,7 @@ package service
|
|
|
|
|
|
import (
|
|
|
"app.yhyue.com/moapp/jybase/common"
|
|
|
+ "app.yhyue.com/moapp/jybase/go-xweb/log"
|
|
|
. "biBackService/config"
|
|
|
"biBackService/public"
|
|
|
"bytes"
|
|
@@ -12,6 +13,7 @@ import (
|
|
|
"net/http"
|
|
|
"net/url"
|
|
|
"os"
|
|
|
+ "strings"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
@@ -138,3 +140,46 @@ func SendWechatWorkMessage() error {
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
+
|
|
|
+func GetTitleByContent(content string) (toTitle string, err error) {
|
|
|
+ reqUrl := SysConfig.WorkflowsUrl
|
|
|
+ method := "POST"
|
|
|
+ param := map[string]interface{}{
|
|
|
+ "inputs": map[string]interface{}{
|
|
|
+ "content": content,
|
|
|
+ },
|
|
|
+ "response_mode": "blocking",
|
|
|
+ "user": SysConfig.WorkflowsUser,
|
|
|
+ }
|
|
|
+ jsonData, err := json.Marshal(param)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ payload := strings.NewReader(string(jsonData))
|
|
|
+
|
|
|
+ client := &http.Client{}
|
|
|
+ req, err := http.NewRequest(method, reqUrl, payload)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ req.Header.Add("Content-Type", "application/json")
|
|
|
+ req.Header.Add("Authorization", "Bearer app-w7OhSixqrVvZLa3wIEXNeoOh")
|
|
|
+ res, err := client.Do(req)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ defer res.Body.Close()
|
|
|
+
|
|
|
+ var result map[string]interface{}
|
|
|
+ if err = json.NewDecoder(res.Body).Decode(&result); err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ log.Println("result", result)
|
|
|
+ if data, ok := result["data"].(map[string]interface{}); ok {
|
|
|
+ if outputs, oks := data["outputs"].(map[string]interface{}); oks {
|
|
|
+ toTitle = strings.Replace(common.ObjToString(outputs["title"]), "标题:", "", -1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //toTitle = string(body)
|
|
|
+ return
|
|
|
+}
|