diff --git a/service/spark/spark-ppt.go b/service/spark/spark-ppt.go index c49ce10..196909d 100644 --- a/service/spark/spark-ppt.go +++ b/service/spark/spark-ppt.go @@ -259,11 +259,11 @@ func SparkDoCreateOutline(userReq *proto.SparkCreateOutlineRequest, base *proto. log.Println("Spark create outline Error:", err) return outline, err } - outlineStr, _ := json.Marshal(userReq) + outlineStr, _ := json.Marshal(outline) //返回的数据保存 service.CreateAIStreamMsg(base.UserID, base.ModelID, int(base.SessionID), outline, modelParam.Model) //保存大纲 - err3, userMsgID = service.CreateMessage(proto.ModelToUserMsgType, int(sessionID), base.UserID, int(model.ID), string(outlineStr), proto.UserToModelPPTMsgType, int(funcs[0].ID)) + err3, userMsgID = service.CreateMessage(proto.ModelToUserMsgType, int(sessionID), int(model.ID), base.UserID, string(outlineStr), proto.UserToModelPPTMsgType, int(funcs[0].ID)) if err3 != nil { log.Println("Create message error:", err3, userMsgID) return proto.SparkCreateOutlineResponse{}, err3 @@ -317,12 +317,12 @@ func SparkDoCreatePPTByOutline(userReq *proto.SparkCreatePPTByOutlineUserRequest service.CreateAIStreamMsg(base.UserID, base.ModelID, int(base.SessionID), resp, modelParam.Model) //保存消息 //新协程获取ppt制作进度 userReq.Sid = resp.Data.SID - go SparkDoGetPPTInfoBySID(&modelParam, userReq, base) + go SparkDoGetPPTInfoBySID(&modelParam, userReq, base, &model) //根据大纲生成ppt return resp, nil } // 每3秒查询一次ppt制作情况 -func SparkDoGetPPTInfoBySID(modelParam *proto.ModelParam, userReq *proto.SparkCreatePPTByOutlineUserRequest, base *proto.SparkCreatePPTBaseInfo) { +func SparkDoGetPPTInfoBySID(modelParam *proto.ModelParam, userReq *proto.SparkCreatePPTByOutlineUserRequest, base *proto.SparkCreatePPTBaseInfo, model *dao.Model) { //定时 ticker := time.NewTicker(3 * time.Second) defer ticker.Stop() @@ -365,6 +365,12 @@ func SparkDoGetPPTInfoBySID(modelParam *proto.ModelParam, userReq *proto.SparkCr if fileRecord.ID == 0 || fileAuth.ID == 0 { log.Println("save file info failed", fileRecord.ID, fileAuth.ID) } + //将model发送的消息保存到数据库 + err3, userMsgID := service.CreateMessage(proto.ModelToUserMsgType, int(base.SessionID), int(model.ID), base.UserID, string(respStr), proto.UserToModelPPTMsgType, base.FunctionID) + if err3 != nil { + log.Println("Create message error:", err3, userMsgID) + } + log.Println("spark create ppt by outline success,msg id:", userMsgID) return } }