Compare commits

...

2 Commits

Author SHA1 Message Date
ArvinLovegood
a354ab8925 feat(news):添加新闻标题字段并更新测试代码
- 在 Telegraph 模型中新增 Title 字段以存储新闻标题
- 更新 market_news_api.go 文件以支持标题数据的提取和赋值
2025-12-11 16:47:35 +08:00
ArvinLovegood
6d50be8541 fix(main):添加全局panic捕获
- 增加defer函数捕获程序异常
- 记录panic堆栈信息便于调试
- 注释掉包含构建密钥的日志输出

chore(test): 新增字符串处理工具包引入

- 引入lancet/v2/strutil包用于测试
- 添加调试日志展示字符串截取功能
- 完善市场资讯API测试用例
2025-12-10 17:52:18 +08:00
3 changed files with 25 additions and 12 deletions

View File

@@ -57,6 +57,7 @@ func (m MarketNewsApi) TelegraphList(crawlTimeOut int64) *[]models.Telegraph {
dataTime := time.Unix(ctime, 0).Local()
logger.SugaredLogger.Debugf("dataTime: %s", dataTime)
telegraph := models.Telegraph{
Title: news["title"].(string),
Content: news["content"].(string),
Time: dataTime.Format("15:04:05"),
DataTime: &dataTime,

View File

@@ -6,11 +6,13 @@ import (
"go-stock/backend/logger"
"go-stock/backend/models"
"go-stock/backend/util"
"path/filepath"
"strings"
"testing"
"github.com/coocood/freecache"
"github.com/duke-git/lancet/v2/random"
"github.com/duke-git/lancet/v2/strutil"
"github.com/go-resty/resty/v2"
"github.com/tidwall/gjson"
)
@@ -274,15 +276,18 @@ func TestProxy(t *testing.T) {
}
func TestNtfy(t *testing.T) {
attach := "https://go-stock.sparkmemory.top/%E5%88%86%E6%9E%90%E6%8A%A5%E5%91%8A/2025/12/09/%E5%B8%82%E5%9C%BA%E8%B5%84%E8%AE%AF[%E5%B8%82%E5%9C%BA%E8%B5%84%E8%AE%AF]-(2025-12-09)AI%E5%88%86%E6%9E%90%E7%BB%93%E6%9E%9C.md"
post, err := resty.New().SetBaseURL("https://go-stock.sparkmemory.top:16667").R().
SetHeader("Content-Type", "text/markdown").
SetHeader("Filename", "投资分析报告.md").
SetHeader("Attach", attach).
SetBody("分析报告").Post("/go-stock")
if err != nil {
logger.SugaredLogger.Error(err)
return
}
logger.SugaredLogger.Debugf("value: %s", post.String())
//attach := "http://go-stock.sparkmemory.top/%E5%88%86%E6%9E%90%E6%8A%A5%E5%91%8A/%E8%B5%84%E9%87%91%E6%B5%81%E5%90%91/2025-12/AI%EF%BC%9A%E5%B8%82%E5%9C%BA%E5%88%86%E6%9E%90%E6%8A%A5%E5%91%8A-[2025.12.11_12.02.01].html"
//post, err := resty.New().SetBaseURL("https://go-stock.sparkmemory.top:16667").R().
// SetHeader("Filename", "AI市场分析报告-[2025.12.11_12.02.01].html").
// SetHeader("Icon", "https://go-stock.sparkmemory.top/appicon.png").
// SetHeader("Attach", attach).
// SetBody("AI市场分析报告-[2025.12.11_12.02.01]").Post("/go-stock")
//if err != nil {
// logger.SugaredLogger.Error(err)
// return
//}
//logger.SugaredLogger.Debugf("value: %s", post.String())
logger.SugaredLogger.Debugf("value: %s", filepath.Base("https://go-stock.sparkmemory.top/%E5%88%86%E6%9E%90%E6%8A%A5%E5%91%8A/2025/12/11/%E5%B8%82%E5%9C%BA%E8%B5%84%E8%AE%AF[%E5%B8%82%E5%9C%BA%E8%B5%84%E8%AE%AF]-(2025-12-11)AI%E5%88%86%E6%9E%90%E7%BB%93%E6%9E%9C_20251211131509.html"))
logger.SugaredLogger.Debugf("value: %s", strutil.After("/data/go-stock-site/docs/分析报告/2025/12/09/市场资讯[市场资讯]-(2025-12-09)AI分析结果.md", "/data/go-stock-site/docs/"))
}

View File

@@ -58,6 +58,13 @@ var OFFICIAL_STATEMENT string
var BuildKey string
func main() {
defer func() {
if r := recover(); r != nil {
log.SugaredLogger.Error("panic: ", r)
log.SugaredLogger.Error("stack: ", string(debug.Stack()))
}
}()
checkDir("data")
db.Init("")
data.InitAnalyzeSentiment()
@@ -70,7 +77,7 @@ func main() {
log.SugaredLogger.Info("starting...")
log.SugaredLogger.Infof("version: %s commit: %s", Version, VersionCommit)
log.SugaredLogger.Infof("build key: %s", BuildKey)
//log.SugaredLogger.Infof("build key: %s", BuildKey)
// Create an instance of the app structure
app := NewApp()