Skip to content

Commit c4af779

Browse files
committed
refactor(app):将syncNews函数改为方法并集成情感分析
- 将syncNews函数转换为App结构体的方法 - 在新闻同步逻辑中集成情感分析功能 - 添加新闻推送功能到同步流程中 - 修复VIP用户新闻同步的调用方式
1 parent 8236adb commit c4af779

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

app.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ func (a *App) CheckUpdate(flag int) {
261261
if _, vipLevel, ok := a.isVip(sponsorCode, "", releaseVersion); ok {
262262
level, _ := convertor.ToInt(vipLevel)
263263
if level >= 2 {
264-
go syncNews()
264+
go a.syncNews()
265265
}
266266
}
267267

@@ -409,7 +409,7 @@ func (a *App) isVip(sponsorCode string, downloadUrl string, releaseVersion *mode
409409
return downloadUrl, vipLevel, isVip
410410
}
411411

412-
func syncNews() {
412+
func (a *App) syncNews() {
413413
defer PanicHandler()
414414
client := resty.New()
415415
url := fmt.Sprintf("http://go-stock.sparkmemory.top:16666/FinancialNews/json?since=%d", time.Now().Add(-24*time.Hour).Unix())
@@ -443,7 +443,7 @@ func syncNews() {
443443
IsRed: isRed,
444444
Time: dataTime.Format("15:04:05"),
445445
Source: GetSource(news.Tags),
446-
SentimentResult: "",
446+
SentimentResult: data.AnalyzeSentiment(news.Message).Description,
447447
}
448448
cnt := int64(0)
449449
if telegraph.Title == "" {
@@ -453,6 +453,7 @@ func syncNews() {
453453
}
454454
if cnt == 0 {
455455
db.Dao.Model(telegraph).Create(&telegraph)
456+
a.NewsPush(&[]models.Telegraph{*telegraph})
456457
}
457458
}
458459
}

0 commit comments

Comments
 (0)