diff --git a/app/controller/live/live.go b/app/controller/live/live.go index aa52643..be1c936 100644 --- a/app/controller/live/live.go +++ b/app/controller/live/live.go @@ -608,6 +608,8 @@ type argsUserData struct { type replyUserData struct { Identifier string `json:"identifier"` + UserId uint `json:"userId"` + Follow uint `json:"follow"` Fans uint `json:"fans"` IsFollow int `json:"isFollow"` } @@ -655,6 +657,8 @@ func (l *Live) UserData(c *gin.Context) { Identifier: identifier, Fans: userDataMap[uint(spectatorId)].Fans, IsFollow: isFollow, + Follow: userDataMap[uint(spectatorId)].Follows, + UserId: userDataMap[uint(spectatorId)].UserId, }) } else { reply = append(reply, replyUserData{ diff --git a/app/controller/topic/topic.go b/app/controller/topic/topic.go index 237a145..8c39eff 100644 --- a/app/controller/topic/topic.go +++ b/app/controller/topic/topic.go @@ -52,12 +52,14 @@ func (t *Topic) Add(c *gin.Context) { back.Fail(c, "参数错误") return } - - if err := (&topic.Topic{}).Add(args.Title); err != nil { + topicId, err := (&topic.Topic{}).Add(args.Title) + if err != nil { back.Fail(c, err.Error()) return } - back.Suc(c, "操作成功", "") + back.Suc(c, "操作成功", gin.H{ + "topicId": topicId, + }) } // @Title 话题列表 diff --git a/app/logic/topic/topic.go b/app/logic/topic/topic.go index 6a1b457..aca9f20 100644 --- a/app/logic/topic/topic.go +++ b/app/logic/topic/topic.go @@ -27,27 +27,27 @@ func (t *Topic) List(keyword string, page lib.Page) (result *[]topic.Topic, coun } // @Title 添加话题 -func (t *Topic) Add(title string) error { +func (t *Topic) Add(title string) (uint, error) { topicModel := &topic.Topic{} topicInfo := topicModel.GetByTitle(title) - if topicInfo.Id >= 0 { - return nil + if topicInfo.Id > 0 { + return topicInfo.Id, nil } text, err := aliyun.Text.CheckText(title) if err != nil { - return err + return 0, err } if len(text.Politics) > 0 || len(text.Contraband) > 0 || len(text.Salacity) > 0 || len(text.Abuse) > 0 { - return errors.New("包含敏感词汇") + return 0, errors.New("包含敏感词汇") } data := topic.Topic{ Title: title, } topicModel.Create(&data) if data.Id <= 0 { - return errors.New("网络异常") + return 0, errors.New("网络异常") } - return nil + return data.Id, nil } // @Title 获取热门话题