获取ppt主题列表缓存
This commit is contained in:
parent
2d7c14087d
commit
da64bd7c56
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"io"
|
"io"
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
@ -449,9 +450,22 @@ func GetSparkPPTThemeList(c *gin.Context) {
|
||||||
}
|
}
|
||||||
modelParam.Url = model.Url
|
modelParam.Url = model.Url
|
||||||
modelParam.System = funcs[0].Info //系统功能
|
modelParam.System = funcs[0].Info //系统功能
|
||||||
|
var themeList proto.PPTThemeResponse
|
||||||
//获取主题列表
|
//获取主题列表
|
||||||
themeList, err2 := spark.SparkPPTThemeList(&modelParam, req)
|
if worker.IsContainKey("spark_ppt_theme_list") {
|
||||||
if err2 != nil {
|
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"})
|
c.JSON(http.StatusOK, gin.H{"error": "get spark ppt theme list error", "code": proto.ParameterError, "message": "failed"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue