hsun 2 years ago
parent
commit
52e2d5325e
2 changed files with 21 additions and 0 deletions
  1. 1 0
      models/tables/yb_bullet_chat/entity.go
  2. 20 0
      services/bullet_chat/bullet_chat.go

+ 1 - 0
models/tables/yb_bullet_chat/entity.go

@@ -10,6 +10,7 @@ type YbBulletChat struct {
 	Content     string    `gorm:"column:content;type:varchar(255);not null;default:''" json:"content"`                              // 弹幕内容
 	Seconds     float64   `gorm:"column:seconds;type:decimal(10,2);not null;default:0.00" json:"seconds"`                           // 时间点(秒)
 	Color       string    `gorm:"column:color;type:varchar(100);not null;default:''" json:"color"`                                  // 颜色#号
+	Title       string    `gorm:"column:title;type:varchar(255);not null;default:''" json:"title"`                                  // 标题(冗余)
 	Source      int       `gorm:"column:source;type:tinyint(4) unsigned;not null;default:0" json:"source"`                          // 来源:1-视频社区;2-线上路演
 	SourceAgent int       `gorm:"column:source_agent;type:tinyint(4) unsigned;not null;default:0" json:"sourceAgent"`               // 来源:1-小程序 2-小程序 PC 3-弘则研究公众号 4-Web PC
 	CreateTime  time.Time `gorm:"column:create_time;type:datetime" json:"createTime"`                                               // 创建时间

+ 20 - 0
services/bullet_chat/bullet_chat.go

@@ -4,7 +4,9 @@ import (
 	"encoding/json"
 	"errors"
 	"hongze/hongze_yb/models/tables/yb_bullet_chat"
+	"hongze/hongze_yb/models/tables/yb_community_video"
 	"hongze/hongze_yb/models/tables/yb_config"
+	"hongze/hongze_yb/models/tables/yb_road_video"
 	"math/rand"
 	"time"
 )
@@ -106,6 +108,23 @@ func CreateBulletChat(userId, primaryId, source, sourceAgent int, seconds float6
 		return
 	}
 
+	title := ""
+	if source == 1 {
+		vd, e := yb_community_video.GetItemById(primaryId)
+		if e != nil {
+			err = errors.New("获取视频失败, Err: " + e.Error())
+			return
+		}
+		title = vd.Title
+	} else {
+		rv, e := yb_road_video.GetItemById(primaryId)
+		if e != nil {
+			err = errors.New("获取路演视频失败, Err: " + e.Error())
+			return
+		}
+		title = rv.Title
+	}
+
 	nowTime := time.Now().Local()
 	bc := new(yb_bullet_chat.YbBulletChat)
 	bc.UserID = userId
@@ -113,6 +132,7 @@ func CreateBulletChat(userId, primaryId, source, sourceAgent int, seconds float6
 	bc.Content = content
 	bc.Seconds = seconds
 	bc.Color = color.Color
+	bc.Title = title
 	bc.Source = source
 	bc.SourceAgent = sourceAgent
 	bc.CreateTime = nowTime