添加制作ppt测试数据,不进行数据请求,只读当前数据

This commit is contained in:
junleea 2025-04-04 18:10:41 +08:00
parent 7620d9e9b0
commit 93c01cfae6
2 changed files with 33 additions and 8 deletions

View File

@ -10,7 +10,6 @@ import (
"fmt"
"github.com/gin-gonic/gin"
"io"
"log"
"net/http"
"os"
"strconv"
@ -453,13 +452,14 @@ func GetSparkPPTThemeList(c *gin.Context) {
var themeList proto.SparkPPTThemeListResponse
//获取主题列表
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)
}
}
//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)
// }
//}
themeList = spark.TestPPTTHemeList()
} else {
themeList, err = spark.SparkPPTThemeList(&modelParam, req)
themeListStr, _ := json.Marshal(themeList)

View File

@ -457,3 +457,28 @@ func testPPTOutline() proto.SparkCreateOutlineResponse {
}
return outline
}
func TestPPTTHemeList() proto.SparkPPTThemeListResponse {
path := "/home/saw/saw_ppt_theme.json"
var themeList proto.SparkPPTThemeListResponse
//读取文件
file, err := os.Open(path)
if err != nil {
log.Println("Error opening file:", err)
return themeList
}
defer file.Close()
//读取文件内容
data, err := io.ReadAll(file)
if err != nil {
log.Println("Error reading file:", err)
return themeList
}
err = json.Unmarshal(data, &themeList)
if err != nil {
log.Println("Error unmarshalling JSON:", err)
return themeList
}
return themeList
}