From da64bd7c564456275014e00c1428be688c11b514 Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Thu, 3 Apr 2025 19:50:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96ppt=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/tool.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/handler/tool.go b/handler/tool.go index be21411..514ef2b 100644 --- a/handler/tool.go +++ b/handler/tool.go @@ -10,6 +10,7 @@ import ( "fmt" "github.com/gin-gonic/gin" "io" + "log" "net/http" "os" "strconv" @@ -449,9 +450,22 @@ func GetSparkPPTThemeList(c *gin.Context) { } modelParam.Url = model.Url modelParam.System = funcs[0].Info //系统功能 + var themeList proto.PPTThemeResponse //获取主题列表 - themeList, err2 := spark.SparkPPTThemeList(&modelParam, req) - if err2 != nil { + if worker.IsContainKey("spark_ppt_theme_list") { + themeListStr := worker.GetRedis("spark_ppt_theme_list") + if themeListStr != "" { + err = json.Unmarshal([]byte(themeListStr), &themeList) + if err != nil { + log.Println("get redis spark ppt theme list error:", err) + } + } + } else { + themeList, err = spark.SparkPPTThemeList(&modelParam, req) + themeListStr, _ := json.Marshal(themeList) + worker.SetRedis("spark_ppt_theme_list", string(themeListStr)) //调试阶段不设置过期 + } + if err != nil { c.JSON(http.StatusOK, gin.H{"error": "get spark ppt theme list error", "code": proto.ParameterError, "message": "failed"}) return }