fix:修复命名错误
This commit is contained in:
@@ -539,7 +539,7 @@ func (f *FeedService) buildFeedVideos(ctx context.Context, videos []*video.Video
|
|||||||
func buildOrderedResult(orderedIDs []uint, dataMap map[uint]*video.Video) []*video.Video {
|
func buildOrderedResult(orderedIDs []uint, dataMap map[uint]*video.Video) []*video.Video {
|
||||||
res := make([]*video.Video, 0, len(orderedIDs))
|
res := make([]*video.Video, 0, len(orderedIDs))
|
||||||
for _, id := range orderedIDs {
|
for _, id := range orderedIDs {
|
||||||
if v, exit := dataMap[id]; exit && v != nil {
|
if v, exits := dataMap[id]; exits && v != nil {
|
||||||
res = append(res, v)
|
res = append(res, v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,15 +23,15 @@ func NewRabbitMQ(cfg *config.RabbitMQConfig) (*RabbitMQ, error) {
|
|||||||
return nil, errors.New("rabbitmq config is nil")
|
return nil, errors.New("rabbitmq config is nil")
|
||||||
}
|
}
|
||||||
url := "amqp://" + cfg.Username + ":" + cfg.Password + "@" + cfg.Host + ":" + strconv.Itoa(cfg.Port) + "/"
|
url := "amqp://" + cfg.Username + ":" + cfg.Password + "@" + cfg.Host + ":" + strconv.Itoa(cfg.Port) + "/"
|
||||||
Conn, err := amqp.Dial(url)
|
conn, err := amqp.Dial(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
Ch, err := Conn.Channel()
|
ch, err := conn.Channel()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &RabbitMQ{Conn: Conn, Ch: Ch}, nil
|
return &RabbitMQ{Conn: conn, Ch: ch}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *RabbitMQ) Close() error {
|
func (r *RabbitMQ) Close() error {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ const (
|
|||||||
|
|
||||||
type TimelineEvent struct {
|
type TimelineEvent struct {
|
||||||
EventID string `json:"event_id"`
|
EventID string `json:"event_id"`
|
||||||
ViedoID uint `json:"video_id"`
|
VideoID uint `json:"video_id"`
|
||||||
CreateTime int64 `json:"create_time"`
|
CreateTime int64 `json:"create_time"`
|
||||||
OccurredAt time.Time `json:"occurred_at"`
|
OccurredAt time.Time `json:"occurred_at"`
|
||||||
}
|
}
|
||||||
@@ -36,7 +36,7 @@ func NewTimelineMQ(base *RabbitMQ) (*TimelineMQ, error) {
|
|||||||
|
|
||||||
func (t *TimelineMQ) PublishVideo(ctx context.Context, videoID uint, createTime time.Time) error {
|
func (t *TimelineMQ) PublishVideo(ctx context.Context, videoID uint, createTime time.Time) error {
|
||||||
if t == nil || t.RabbitMQ == nil {
|
if t == nil || t.RabbitMQ == nil {
|
||||||
return errors.New("timelike mq is not initialized")
|
return errors.New("timeline mq is not initialized")
|
||||||
}
|
}
|
||||||
if videoID == 0 {
|
if videoID == 0 {
|
||||||
return errors.New("videoID are required")
|
return errors.New("videoID are required")
|
||||||
@@ -47,7 +47,7 @@ func (t *TimelineMQ) PublishVideo(ctx context.Context, videoID uint, createTime
|
|||||||
}
|
}
|
||||||
timeline := TimelineEvent{
|
timeline := TimelineEvent{
|
||||||
EventID: id,
|
EventID: id,
|
||||||
ViedoID: videoID,
|
VideoID: videoID,
|
||||||
CreateTime: createTime.UnixMilli(),
|
CreateTime: createTime.UnixMilli(),
|
||||||
OccurredAt: time.Now(),
|
OccurredAt: time.Now(),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,14 +50,14 @@ func (vs *VideoService) Publish(ctx context.Context, video *Video) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
Msg := OutboxMsg{
|
msg := OutboxMsg{
|
||||||
VideoID: video.ID,
|
VideoID: video.ID,
|
||||||
EventType: "video_published",
|
EventType: "video_published",
|
||||||
Status: "pending",
|
Status: "pending",
|
||||||
CreateTime: video.CreateTime,
|
CreateTime: video.CreateTime,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := tx.Create(Msg).Error; err != nil {
|
if err := tx.Create(&msg).Error; err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user