|
@@ -23,6 +23,7 @@ type MobileReportBillboardController struct {
|
|
|
// @Title 阅读飙升榜/报告收藏榜
|
|
|
// @Description 获取阅读飙升榜/报告收藏榜接口
|
|
|
// @Param ChartPermissionId query int false "分类ID"
|
|
|
+// @Param PageSize query int true "每页数据条数"
|
|
|
// @Param Source query int true "来源 1:阅读飙升 ,2:报告收藏"
|
|
|
// @Success 200 {object} models.ReportBillboardListResp
|
|
|
// @router /list [get]
|
|
@@ -39,41 +40,58 @@ func (this *MobileReportBillboardController) ReadList() {
|
|
|
return
|
|
|
}
|
|
|
chartPermissionId, _ := this.GetInt("ChartPermissionId")
|
|
|
+ pageSize, _ := this.GetInt("PageSize")
|
|
|
source, _ := this.GetInt("Source")
|
|
|
sourceArr := []int{1, 2}
|
|
|
if !utils.InArrayByInt(sourceArr, source) {
|
|
|
br.Msg = "来源有误"
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- topNum := utils.PageSize15
|
|
|
+ var topNum int
|
|
|
+ if pageSize == 0 {
|
|
|
+ topNum = utils.PageSize15
|
|
|
+ } else {
|
|
|
+ topNum = pageSize
|
|
|
+ }
|
|
|
list := make([]*models.ArticleListResp, 0)
|
|
|
-
|
|
|
// 阅读飙升榜
|
|
|
if source == 1 {
|
|
|
var topCond string
|
|
|
var topPars []interface{}
|
|
|
- if chartPermissionId > 0 {
|
|
|
- categoryId, err := models.GetCategoryId(chartPermissionId)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- br.Msg = "获取信息失败"
|
|
|
- br.ErrMsg = "获取分类权限信息失败,Err:" + err.Error()
|
|
|
+ if chartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
|
|
|
+ nowTime := time.Now().Local()
|
|
|
+ startTime := nowTime.AddDate(0, -1, 0)
|
|
|
+ endTime := nowTime.AddDate(0, 0, -1)
|
|
|
+ topCond += ` AND l.create_time BETWEEN ? AND ? AND a.article_id > ? `
|
|
|
+ topPars = append(topPars, startTime, endTime, utils.SummaryArticleId)
|
|
|
+ topList, e := models.GetTopReadRecordArticleListByConditionYx(topNum, topCond, topPars)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取报告阅读增量排行榜失败, Err:" + e.Error()
|
|
|
return
|
|
|
}
|
|
|
- if categoryId != "" {
|
|
|
- topCond += ` AND a.category_id IN (` + categoryId + `)`
|
|
|
+ list = topList
|
|
|
+ } else {
|
|
|
+ if chartPermissionId > 0 {
|
|
|
+ categoryId, err := models.GetCategoryId(chartPermissionId)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取分类权限信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if categoryId != "" {
|
|
|
+ topCond += ` AND a.category_id IN (` + categoryId + `)`
|
|
|
+ }
|
|
|
}
|
|
|
+ topList, e := models.GetTopReadRecordArticleListByCondition(topNum, topCond, topPars)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取报告阅读增量排行榜失败, Err:" + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ list = topList
|
|
|
}
|
|
|
- topList, e := models.GetTopReadRecordArticleListByCondition(topNum, topCond, topPars)
|
|
|
- if e != nil {
|
|
|
- br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取报告阅读增量排行榜失败, Err:" + e.Error()
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- list = topList
|
|
|
}
|
|
|
-
|
|
|
// 报告收藏榜
|
|
|
if source == 2 {
|
|
|
var collectCond string
|
|
@@ -95,46 +113,22 @@ func (this *MobileReportBillboardController) ReadList() {
|
|
|
endTime := nowTime.AddDate(0, 0, -1)
|
|
|
collectCond += ` AND ac.create_time BETWEEN ? AND ?`
|
|
|
collectPars = append(collectPars, startTime, endTime)
|
|
|
- collectList, e := models.GetReportCollectionBillboardList(topNum, collectPars, collectCond)
|
|
|
- if e != nil {
|
|
|
- br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取报告收藏排行榜失败, Err:" + e.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- list = collectList
|
|
|
- }
|
|
|
- articleIds := make([]int, 0)
|
|
|
- for i := range list {
|
|
|
- articleIds = append(articleIds, list[i].ArticleId)
|
|
|
- }
|
|
|
- // 报告关联产业信息
|
|
|
- industryMap := make(map[int][]*models.IndustrialManagementIdInt, 0)
|
|
|
- if len(articleIds) > 0 {
|
|
|
- var industryCond string
|
|
|
- var industryPars []interface{}
|
|
|
- industryCond += ` AND mg.article_id IN (` + utils.GetOrmInReplace(len(articleIds)) + `)`
|
|
|
- industryPars = append(industryPars, articleIds)
|
|
|
- industryList, e := models.GetIndustrialListByarticleId(industryPars, industryCond)
|
|
|
- if e != nil {
|
|
|
- br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取报告关联的产业信息失败, Err: " + e.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- for i := range industryList {
|
|
|
- v := industryList[i]
|
|
|
- industryMap[v.ArticleId] = append(industryMap[v.ArticleId], &models.IndustrialManagementIdInt{
|
|
|
- ArticleId: v.ArticleId,
|
|
|
- IndustrialManagementId: v.IndustrialManagementId,
|
|
|
- IndustryName: v.IndustryName,
|
|
|
- ChartPermissionId: v.ChartPermissionId,
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- for k, v := range list {
|
|
|
- if len(industryMap[v.ArticleId]) > 0 {
|
|
|
- list[k].List = industryMap[v.ArticleId]
|
|
|
+ if chartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
|
|
|
+ topList, e := models.GetReportCollectionBillboardListYx(topNum, collectPars, collectCond)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取报告阅读增量排行榜失败, Err:" + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ list = topList
|
|
|
} else {
|
|
|
- list[k].List = make([]*models.IndustrialManagementIdInt, 0)
|
|
|
+ collectList, e := models.GetReportCollectionBillboardList(topNum, collectPars, collectCond)
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取报告收藏排行榜失败, Err:" + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ list = collectList
|
|
|
}
|
|
|
}
|
|
|
var err error
|