添加创建ppt的状态信息
This commit is contained in:
parent
bc6c996b2f
commit
8ae2af9884
|
|
@ -59,6 +59,7 @@ func SetUpToolGroup(router *gin.Engine) {
|
|||
toolGroup.POST("/spark_ppt_theme_list", GetSparkPPTThemeList)
|
||||
toolGroup.POST("/spark_create_outline", CreateSparkPPTSOutline)
|
||||
toolGroup.POST("/spark_create_ppt", CreateSparkPPT)
|
||||
toolGroup.POST("/spark_ppt_create_status", GetSparkCreatePPTStatus)
|
||||
}
|
||||
|
||||
func SetDeviceStatusV2(c *gin.Context) {
|
||||
|
|
@ -511,3 +512,34 @@ func CreateSparkPPT(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
}
|
||||
|
||||
func GetSparkCreatePPTStatus(c *gin.Context) {
|
||||
id := c.Param("id")
|
||||
userID, _ := strconv.Atoi(id)
|
||||
var req proto.GetSparkCreatePPTStatusReq
|
||||
if err := c.ShouldBind(&req); err == nil {
|
||||
//查看该会话是否属于该用户
|
||||
session := dao.FindSessionByID(req.SessionID)
|
||||
if session.ID == 0 || session.UserID != userID {
|
||||
c.JSON(http.StatusOK, gin.H{"error": "session not found or session is not the user", "code": proto.ParameterError, "message": "failed"})
|
||||
return
|
||||
}
|
||||
//从redis获取
|
||||
key := fmt.Sprintf("user-%d-session-%d-create-pptx", userID, req.SessionID)
|
||||
status := worker.GetRedis(key)
|
||||
if status == "" {
|
||||
c.JSON(http.StatusOK, gin.H{"code": proto.SuccessCode, "message": "success", "data": nil})
|
||||
return
|
||||
}
|
||||
var resp proto.SparkCreatePPTByOutlineResponse
|
||||
err2 := json.Unmarshal([]byte(status), &resp)
|
||||
if err2 != nil {
|
||||
c.JSON(http.StatusOK, gin.H{"error": "get redis error", "code": proto.ParameterError, "message": "failed"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"code": proto.SuccessCode, "message": "success", "data": resp})
|
||||
} else {
|
||||
c.JSON(http.StatusOK, gin.H{"error": "parameter error", "code": proto.ParameterError, "message": "failed"})
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -180,3 +180,8 @@ type SparkCreatePPTData struct {
|
|||
SubTitle string `json:"subTitle"`
|
||||
Outline interface{} `json:"outline"`
|
||||
}
|
||||
|
||||
type GetSparkCreatePPTStatusReq struct {
|
||||
Function string `json:"function" form:"function"` // 功能
|
||||
SessionID int `json:"sessionId" form:"sessionId"` // 会话id
|
||||
}
|
||||
|
|
|
|||
|
|
@ -328,7 +328,11 @@ func SparkDoGetPPTInfoBySID(modelParam *proto.ModelParam, userReq *proto.SparkCr
|
|||
log.Println("Spark create ppt by outline Error:", err)
|
||||
return
|
||||
}
|
||||
respStr, _ := json.Marshal(resp)
|
||||
service.CreateAIStreamMsg(base.UserID, base.ModelID, int(base.SessionID), resp, modelParam.Model) //保存消息
|
||||
//添加到消息队列,用于前端查询
|
||||
key := fmt.Sprintf("user-%d-session-%d-create-pptx", base.UserID, base.SessionID)
|
||||
worker.SetRedisWithExpire(key, string(respStr), time.Second*60*5) //设置5分钟过期
|
||||
if resp.Data.PptStatus == "done" {
|
||||
log.Println("ppt done")
|
||||
//下载文件,保存到指定用户的文件
|
||||
|
|
|
|||
Loading…
Reference in New Issue