|
@@ -2,12 +2,16 @@ package cygx
|
|
|
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
+ "github.com/rdlucklib/rdluck_tools/paging"
|
|
|
+ "github.com/tealeg/xlsx"
|
|
|
"hongze/hz_crm_api/controllers"
|
|
|
"hongze/hz_crm_api/models"
|
|
|
"hongze/hz_crm_api/models/cygx"
|
|
|
cygxService "hongze/hz_crm_api/services/cygx"
|
|
|
"hongze/hz_crm_api/services/elastic"
|
|
|
"hongze/hz_crm_api/utils"
|
|
|
+ "os"
|
|
|
+ "path/filepath"
|
|
|
"strconv"
|
|
|
"time"
|
|
|
)
|
|
@@ -145,6 +149,12 @@ func (this *YanxuanSpecialController) AuthorEnable() {
|
|
|
// @Title 作者列表
|
|
|
// @Description 作者列表
|
|
|
// @Param request body help_doc.AddHelpDocReq true "type json string"
|
|
|
+// @Param PageSize query int true "每页数据条数"
|
|
|
+// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
|
+// @Param Status query string true "状态: 1:启用 、 2:禁用 。传其他默认所有"
|
|
|
+// @Param KeyWord query string false "搜索关键词"
|
|
|
+// @Param SortParam query string false "排序字段参数,用来排序的字段, 枚举值:'CreatTime':开通时间 、 'articleNum':已发布文章 、 'pv':总Pv/Uv "
|
|
|
+// @Param SortType query string true "如何排序,是正序还是倒序,枚举值:`asc 正序`,`desc 倒叙`"
|
|
|
// @Success 200 {object} models.AddEnglishReportResp
|
|
|
// @router /yanxuan_special/author/list [get]
|
|
|
func (this *YanxuanSpecialController) AuthorList() {
|
|
@@ -161,39 +171,101 @@ func (this *YanxuanSpecialController) AuthorList() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- list, tmpErr := cygx.GetYanxuanSpecialAuthorList()
|
|
|
+ pageSize, _ := this.GetInt("PageSize")
|
|
|
+ currentIndex, _ := this.GetInt("CurrentIndex")
|
|
|
+ status, _ := this.GetInt("Status")
|
|
|
+ keyWord := this.GetString("KeyWord")
|
|
|
+ //排序参数
|
|
|
+ sortParam := this.GetString("SortParam")
|
|
|
+ sortType := this.GetString("SortType")
|
|
|
+
|
|
|
+ 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{}
|
|
|
+ //作者状态处理
|
|
|
+ if status == 1 || status == 2 {
|
|
|
+ condition += ` AND art.status = ? `
|
|
|
+ pars = append(pars, status)
|
|
|
+ }
|
|
|
+
|
|
|
+ //关键词搜索
|
|
|
+ if keyWord != "" {
|
|
|
+ keyWord = "%" + keyWord + "%"
|
|
|
+ condition += ` AND art.special_name like ? `
|
|
|
+ pars = append(pars, keyWord)
|
|
|
+ }
|
|
|
+
|
|
|
+ //排序字段以及排序方式处理
|
|
|
+ var sortStr string
|
|
|
+ if sortParam != "" && sortType != "" {
|
|
|
+ if sortParam == "CreatTime" {
|
|
|
+ if sortType == "asc" {
|
|
|
+ sortStr = " ORDER BY art.create_time ASC "
|
|
|
+ } else {
|
|
|
+ sortStr = " ORDER BY art.create_time DESC "
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if sortParam == "articleNum" {
|
|
|
+ if sortType == "asc" {
|
|
|
+ sortStr = " ORDER BY art.article_num ASC "
|
|
|
+ } else {
|
|
|
+ sortStr = " ORDER BY art.article_num DESC "
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if sortParam == "Pv" {
|
|
|
+ if sortType == "asc" {
|
|
|
+ sortStr = " ORDER BY art.pv ASC "
|
|
|
+ } else {
|
|
|
+ sortStr = " ORDER BY art.pv DESC "
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ sortStr = " ORDER BY art.create_time DESC "
|
|
|
+ }
|
|
|
+
|
|
|
+ total, err := cygx.GetYanxuanSpecialAuthorCount(condition, pars)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ list, tmpErr := cygx.GetYanxuanSpecialAuthorList(condition+sortStr, pars, startSize, pageSize)
|
|
|
if tmpErr != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- br.Data = list
|
|
|
+ resp := new(cygx.GetCygxYanxuanSpecialAuthorItemResp)
|
|
|
+ page := paging.GetPaging(currentIndex, pageSize, total)
|
|
|
+ resp.List = list
|
|
|
+ resp.Paging = page
|
|
|
+ br.Data = resp
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
|
br.Msg = "获取成功"
|
|
|
}
|
|
|
|
|
|
-//V12.0.1 上线脚本
|
|
|
-//func init() {
|
|
|
-// list, err := cygx.GetYanxuanSpecialAuthorList()
|
|
|
-// if err != nil {
|
|
|
-// fmt.Println(err)
|
|
|
-// }
|
|
|
-// for _, v := range list {
|
|
|
-// //获取关联公司的用户信息
|
|
|
-// infoUser, err := cygx.GetUserAndCompanyNameList(v.UserId)
|
|
|
-// if err != nil {
|
|
|
-// fmt.Println(err)
|
|
|
-// }
|
|
|
-// err = cygx.UpdateSpecialAuthorComapony(infoUser.UserId, infoUser.CompanyId, infoUser.CompanyName)
|
|
|
-// fmt.Println(infoUser.UserId)
|
|
|
-// }
|
|
|
-//}
|
|
|
-
|
|
|
// @Title 审核列表
|
|
|
// @Description 审核列表
|
|
|
-// @Param request body help_doc.AddHelpDocReq true "type json string"
|
|
|
+// @Param PageSize query int true "每页数据条数"
|
|
|
+// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
|
+// @Param Status query string true "状态: 1:待审核 、 2:已发布 。默认待审核"
|
|
|
+// @Param Type query int true "文章类型,1:笔记、2:观点"
|
|
|
+// @Param KeyWord query string false "搜索关键词"
|
|
|
+// @Param SortParam query string false "排序字段参数,用来排序的字段, 枚举值:'CreatTime':开通时间 、 'articleNum':已发布文章 、 'pv':总Pv/Uv "
|
|
|
+// @Param SortType query string true "如何排序,是正序还是倒序,枚举值:`asc 正序`,`desc 倒叙`"
|
|
|
+// @Param StartDate query string false "开始时间 ,列如2021-03-06 "
|
|
|
+// @Param EndDate query string false "结束时间,列如2021-03-06 "
|
|
|
// @Success 200 {object} models.AddEnglishReportResp
|
|
|
// @router /yanxuan_special/list [get]
|
|
|
func (this *YanxuanSpecialController) List() {
|
|
@@ -211,6 +283,25 @@ func (this *YanxuanSpecialController) List() {
|
|
|
}
|
|
|
|
|
|
userId, _ := this.GetInt("UserId", 0)
|
|
|
+ pageSize, _ := this.GetInt("PageSize")
|
|
|
+ currentIndex, _ := this.GetInt("CurrentIndex")
|
|
|
+ status, _ := this.GetInt("Status", 1)
|
|
|
+ specialType, _ := this.GetInt("Type", 1)
|
|
|
+ keyWord := this.GetString("KeyWord")
|
|
|
+ //排序参数
|
|
|
+ sortParam := this.GetString("SortParam")
|
|
|
+ sortType := this.GetString("SortType")
|
|
|
+ startDate := this.GetString("StartDate")
|
|
|
+ endDate := this.GetString("EndDate")
|
|
|
+
|
|
|
+ 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{}
|
|
|
|
|
@@ -218,10 +309,55 @@ func (this *YanxuanSpecialController) List() {
|
|
|
condition += ` AND a.user_id = ? `
|
|
|
pars = append(pars, userId)
|
|
|
}
|
|
|
+ if status == 1 {
|
|
|
+ condition += ` AND a.status = 2 `
|
|
|
+ }
|
|
|
+ if status == 2 {
|
|
|
+ condition += ` AND a.status = 3 `
|
|
|
+ }
|
|
|
+
|
|
|
+ if startDate != "" {
|
|
|
+ condition += ` AND a.publish_time >= ` + "'" + startDate + " 00:00:00'"
|
|
|
+ }
|
|
|
+ if endDate != "" {
|
|
|
+ condition += ` AND a.publish_time <= ` + "'" + endDate + " 23:59:59'"
|
|
|
+ }
|
|
|
+
|
|
|
+ //文章类型
|
|
|
+ if specialType == 1 || specialType == 2 {
|
|
|
+ condition += ` AND a.type = ? `
|
|
|
+ pars = append(pars, specialType)
|
|
|
+ }
|
|
|
+
|
|
|
+ //关键词搜索
|
|
|
+ if keyWord != "" {
|
|
|
+ keyWord = "%" + keyWord + "%"
|
|
|
+ condition += ` AND a.title like ? `
|
|
|
+ pars = append(pars, keyWord)
|
|
|
+ }
|
|
|
+
|
|
|
+ //排序字段以及排序方式处理
|
|
|
+ var sortStr string
|
|
|
+ if sortParam != "" && sortType != "" {
|
|
|
+ if sortParam == "Pv" {
|
|
|
+ if sortType == "asc" {
|
|
|
+ sortStr = " ORDER BY a.pv ASC "
|
|
|
+ } else {
|
|
|
+ sortStr = " ORDER BY a.pv DESC "
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ sortStr = " ORDER BY a.publish_time DESC "
|
|
|
+ }
|
|
|
|
|
|
- condition += ` AND a.status = 2 `
|
|
|
+ total, err := cygx.GetGetYanxuanSpecialCount(condition, pars)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
- list, tmpErr := cygx.GetYanxuanSpecialList(condition, pars)
|
|
|
+ list, tmpErr := cygx.GetYanxuanSpecialList(condition+sortStr, pars, startSize, pageSize)
|
|
|
if tmpErr != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
|
|
@@ -245,11 +381,6 @@ func (this *YanxuanSpecialController) List() {
|
|
|
}
|
|
|
v.Docs = docs
|
|
|
}
|
|
|
- if v.Type == 1 {
|
|
|
- v.Title = "【笔记】" + v.Title
|
|
|
- } else if v.Type == 2 {
|
|
|
- v.Title = "【观点】" + v.Title
|
|
|
- }
|
|
|
if v.CompanyTags != "" {
|
|
|
v.Tags += v.CompanyTags
|
|
|
}
|
|
@@ -260,8 +391,12 @@ func (this *YanxuanSpecialController) List() {
|
|
|
v.Tags += v.IndustryTags
|
|
|
}
|
|
|
}
|
|
|
+ resp := new(cygx.GetCygxYanxuanSpeciaResplItemResp)
|
|
|
+ page := paging.GetPaging(currentIndex, pageSize, total)
|
|
|
|
|
|
- br.Data = list
|
|
|
+ resp.List = list
|
|
|
+ resp.Paging = page
|
|
|
+ br.Data = resp
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
|
br.Msg = "获取成功"
|
|
@@ -322,3 +457,139 @@ func (this *YanxuanSpecialController) Enable() {
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
|
}
|
|
|
+
|
|
|
+// @Title 收藏详情
|
|
|
+// @Description 收藏详情
|
|
|
+// @Param SpecialId query int true "每页数据条数"
|
|
|
+// @Success 200 {object} models.AddEnglishReportResp
|
|
|
+// @router /yanxuan_special/special_collect/list [get]
|
|
|
+func (this *YanxuanSpecialController) SpecialCollectList() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ sysUser := this.SysUser
|
|
|
+ if sysUser == nil {
|
|
|
+ br.Msg = "请登录"
|
|
|
+ br.ErrMsg = "请登录,SysUser Is Empty"
|
|
|
+ br.Ret = 408
|
|
|
+ return
|
|
|
+ }
|
|
|
+ specialId, _ := this.GetInt("SpecialId")
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ condition += " AND yanxuan_special_id = ? ORDER BY art.create_time DESC "
|
|
|
+ pars = append(pars, specialId)
|
|
|
+ list, err := cygx.GetCygxYanxuanSpecialCollectList(condition, pars, 0, 100000)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp := new(cygx.GetCygxYanxuanSpecialCollectResp)
|
|
|
+ resp.List = list
|
|
|
+ br.Data = resp
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
+}
|
|
|
+
|
|
|
+// @Title 下载PV
|
|
|
+// @Description 下载PV接口
|
|
|
+// @Param SpecialId query int true "每页数据条数"
|
|
|
+// @router /yanxuan_special/list_pv [get]
|
|
|
+func (this *YanxuanSpecialController) ListPv() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ AdminUser := this.SysUser
|
|
|
+ if AdminUser == nil {
|
|
|
+ br.Msg = "请登录"
|
|
|
+ br.ErrMsg = "请登录,用户信息为空"
|
|
|
+ br.Ret = 408
|
|
|
+ return
|
|
|
+ }
|
|
|
+ specialId, _ := this.GetInt("SpecialId")
|
|
|
+ if specialId < 1 {
|
|
|
+ br.Msg = "请输入专栏ID"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ condition = ` AND yanxuan_special_id = ? ORDER BY create_time DESC `
|
|
|
+ pars = append(pars, specialId)
|
|
|
+
|
|
|
+ list, err := cygx.GetCygxYanxuanSpecialRecordList(condition, pars)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //创建excel
|
|
|
+ dir, err := os.Executable()
|
|
|
+ exPath := filepath.Dir(dir)
|
|
|
+ downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
|
|
|
+ xlsxFile := xlsx.NewFile()
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "生成文件失败"
|
|
|
+ br.ErrMsg = "生成文件失败"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ style := xlsx.NewStyle()
|
|
|
+ alignment := xlsx.Alignment{
|
|
|
+ Horizontal: "center",
|
|
|
+ Vertical: "center",
|
|
|
+ WrapText: true,
|
|
|
+ }
|
|
|
+ style.Alignment = alignment
|
|
|
+ style.ApplyAlignment = true
|
|
|
+ sheet, err := xlsxFile.AddSheet("阅读明细")
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "新增Sheet失败"
|
|
|
+ br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ rowTitle := sheet.AddRow()
|
|
|
+ cellA := rowTitle.AddCell()
|
|
|
+ cellA.Value = "姓名"
|
|
|
+ cellB := rowTitle.AddCell()
|
|
|
+ cellB.Value = "公司名称"
|
|
|
+ cellC := rowTitle.AddCell()
|
|
|
+ cellC.Value = "所属权益销售"
|
|
|
+ cellD := rowTitle.AddCell()
|
|
|
+ cellD.Value = "阅读时间"
|
|
|
+ cellE := rowTitle.AddCell()
|
|
|
+ cellE.Value = "阅读时长"
|
|
|
+
|
|
|
+ for _, item := range list {
|
|
|
+ row := sheet.AddRow()
|
|
|
+ cellA := row.AddCell()
|
|
|
+ cellA.Value = item.RealName
|
|
|
+ cellB := row.AddCell()
|
|
|
+ cellB.Value = item.CompanyName
|
|
|
+ cellC := row.AddCell()
|
|
|
+ cellC.Value = item.SellerName
|
|
|
+ cellD := row.AddCell()
|
|
|
+ cellD.Value = item.CreateTime
|
|
|
+ cellE := row.AddCell()
|
|
|
+ cellE.Value = strconv.Itoa(item.StopTime)
|
|
|
+ }
|
|
|
+ err = xlsxFile.Save(downLoadnFilePath)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "保存文件失败"
|
|
|
+ br.ErrMsg = "保存文件失败"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ downloadFileName := time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
|
|
|
+ this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
|
|
|
+ defer func() {
|
|
|
+ os.Remove(downLoadnFilePath)
|
|
|
+ }()
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "导出成功"
|
|
|
+
|
|
|
+}
|