|
@@ -158,6 +158,9 @@ func (this *MobileResearchController) ArticleNewList() {
|
|
|
|
|
|
// @Title KOL榜列表
|
|
|
// @Description KOL榜列表接口
|
|
|
+// @Param PageSize query int true "每页数据条数"
|
|
|
+// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
|
+// @Param ThemeType query int true "主题类型,1关注度、2更新时间 "
|
|
|
// @Success 200 {object} models.DepartmentListResp
|
|
|
// @router /kolList [get]
|
|
|
func (this *MobileResearchController) KolList() {
|
|
@@ -172,7 +175,32 @@ func (this *MobileResearchController) KolList() {
|
|
|
br.Ret = 408
|
|
|
return
|
|
|
}
|
|
|
- list, err := models.GetDepartmentList(user.UserId)
|
|
|
+ themeType, _ := this.GetInt("ThemeType")
|
|
|
+ pageSize, _ := this.GetInt("PageSize")
|
|
|
+ currentIndex, _ := this.GetInt("CurrentIndex")
|
|
|
+ var startSize int
|
|
|
+ if pageSize <= 0 {
|
|
|
+ pageSize = utils.PageSize15
|
|
|
+ }
|
|
|
+ if currentIndex <= 0 {
|
|
|
+ currentIndex = 1
|
|
|
+ }
|
|
|
+ startSize = utils.StartIndex(currentIndex, pageSize)
|
|
|
+
|
|
|
+ total, err := models.GetDepartmentlistCount("")
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var condition string
|
|
|
+ if themeType != 2 {
|
|
|
+ condition = `ORDER BY fllow_num DESC `
|
|
|
+ } else {
|
|
|
+ condition = `ORDER BY publish_date DESC `
|
|
|
+ }
|
|
|
+
|
|
|
+ list, err := models.GetDepartmentList(condition, user.UserId, startSize, pageSize)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取信息失败"
|
|
|
br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
|
|
@@ -189,6 +217,7 @@ func (this *MobileResearchController) KolList() {
|
|
|
if v.FllowNum > 0 {
|
|
|
list[k].IsFollow = true
|
|
|
}
|
|
|
+ list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
|
|
|
for _, v2 := range listIndustrial {
|
|
|
if v2.DepartmentId == v.DepartmentId {
|
|
|
if departmentMap["D"+strconv.Itoa(v2.DepartmentId)+"In"+strconv.Itoa(v2.IndustrialManagementId)] == "" && len(list[k].List) < 4 {
|
|
@@ -199,6 +228,8 @@ func (this *MobileResearchController) KolList() {
|
|
|
}
|
|
|
}
|
|
|
resp := new(models.DepartmentListResp)
|
|
|
+ page := paging.GetPaging(currentIndex, pageSize, total)
|
|
|
+ resp.Paging = page
|
|
|
resp.List = list
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
@@ -427,3 +458,133 @@ func (this *MobileResearchController) ThemeDetail() {
|
|
|
br.Msg = "获取成功"
|
|
|
br.Data = resp
|
|
|
}
|
|
|
+
|
|
|
+// @Title 研选作者详情
|
|
|
+// @Description 研选作者详情接口
|
|
|
+// @Param DepartmentId query int true "作者ID"
|
|
|
+// @Success 200 {object} models.DepartmentDetailResp
|
|
|
+// @router /departmentId/detail [get]
|
|
|
+func (this *MobileResearchController) DepartmentIdDetail() {
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ pageSize, _ := this.GetInt("PageSize")
|
|
|
+ currentIndex, _ := this.GetInt("CurrentIndex")
|
|
|
+ var startSize int
|
|
|
+ if pageSize <= 0 {
|
|
|
+ pageSize = utils.PageSize20
|
|
|
+ }
|
|
|
+ if currentIndex <= 0 {
|
|
|
+ currentIndex = 1
|
|
|
+ }
|
|
|
+ startSize = paging.StartIndex(currentIndex, pageSize)
|
|
|
+ departmentId, _ := this.GetInt("DepartmentId")
|
|
|
+ if departmentId < 1 {
|
|
|
+ br.Msg = "请输入作者ID"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ articleTypeIds, err := services.GetYanXuanArticleTypeIds()
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if articleTypeIds != "" {
|
|
|
+ condition = ` AND a.article_type_id IN (` + articleTypeIds + `) `
|
|
|
+ } else {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "研选分类ID不能为空"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp := new(models.DepartmentDetailResp)
|
|
|
+ detail, err := models.GetDepartmentDetail(user.UserId, departmentId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取作者信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp.DepartmentId = detail.DepartmentId
|
|
|
+ resp.NickName = detail.NickName
|
|
|
+ resp.ImgUrl = detail.ImgUrl
|
|
|
+ resp.FllowNum = detail.FllowNum
|
|
|
+ resp.ArticleNum = detail.ArticleNum
|
|
|
+ resp.CollectNum = detail.CollectNum
|
|
|
+ if detail.MyFllowNum > 0 {
|
|
|
+ resp.IsFllow = true
|
|
|
+ }
|
|
|
+
|
|
|
+ condition = ` AND a.department_id = ` + strconv.Itoa(departmentId)
|
|
|
+ condition += ` AND a.article_type_id IN (` + articleTypeIds + `) `
|
|
|
+ total, err := models.GetArticleResearchCount(condition, pars)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "GetArticleResearchCount,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ list, err := models.GetArticleResearchList(condition, pars, startSize, pageSize, user.UserId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ list, err = services.HandleArticleCategoryImg(list)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //处理对应的文章类型标签按钮
|
|
|
+ nameMap, styleMap, err := services.GetArticleTypeMap()
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "GetArticleTypeMap Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ //resp := new(models.ArticleResearchListResp)
|
|
|
+ for _, v := range list {
|
|
|
+ item := models.ArticleResearchResp{
|
|
|
+ ArticleId: v.ArticleId,
|
|
|
+ ArticleTypeId: v.ArticleTypeId,
|
|
|
+ Title: v.Title,
|
|
|
+ PublishDate: v.PublishDate,
|
|
|
+ DepartmentId: v.DepartmentId,
|
|
|
+ NickName: v.NickName,
|
|
|
+ IsCollect: v.IsCollect,
|
|
|
+ Pv: v.Pv,
|
|
|
+ CollectNum: v.CollectNum,
|
|
|
+ Abstract: v.Abstract,
|
|
|
+ Annotation: v.Annotation,
|
|
|
+ ImgUrlPc: v.ImgUrlPc,
|
|
|
+ ArticleTypeName: nameMap[v.ArticleTypeId],
|
|
|
+ ButtonStyle: styleMap[v.ArticleTypeId],
|
|
|
+ List: v.List,
|
|
|
+ }
|
|
|
+ resp.List = append(resp.List, &item)
|
|
|
+ }
|
|
|
+
|
|
|
+ condition = ` AND a.department_id = ` + strconv.Itoa(departmentId)
|
|
|
+ listIndustrial, err := models.GetIndustrialManagementNewList(condition)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ page := paging.GetPaging(currentIndex, pageSize, total)
|
|
|
+ resp.ListIndustrial = listIndustrial
|
|
|
+ resp.Paging = page
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
+ br.Data = resp
|
|
|
+}
|