package kafka import ( "context" "encoding/json" "finclip-app-manager/infrastructure/client/httpcall" "finclip-app-manager/infrastructure/config" uuid "github.com/satori/go.uuid" "strings" ) //通知中心 type NotifyContent struct { Msg string `json:"msg"` Result string `json:"result"` Reason string `json:"reason"` Title string `json:"title"` } func GenNotifyData(ctx context.Context, organId string, t int, content NotifyContent) error { data := make(map[string]interface{}) data["organTraceId"] = organId data["tab"] = "work" data["type"] = t //1000-1999:应用市场使用,2000-2999:企业端使用,3000-3999:运营端使用 data["content"] = content data["id"] = uuid.NewV4().String() jsonBytes, _ := json.Marshal(data) if producer == nil { req := &httpcall.AddNotifyReq{} req.Id = uuid.NewV4().String() req.Type = t req.Content = content req.OrganId = organId req.Tab = "system" err := hCaller.AddNotify(ctx, req) return err } return sendMsg(ctx, config.GetConfig().KafkaNotifyTopic, string(jsonBytes)) } func getAddrIp(address string) string { ipArry := strings.Split(address, ",") if len(ipArry) == 0 { return "" } else { return ipArry[0] } }