|
@@ -2,9 +2,11 @@ package controllers
|
|
|
|
|
|
import (
|
|
import (
|
|
"encoding/json"
|
|
"encoding/json"
|
|
|
|
+ "github.com/rdlucklib/rdluck_tools/paging"
|
|
"hongze/hongze_cygx/models"
|
|
"hongze/hongze_cygx/models"
|
|
"hongze/hongze_cygx/services"
|
|
"hongze/hongze_cygx/services"
|
|
"hongze/hongze_cygx/utils"
|
|
"hongze/hongze_cygx/utils"
|
|
|
|
+ "strings"
|
|
"time"
|
|
"time"
|
|
)
|
|
)
|
|
|
|
|
|
@@ -14,8 +16,10 @@ type YanxuanSpecialController struct {
|
|
|
|
|
|
// @Title 专栏列表
|
|
// @Title 专栏列表
|
|
// @Description 专栏列表
|
|
// @Description 专栏列表
|
|
-// @Param request body help_doc.AddHelpDocReq true "type json string"
|
|
|
|
-// @Success 200 {object} models.AddEnglishReportResp
|
|
|
|
|
|
+// @Param UserId query int true "用户ID"
|
|
|
|
+// @Param PageSize query int true "每页数据条数"
|
|
|
|
+// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
|
|
+// @Success 200 {object} models.SpecialListResp
|
|
// @router /list [get]
|
|
// @router /list [get]
|
|
func (this *YanxuanSpecialController) List() {
|
|
func (this *YanxuanSpecialController) List() {
|
|
br := new(models.BaseResponse).Init()
|
|
br := new(models.BaseResponse).Init()
|
|
@@ -30,33 +34,38 @@ func (this *YanxuanSpecialController) List() {
|
|
br.Ret = 408
|
|
br.Ret = 408
|
|
return
|
|
return
|
|
}
|
|
}
|
|
-
|
|
|
|
userId, _ := this.GetInt("UserId", 0)
|
|
userId, _ := this.GetInt("UserId", 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 condition string
|
|
var pars []interface{}
|
|
var pars []interface{}
|
|
|
|
|
|
- var specialUser *models.CygxYanxuanSpecialAuthorItem
|
|
|
|
- var err error
|
|
|
|
if userId > 0 {
|
|
if userId > 0 {
|
|
condition += ` AND a.user_id = ? `
|
|
condition += ` AND a.user_id = ? `
|
|
pars = append(pars, userId)
|
|
pars = append(pars, userId)
|
|
}
|
|
}
|
|
-
|
|
|
|
- cond := ``
|
|
|
|
- cond += ` AND a.status = 1 `
|
|
|
|
- specialUser, err = models.GetYanxuanSpecialAuthor(sysUser.UserId, sysUser.UserId, cond)
|
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
|
|
|
+ condition += ` AND a.status = 3 `
|
|
|
|
+ total, err := models.GetCygxYanxuanSpecialCount(condition, pars)
|
|
|
|
+ if err != nil {
|
|
br.Msg = "获取失败"
|
|
br.Msg = "获取失败"
|
|
br.ErrMsg = "获取失败, Err:" + err.Error()
|
|
br.ErrMsg = "获取失败, Err:" + err.Error()
|
|
return
|
|
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.Msg = "获取失败"
|
|
- br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
|
|
|
|
|
|
+ br.ErrMsg = "获取失败, Err:" + err.Error()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
for _, v := range list {
|
|
for _, v := range list {
|
|
@@ -98,12 +107,13 @@ func (this *YanxuanSpecialController) List() {
|
|
v.Tags += v.IndustryTags
|
|
v.Tags += v.IndustryTags
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- resp := new(models.SpecialListResp)
|
|
|
|
|
|
|
|
- if specialUser != nil {
|
|
|
|
- resp.IsAuthor = true
|
|
|
|
- }
|
|
|
|
|
|
+ isAuthor, isImproveInformation := services.GetYanxuanSpecialAuthorInfo(sysUser) //用户是否没开通研选专栏以及,专栏信息是否完善
|
|
|
|
+ resp.IsAuthor = isAuthor
|
|
|
|
+ resp.IsImproveInformation = isImproveInformation
|
|
resp.List = list
|
|
resp.List = list
|
|
|
|
+ page := paging.GetPaging(currentIndex, pageSize, total)
|
|
|
|
+ resp.Paging = page
|
|
|
|
|
|
br.Data = resp
|
|
br.Data = resp
|
|
br.Ret = 200
|
|
br.Ret = 200
|
|
@@ -113,7 +123,8 @@ func (this *YanxuanSpecialController) List() {
|
|
|
|
|
|
// @Title 专栏详情
|
|
// @Title 专栏详情
|
|
// @Description 专栏详情
|
|
// @Description 专栏详情
|
|
-// @Param request body help_doc.AddHelpDocReq true "type json string"
|
|
|
|
|
|
+// @Param IsSendWx query int false "是否是通过微信模版进来的 1是,其它否"
|
|
|
|
+// @Param Id query int true "详情ID"
|
|
// @Success 200 {object} models.AddEnglishReportResp
|
|
// @Success 200 {object} models.AddEnglishReportResp
|
|
// @router /detail [get]
|
|
// @router /detail [get]
|
|
func (this *YanxuanSpecialController) Detail() {
|
|
func (this *YanxuanSpecialController) Detail() {
|
|
@@ -131,6 +142,7 @@ func (this *YanxuanSpecialController) Detail() {
|
|
}
|
|
}
|
|
|
|
|
|
specialId, _ := this.GetInt("Id", 0)
|
|
specialId, _ := this.GetInt("Id", 0)
|
|
|
|
+ isSendWx, _ := this.GetInt("IsSendWx", 0)
|
|
|
|
|
|
if specialId <= 0 {
|
|
if specialId <= 0 {
|
|
br.Msg = "参数错误"
|
|
br.Msg = "参数错误"
|
|
@@ -149,6 +161,8 @@ func (this *YanxuanSpecialController) Detail() {
|
|
}
|
|
}
|
|
|
|
|
|
var resp models.CygxYanxuanSpecialResp
|
|
var resp models.CygxYanxuanSpecialResp
|
|
|
|
+
|
|
|
|
+ resp.HasPermission = 1
|
|
resp.CygxYanxuanSpecialItem = *item
|
|
resp.CygxYanxuanSpecialItem = *item
|
|
if item.DocUrl != "" {
|
|
if item.DocUrl != "" {
|
|
var docs []models.Doc
|
|
var docs []models.Doc
|
|
@@ -172,6 +186,26 @@ func (this *YanxuanSpecialController) Detail() {
|
|
resp.IndustryTags = append(resp.IndustryTags, item.IndustryTags)
|
|
resp.IndustryTags = append(resp.IndustryTags, item.IndustryTags)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //如果状态未审核通过,而且查看的不是本人,不是审核人员,就无法查看详情
|
|
|
|
+ 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 isSendWx == 1 && strings.Contains(cnf.ConfigValue, sysUser.Mobile) {
|
|
|
|
+ resp.IsShowExamine = true
|
|
|
|
+ resp.ExamineStatus = item.Status
|
|
|
|
+ }
|
|
|
|
+ resp.ExamineStatus = item.Status
|
|
|
|
+ if item.UserId != sysUser.UserId && item.Status != 3 && !strings.Contains(cnf.ConfigValue, sysUser.Mobile) {
|
|
|
|
+ resp.CygxYanxuanSpecialItem = *new(models.CygxYanxuanSpecialItem) // 如果内容不可见,就把内容置空
|
|
|
|
+ resp.HasPermission = 2
|
|
|
|
+ }
|
|
|
|
+
|
|
go services.AddSpecialRecord(this.User, specialId)
|
|
go services.AddSpecialRecord(this.User, specialId)
|
|
|
|
|
|
br.Data = resp
|
|
br.Data = resp
|
|
@@ -551,7 +585,7 @@ func (this *YanxuanSpecialController) Center() {
|
|
condition += ` AND a.status = ? `
|
|
condition += ` AND a.status = ? `
|
|
pars = append(pars, 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 {
|
|
if tmpErr != nil {
|
|
br.Msg = "获取失败"
|
|
br.Msg = "获取失败"
|
|
br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
|
|
br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
|
|
@@ -559,17 +593,17 @@ func (this *YanxuanSpecialController) Center() {
|
|
}
|
|
}
|
|
|
|
|
|
for _, v := range list {
|
|
for _, v := range list {
|
|
|
|
+ //如果在web端有样式或者上传了文件,小程序就禁止编辑修改内容
|
|
hasStyle, err := utils.ArticleHasStyle(v.Content)
|
|
hasStyle, err := utils.ArticleHasStyle(v.Content)
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- v.ContentHasStyle = hasStyle
|
|
|
|
hasImg, err := utils.ArticleHasImgUrl(v.Content)
|
|
hasImg, err := utils.ArticleHasImgUrl(v.Content)
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- if hasImg {
|
|
|
|
- v.ContentHasStyle = hasImg
|
|
|
|
|
|
+ if hasStyle || strings.Contains(v.DocUrl, "http") || hasImg {
|
|
|
|
+ v.ContentHasStyle = true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -833,7 +867,8 @@ func (this *YanxuanSpecialController) Cancel() {
|
|
|
|
|
|
// @Title 作者列表
|
|
// @Title 作者列表
|
|
// @Description 作者列表
|
|
// @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
|
|
// @Success 200 {object} models.AddEnglishReportResp
|
|
// @router /author/list [get]
|
|
// @router /author/list [get]
|
|
func (this *YanxuanSpecialController) AuthorList() {
|
|
func (this *YanxuanSpecialController) AuthorList() {
|
|
@@ -849,35 +884,52 @@ func (this *YanxuanSpecialController) AuthorList() {
|
|
br.Ret = 408
|
|
br.Ret = 408
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- var specialUser *models.CygxYanxuanSpecialAuthorItem
|
|
|
|
- var err error
|
|
|
|
|
|
|
|
- cond := ``
|
|
|
|
- cond += ` AND a.status = 1 `
|
|
|
|
- specialUser, err = models.GetYanxuanSpecialAuthor(sysUser.UserId, sysUser.UserId, cond)
|
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
|
|
|
+ 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)
|
|
|
|
+ var condition string
|
|
|
|
+ var pars []interface{}
|
|
|
|
+ condition += ` AND a.nick_name <> '' `
|
|
|
|
+
|
|
|
|
+ total, err := models.GetCygxYanxuanSpecialAuthorCount(condition, pars)
|
|
|
|
+ if err != nil {
|
|
br.Msg = "获取失败"
|
|
br.Msg = "获取失败"
|
|
- br.ErrMsg = "获取失败, Err:" + err.Error()
|
|
|
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
-
|
|
|
|
- list, tmpErr := models.GetYanxuanSpecialAuthorList()
|
|
|
|
|
|
+ condition += ` ORDER BY latest_publish_time DESC`
|
|
|
|
+ list, tmpErr := models.GetYanxuanSpecialAuthorList(condition, pars, startSize, pageSize)
|
|
if tmpErr != nil {
|
|
if tmpErr != nil {
|
|
br.Msg = "获取失败"
|
|
br.Msg = "获取失败"
|
|
br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
|
|
br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ var userIds []int
|
|
for _, v := range list {
|
|
for _, v := range list {
|
|
v.LatestPublishDate = v.LatestPublishTime.Format(utils.FormatDate) + "更新"
|
|
v.LatestPublishDate = v.LatestPublishTime.Format(utils.FormatDate) + "更新"
|
|
|
|
+ userIds = append(userIds, v.UserId)
|
|
}
|
|
}
|
|
- resp := new(models.SpecialAuthorListResp)
|
|
|
|
|
|
|
|
- if specialUser != nil {
|
|
|
|
- resp.IsAuthor = true
|
|
|
|
|
|
+ bestNew := services.GetBestNewYanxuanSpecialByUserId(userIds)
|
|
|
|
+ for _, v := range list {
|
|
|
|
+ v.YanxuanSpecialCenter = bestNew[v.UserId]
|
|
}
|
|
}
|
|
|
|
+ resp := new(models.SpecialAuthorListResp)
|
|
|
|
+ isAuthor, _ := services.GetYanxuanSpecialAuthorInfo(sysUser) //用户是否没开通研选专栏以及,专栏信息是否完善
|
|
|
|
+ resp.IsAuthor = isAuthor
|
|
|
|
+ page := paging.GetPaging(currentIndex, pageSize, total)
|
|
resp.List = list
|
|
resp.List = list
|
|
-
|
|
|
|
|
|
+ resp.Paging = page
|
|
br.Data = resp
|
|
br.Data = resp
|
|
br.Ret = 200
|
|
br.Ret = 200
|
|
br.Success = true
|
|
br.Success = true
|