|
@@ -2,6 +2,7 @@ package controllers
|
|
|
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
+ "github.com/rdlucklib/rdluck_tools/paging"
|
|
|
"hongze/hongze_clpt/models"
|
|
|
"hongze/hongze_clpt/services"
|
|
|
"hongze/hongze_clpt/utils"
|
|
@@ -20,7 +21,9 @@ type YanxuanSpecialNoLoginController struct {
|
|
|
|
|
|
// @Title 专栏列表
|
|
|
// @Description 专栏列表
|
|
|
-// @Param request body help_doc.AddHelpDocReq true "type json string"
|
|
|
+// @Param SpecialColumnId query int true "作者专栏ID"
|
|
|
+// @Param PageSize query int true "每页数据条数"
|
|
|
+// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
|
// @Success 200 {object} models.AddEnglishReportResp
|
|
|
// @router /list [get]
|
|
|
func (this *YanxuanSpecialNoLoginController) List() {
|
|
@@ -38,29 +41,38 @@ func (this *YanxuanSpecialNoLoginController) List() {
|
|
|
}
|
|
|
|
|
|
specialColumnId, _ := this.GetInt("SpecialColumnId", 0)
|
|
|
+ pageSize, _ := this.GetInt("PageSize")
|
|
|
+ currentIndex, _ := this.GetInt("CurrentIndex")
|
|
|
+
|
|
|
+ var startSize int
|
|
|
+ if pageSize <= 0 {
|
|
|
+ pageSize = utils.PageSize20
|
|
|
+ }
|
|
|
+ if currentIndex <= 0 {
|
|
|
+ currentIndex = 1
|
|
|
+ }
|
|
|
+ startSize = utils.StartIndex(currentIndex, pageSize)
|
|
|
+ resp := new(models.SpecialListResp)
|
|
|
var condition string
|
|
|
var pars []interface{}
|
|
|
|
|
|
- var specialUser *models.CygxYanxuanSpecialAuthorItem
|
|
|
- var err error
|
|
|
if specialColumnId > 0 {
|
|
|
condition += ` AND b.id = ? `
|
|
|
pars = append(pars, specialColumnId)
|
|
|
}
|
|
|
|
|
|
- specialUser, err = models.GetYanxuanSpecialAuthor(sysUser.UserId, sysUser.UserId)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ condition += ` AND a.status = 3 `
|
|
|
+ total, err := models.GetCygxYanxuanSpecialCount(condition, pars)
|
|
|
+ if err != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取失败, Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- condition += ` AND a.status = 3 `
|
|
|
-
|
|
|
- list, tmpErr := models.GetYanxuanSpecialList(sysUser.UserId, condition, pars)
|
|
|
- if tmpErr != nil {
|
|
|
+ list, err := models.GetYanxuanSpecialList(sysUser.UserId, condition, pars, startSize, pageSize)
|
|
|
+ if err != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
|
|
|
+ br.ErrMsg = "获取失败, Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
for _, v := range list {
|
|
@@ -114,13 +126,12 @@ func (this *YanxuanSpecialNoLoginController) List() {
|
|
|
v.TagList = []string{}
|
|
|
}
|
|
|
}
|
|
|
- resp := new(models.SpecialListResp)
|
|
|
-
|
|
|
- if specialUser != nil {
|
|
|
- resp.IsAuthor = true
|
|
|
- }
|
|
|
+ isAuthor, isImproveInformation := services.GetYanxuanSpecialAuthorInfo(sysUser) //用户是否没开通研选专栏以及,专栏信息是否完善
|
|
|
+ resp.IsAuthor = isAuthor
|
|
|
+ resp.IsImproveInformation = isImproveInformation
|
|
|
resp.List = list
|
|
|
-
|
|
|
+ page := paging.GetPaging(currentIndex, pageSize, total)
|
|
|
+ resp.Paging = page
|
|
|
br.Data = resp
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
@@ -164,18 +175,8 @@ func (this *YanxuanSpecialController) Detail() {
|
|
|
item.IsCollect = 1
|
|
|
}
|
|
|
|
|
|
- //industryTagList, tmpErr := models.GetYanxuanSpecialIndustry("")
|
|
|
- //if tmpErr != nil {
|
|
|
- // br.Msg = "获取失败"
|
|
|
- // br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
|
|
|
- // return
|
|
|
- //}
|
|
|
- //industryTagMap := make(map[string]int, 0)
|
|
|
- //for _, v := range industryTagList {
|
|
|
- // industryTagMap[v] = 1
|
|
|
- //}
|
|
|
-
|
|
|
var resp models.CygxYanxuanSpecialResp
|
|
|
+ resp.HasPermission = 1
|
|
|
resp.CygxYanxuanSpecialItem = *item
|
|
|
if item.DocUrl != "" {
|
|
|
var docs []models.Doc
|
|
@@ -212,6 +213,19 @@ func (this *YanxuanSpecialController) Detail() {
|
|
|
resp.IndustryTags = []string{}
|
|
|
}
|
|
|
|
|
|
+ var configCode string
|
|
|
+ //如果是研选的就推送给汪洋跟王芳,否则就推送给王芳
|
|
|
+ configCode = utils.TPL_MSG_WANG_FANG_WANG_YANG
|
|
|
+ cnf, err := models.GetConfigByCode(configCode)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败, Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if item.UserId != sysUser.UserId && item.Status != 3 && !strings.Contains(cnf.ConfigValue, sysUser.Mobile) {
|
|
|
+ resp.HasPermission = 2
|
|
|
+ }
|
|
|
+
|
|
|
go services.AddSpecialRecord(this.User, specialId)
|
|
|
|
|
|
br.Data = resp
|
|
@@ -603,7 +617,7 @@ func (this *YanxuanSpecialController) Center() {
|
|
|
condition += ` AND a.status = ? `
|
|
|
pars = append(pars, status)
|
|
|
|
|
|
- list, tmpErr := models.GetYanxuanSpecialList(sysUser.UserId, condition, pars)
|
|
|
+ list, tmpErr := models.GetYanxuanSpecialList(sysUser.UserId, condition, pars, 0, 0)
|
|
|
if tmpErr != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
|
|
@@ -877,7 +891,8 @@ func (this *YanxuanSpecialController) Cancel() {
|
|
|
|
|
|
// @Title 作者列表
|
|
|
// @Description 作者列表
|
|
|
-// @Param request body help_doc.AddHelpDocReq true "type json string"
|
|
|
+// @Param PageSize query int true "每页数据条数"
|
|
|
+// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
|
// @Success 200 {object} models.AddEnglishReportResp
|
|
|
// @router /author/list [get]
|
|
|
func (this *YanxuanSpecialNoLoginController) AuthorList() {
|
|
@@ -893,42 +908,52 @@ func (this *YanxuanSpecialNoLoginController) AuthorList() {
|
|
|
br.Ret = 408
|
|
|
return
|
|
|
}
|
|
|
- var specialUser *models.CygxYanxuanSpecialAuthorItem
|
|
|
- var err error
|
|
|
+ pageSize, _ := this.GetInt("PageSize")
|
|
|
+ currentIndex, _ := this.GetInt("CurrentIndex")
|
|
|
|
|
|
- specialUser, err = models.GetYanxuanSpecialAuthor(sysUser.UserId, sysUser.UserId)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ var startSize int
|
|
|
+ if pageSize <= 0 {
|
|
|
+ pageSize = utils.PageSize20
|
|
|
+ }
|
|
|
+ if currentIndex <= 0 {
|
|
|
+ currentIndex = 1
|
|
|
+ }
|
|
|
+ startSize = utils.StartIndex(currentIndex, pageSize)
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ condition += ` AND a.nick_name <> '' `
|
|
|
+
|
|
|
+ total, err := models.GetCygxYanxuanSpecialAuthorCount(condition, pars)
|
|
|
+ if err != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取失败, Err:" + err.Error()
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- list, tmpErr := models.GetYanxuanSpecialAuthorList()
|
|
|
+ condition += ` ORDER BY latest_publish_time DESC`
|
|
|
+ list, tmpErr := models.GetYanxuanSpecialAuthorList(condition, pars, startSize, pageSize)
|
|
|
if tmpErr != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- resp := new(models.SpecialAuthorListResp)
|
|
|
-
|
|
|
+ var userIds []int
|
|
|
for _, v := range list {
|
|
|
v.LatestPublishDate = v.LatestPublishTime.Format(utils.FormatDate) + "更新"
|
|
|
- if v.UserId == sysUser.UserId {
|
|
|
- resp.List = append(resp.List, v)
|
|
|
- }
|
|
|
+ userIds = append(userIds, v.UserId)
|
|
|
}
|
|
|
|
|
|
+ bestNew := services.GetBestNewYanxuanSpecialByUserId(userIds)
|
|
|
for _, v := range list {
|
|
|
- if v.UserId != sysUser.UserId {
|
|
|
- resp.List = append(resp.List, v)
|
|
|
- }
|
|
|
+ v.YanxuanSpecialCenter = bestNew[v.UserId]
|
|
|
}
|
|
|
-
|
|
|
- if specialUser != nil {
|
|
|
- resp.IsAuthor = true
|
|
|
- }
|
|
|
-
|
|
|
+ resp := new(models.SpecialAuthorListResp)
|
|
|
+ isAuthor, isImproveInformation := services.GetYanxuanSpecialAuthorInfo(sysUser) //用户是否没开通研选专栏以及,专栏信息是否完善
|
|
|
+ resp.IsAuthor = isAuthor
|
|
|
+ resp.IsImproveInformation = isImproveInformation
|
|
|
+ page := paging.GetPaging(currentIndex, pageSize, total)
|
|
|
+ resp.List = list
|
|
|
+ resp.Paging = page
|
|
|
br.Data = resp
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|