You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.2 KiB
57 lines
1.2 KiB
5 years ago
|
package topic
|
||
|
|
||
|
import (
|
||
|
"live/app/lib"
|
||
|
"live/app/lib/config"
|
||
|
"live/app/model/topic"
|
||
|
)
|
||
|
|
||
|
type Topic struct {
|
||
|
}
|
||
|
|
||
|
// @Title 根据关键字获取话题列表
|
||
|
func (t *Topic) List(keyword string, page lib.Page) (result *[]topic.Topic, count int64) {
|
||
|
result = &[]topic.Topic{}
|
||
|
|
||
|
topicModel := &topic.Topic{}
|
||
|
start := (page.GetPage() - 1) * page.GetLimit()
|
||
|
count = topicModel.GetlistCount(keyword)
|
||
|
if count <= int64(start) {
|
||
|
// 没有数据,不需要查库
|
||
|
return
|
||
|
}
|
||
|
*result = topicModel.Getlist(keyword, start, page.GetLimit())
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// @Title 获取热门话题
|
||
|
func (t *Topic) Hot() []topic.Topic {
|
||
|
topicModel := &topic.Topic{}
|
||
|
return topicModel.GetHotlist(config.Config.Section("topic").Key("hotCount").MustInt(10))
|
||
|
}
|
||
|
|
||
|
// @Title 根据ids获取列表
|
||
|
func (t *Topic) GetListByIds(topicIds []uint) (result *[]topic.Topic) {
|
||
|
result = &[]topic.Topic{}
|
||
|
if len(topicIds) == 0 {
|
||
|
return
|
||
|
}
|
||
|
|
||
|
topicModel := &topic.Topic{}
|
||
|
*result = topicModel.GetlistByIds(topicIds)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// @Title 根据id获取单条信息
|
||
|
func (t *Topic) GetInfo(topicId uint) (result topic.Topic) {
|
||
|
if topicId <= 0 {
|
||
|
return
|
||
|
}
|
||
|
topicModel := &topic.Topic{}
|
||
|
return topicModel.GetById(topicId)
|
||
|
}
|
||
|
|
||
|
func (t *Topic) ContentList(topicId uint) {
|
||
|
|
||
|
}
|