|
|
|
@ -2,9 +2,11 @@ package topic
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
"live/app/common"
|
|
|
|
|
"live/app/lib"
|
|
|
|
|
"live/app/lib/back"
|
|
|
|
|
"live/app/lib/tools"
|
|
|
|
|
"live/app/logic/short"
|
|
|
|
|
"live/app/logic/topic"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
@ -40,3 +42,59 @@ func (t *Topic) Hot(c *gin.Context) {
|
|
|
|
|
list := (&topic.Topic{}).Hot()
|
|
|
|
|
back.Suc(c, "操作成功", list)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type argsInfo struct {
|
|
|
|
|
TopicId uint `json:"topicId" form:"topicId"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @Title 获取单条详情
|
|
|
|
|
func (t *Topic) Info(c *gin.Context) {
|
|
|
|
|
uid := common.GetUserId(c)
|
|
|
|
|
args := argsInfo{}
|
|
|
|
|
if err := tools.ParseParams(&args, c); err != nil {
|
|
|
|
|
back.Fail(c, err.Error())
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if args.TopicId <= 0 {
|
|
|
|
|
back.Fail(c, "参数不全")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
info := (&topic.Topic{}).GetInfo(uid, args.TopicId)
|
|
|
|
|
if info.Id > 0 {
|
|
|
|
|
back.Suc(c, "操作成功", info)
|
|
|
|
|
return
|
|
|
|
|
} else {
|
|
|
|
|
back.Fail(c, "未查询到数据")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type argsTopicContentList struct {
|
|
|
|
|
TopicId uint `json:"topicId" form:"topicId"`
|
|
|
|
|
lib.Page
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @Title 话题内容列表
|
|
|
|
|
func (t *Topic) ContentList(c *gin.Context) {
|
|
|
|
|
uid := common.GetUserId(c)
|
|
|
|
|
args := argsTopicContentList{}
|
|
|
|
|
if err := tools.ParseParams(&args, c); err != nil {
|
|
|
|
|
back.Fail(c, err.Error())
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if args.TopicId <= 0 {
|
|
|
|
|
back.Fail(c, "参数不全")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
list, count, err := (&short.Short{}).ListByTopicId(uid, args.TopicId, args.Page)
|
|
|
|
|
if err != nil {
|
|
|
|
|
back.Err(c, err.Error())
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
back.Suc(c, "操作成功", gin.H{
|
|
|
|
|
"list": list,
|
|
|
|
|
"total": count,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|