新增了详情页排名计算
This commit is contained in:
@@ -109,18 +109,33 @@ func (r *Article) GetArticle(c *gin.Context) {
|
||||
|
||||
article.ArticleAuthor = articleAuthors
|
||||
|
||||
// 获取排名
|
||||
rank, _ := articleDao.GetArticleRank(article.ArticleId)
|
||||
|
||||
// 处理返回值
|
||||
g := dto.GetArticleDto(article)
|
||||
|
||||
// 获取排名开关限制
|
||||
systemConfigDao := dao.SystemConfigDao{}
|
||||
systemConfig, err := systemConfigDao.GetSystemConfigById(1)
|
||||
if err != nil {
|
||||
responses.OkWithData(nil, c)
|
||||
return
|
||||
}
|
||||
|
||||
if systemConfig.IsDisplayRank == 1 {
|
||||
// 获取大于某一投票数的文章
|
||||
maps := make(map[string]interface{})
|
||||
maps["article_status"] = 1
|
||||
articles, err := articleDao.GetArticleListGtVoteNum(maps, article.VoteNum)
|
||||
if err == nil {
|
||||
rank := len(articles) + 1
|
||||
|
||||
// 加载数据-作者排名
|
||||
g.LoadRank(rank)
|
||||
}
|
||||
}
|
||||
|
||||
// 加载数据-作者
|
||||
g.LoadArticleAuthor(article.ArticleAuthor)
|
||||
|
||||
// 加载数据-作者排名
|
||||
g.LoadRank(rank)
|
||||
|
||||
// 检测用户今日是否投票
|
||||
userId := c.GetInt64("UserId")
|
||||
if userId != 0 {
|
||||
|
||||
+21
-6
@@ -109,18 +109,33 @@ func (r *Video) GetVideo(c *gin.Context) {
|
||||
|
||||
video.VideoAuthor = videoAuthors
|
||||
|
||||
// 获取排名
|
||||
rank, _ := videoDao.GetVideoRank(video.VideoId)
|
||||
|
||||
// 处理返回值
|
||||
g := dto.GetVideoDto(video)
|
||||
|
||||
// 获取排名开关限制
|
||||
systemConfigDao := dao.SystemConfigDao{}
|
||||
systemConfig, err := systemConfigDao.GetSystemConfigById(1)
|
||||
if err != nil {
|
||||
responses.OkWithData(nil, c)
|
||||
return
|
||||
}
|
||||
|
||||
if systemConfig.IsDisplayRank == 1 {
|
||||
// 获取大于某一投票数的文章
|
||||
maps := make(map[string]interface{})
|
||||
maps["article_status"] = 1
|
||||
videos, err := videoDao.GetVideoListGtVoteNum(maps, video.VoteNum)
|
||||
if err == nil {
|
||||
rank := len(videos) + 1
|
||||
|
||||
// 加载数据-作者排名
|
||||
g.LoadRank(rank)
|
||||
}
|
||||
}
|
||||
|
||||
// 加载数据-作者
|
||||
g.LoadVideoAuthor(video.VideoAuthor)
|
||||
|
||||
// 加载数据-作者排名
|
||||
g.LoadRank(rank)
|
||||
|
||||
// 检测用户今日是否投票
|
||||
userId := c.GetInt64("UserId")
|
||||
if userId != 0 {
|
||||
|
||||
Reference in New Issue
Block a user