|
@@ -2,6 +2,7 @@ package controllers
|
|
|
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
+ "github.com/rdlucklib/rdluck_tools/paging"
|
|
|
"hongze/hongze_cygx/models"
|
|
|
"hongze/hongze_cygx/services"
|
|
|
"hongze/hongze_cygx/utils"
|
|
@@ -14,8 +15,10 @@ type YanxuanSpecialController struct {
|
|
|
|
|
|
// @Title 专栏列表
|
|
|
// @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]
|
|
|
func (this *YanxuanSpecialController) List() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
@@ -30,33 +33,38 @@ func (this *YanxuanSpecialController) List() {
|
|
|
br.Ret = 408
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
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 pars []interface{}
|
|
|
|
|
|
- var specialUser *models.CygxYanxuanSpecialAuthorItem
|
|
|
- var err error
|
|
|
if userId > 0 {
|
|
|
condition += ` AND a.user_id = ? `
|
|
|
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.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 {
|
|
@@ -98,12 +106,13 @@ func (this *YanxuanSpecialController) List() {
|
|
|
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
|
|
|
+ page := paging.GetPaging(currentIndex, pageSize, total)
|
|
|
+ resp.Paging = page
|
|
|
|
|
|
br.Data = resp
|
|
|
br.Ret = 200
|
|
@@ -113,7 +122,8 @@ func (this *YanxuanSpecialController) List() {
|
|
|
|
|
|
// @Title 专栏详情
|
|
|
// @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
|
|
|
// @router /detail [get]
|
|
|
func (this *YanxuanSpecialController) Detail() {
|
|
@@ -131,6 +141,7 @@ func (this *YanxuanSpecialController) Detail() {
|
|
|
}
|
|
|
|
|
|
specialId, _ := this.GetInt("Id", 0)
|
|
|
+ isSendWx, _ := this.GetInt("IsSendWx", 0)
|
|
|
|
|
|
if specialId <= 0 {
|
|
|
br.Msg = "参数错误"
|
|
@@ -172,6 +183,13 @@ func (this *YanxuanSpecialController) Detail() {
|
|
|
resp.IndustryTags = append(resp.IndustryTags, item.IndustryTags)
|
|
|
}
|
|
|
|
|
|
+ if isSendWx == 1 {
|
|
|
+ if item.UserId == sysUser.UserId {
|
|
|
+ resp.IsShowExamine = true
|
|
|
+ }
|
|
|
+ resp.ExamineStatus = item.Status
|
|
|
+ }
|
|
|
+
|
|
|
go services.AddSpecialRecord(this.User, specialId)
|
|
|
|
|
|
br.Data = resp
|
|
@@ -551,7 +569,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()
|
|
@@ -833,7 +851,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 *YanxuanSpecialController) AuthorList() {
|