添加制作ppt测试数据,不进行数据请求,只读当前数据
This commit is contained in:
parent
7620d9e9b0
commit
93c01cfae6
|
|
@ -10,7 +10,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
@ -453,13 +452,14 @@ func GetSparkPPTThemeList(c *gin.Context) {
|
||||||
var themeList proto.SparkPPTThemeListResponse
|
var themeList proto.SparkPPTThemeListResponse
|
||||||
//获取主题列表
|
//获取主题列表
|
||||||
if worker.IsContainKey("spark_ppt_theme_list") {
|
if worker.IsContainKey("spark_ppt_theme_list") {
|
||||||
themeListStr := worker.GetRedis("spark_ppt_theme_list")
|
//themeListStr := worker.GetRedis("spark_ppt_theme_list")
|
||||||
if themeListStr != "" {
|
//if themeListStr != "" {
|
||||||
err = json.Unmarshal([]byte(themeListStr), &themeList)
|
// err = json.Unmarshal([]byte(themeListStr), &themeList)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log.Println("get redis spark ppt theme list error:", err)
|
// log.Println("get redis spark ppt theme list error:", err)
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
themeList = spark.TestPPTTHemeList()
|
||||||
} else {
|
} else {
|
||||||
themeList, err = spark.SparkPPTThemeList(&modelParam, req)
|
themeList, err = spark.SparkPPTThemeList(&modelParam, req)
|
||||||
themeListStr, _ := json.Marshal(themeList)
|
themeListStr, _ := json.Marshal(themeList)
|
||||||
|
|
|
||||||
|
|
@ -457,3 +457,28 @@ func testPPTOutline() proto.SparkCreateOutlineResponse {
|
||||||
}
|
}
|
||||||
return outline
|
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
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue