|
@@ -4,7 +4,9 @@ import (
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
"hongze/hongze_cygx/models"
|
|
|
+ "hongze/hongze_cygx/services"
|
|
|
"hongze/hongze_cygx/utils"
|
|
|
+ "rdluck_tools/paging"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
"time"
|
|
@@ -175,6 +177,13 @@ func (this *ReportController) ArticleCategoryList() {
|
|
|
this.Data["json"] = br
|
|
|
this.ServeJSON()
|
|
|
}()
|
|
|
+ user := this.User
|
|
|
+ if user == nil {
|
|
|
+ br.Msg = "请重新登录"
|
|
|
+ br.Ret = 408
|
|
|
+ return
|
|
|
+ }
|
|
|
+ uid := user.UserId
|
|
|
industrialManagementId, _ := this.GetInt("IndustrialManagementId")
|
|
|
if industrialManagementId < 1 {
|
|
|
br.Msg = "请输入分类ID"
|
|
@@ -186,6 +195,18 @@ func (this *ReportController) ArticleCategoryList() {
|
|
|
br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ for k, v := range list {
|
|
|
+ recordCount, err := models.IndustrialUserRecordArticleCount(uid, industrialManagementId, v.CategoryId)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if recordCount == 0 {
|
|
|
+ list[k].IsRed = true
|
|
|
+ }
|
|
|
+ }
|
|
|
detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取信息失败"
|
|
@@ -196,6 +217,89 @@ func (this *ReportController) ArticleCategoryList() {
|
|
|
resp.List = list
|
|
|
resp.LayoutTime = utils.TimeRemoveHms(detail.LayoutTime)
|
|
|
resp.IndustryName = detail.IndustryName
|
|
|
+ resp.IndustrialManagementId = industrialManagementId
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
+ br.Data = resp
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 产业文章列表接口
|
|
|
+// @Description 获取产业文章列表接口
|
|
|
+// @Param PageSize query int true "每页数据条数"
|
|
|
+// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
|
+// @Param CategoryId query int true "分类ID"
|
|
|
+// @Param IndustrialManagementId query int true "产业ID"
|
|
|
+// @Success 200 {object} models.TacticsListResp
|
|
|
+// @router /industry/ArticleList [get]
|
|
|
+func (this *ReportController) List() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ user := this.User
|
|
|
+ if user == nil {
|
|
|
+ br.Msg = "请重新登录"
|
|
|
+ br.Ret = 408
|
|
|
+ return
|
|
|
+ }
|
|
|
+ uid := user.UserId
|
|
|
+ pageSize, _ := this.GetInt("PageSize")
|
|
|
+ currentIndex, _ := this.GetInt("CurrentIndex")
|
|
|
+ categoryId, _ := this.GetInt("CategoryId")
|
|
|
+ industrialManagementId, _ := this.GetInt("IndustrialManagementId")
|
|
|
+
|
|
|
+ var startSize int
|
|
|
+ if pageSize <= 0 {
|
|
|
+ pageSize = utils.PageSize20
|
|
|
+ }
|
|
|
+ if currentIndex <= 0 {
|
|
|
+ currentIndex = 1
|
|
|
+ }
|
|
|
+ startSize = paging.StartIndex(currentIndex, pageSize)
|
|
|
+ var pars []interface{}
|
|
|
+ var total int
|
|
|
+ resp := new(models.TacticsListResp)
|
|
|
+ page := paging.GetPaging(currentIndex, pageSize, total)
|
|
|
+
|
|
|
+ if categoryId < 1 {
|
|
|
+ br.Msg = "请输入分类ID"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if industrialManagementId < 1 {
|
|
|
+ br.Msg = "请输入产业ID"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ total, err := models.GetReportIndustrialCount(categoryId, industrialManagementId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.Msg = "获取帖子总数失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ page = paging.GetPaging(currentIndex, pageSize, total)
|
|
|
+ list, err := models.GetReportIndustrialList(pars, categoryId, industrialManagementId, uid, startSize, pageSize)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.Msg = "获取帖子数据失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ lenList := len(list)
|
|
|
+ for i := 0; i < lenList; i++ {
|
|
|
+ item := list[i]
|
|
|
+ list[i].Body, _ = services.GetReportContentTextSub(item.Body)
|
|
|
+ //list[i].Abstract = html.UnescapeString(item.Abstract)
|
|
|
+ list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
|
|
|
+ }
|
|
|
+
|
|
|
+ for k, v := range list {
|
|
|
+ if v.Readnum == 0 {
|
|
|
+ list[k].IsRed = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resp.List = list
|
|
|
+ resp.Paging = page
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
|
br.Msg = "获取成功"
|