|
@@ -5,6 +5,7 @@ import (
|
|
|
"eta/eta_mini_crm_ht/models/response"
|
|
|
"eta/eta_mini_crm_ht/utils"
|
|
|
"github.com/rdlucklib/rdluck_tools/paging"
|
|
|
+ "strconv"
|
|
|
"strings"
|
|
|
)
|
|
|
|
|
@@ -33,6 +34,7 @@ func (this *MessageController) ReportList() {
|
|
|
permissionIds := this.GetString("PermissionIds")
|
|
|
analystNames := this.GetString("AnalystNames")
|
|
|
sortType := this.GetString("SortType")
|
|
|
+ var permissionCondition string
|
|
|
var condition string
|
|
|
var pars []interface{}
|
|
|
|
|
@@ -44,14 +46,16 @@ func (this *MessageController) ReportList() {
|
|
|
}
|
|
|
if permissionIds != "" {
|
|
|
permissionArr := strings.Split(permissionIds, ",")
|
|
|
- condition += " AND permission_id in (" + utils.GetOrmReplaceHolder(len(permissionArr)) + ")"
|
|
|
+ permissionCondition += "permission_id in (" + utils.GetOrmReplaceHolder(len(permissionArr)) + ")"
|
|
|
pars = append(pars, permissionArr)
|
|
|
}
|
|
|
+
|
|
|
if analystNames != "" {
|
|
|
analystNameArr := strings.Split(analystNames, ",")
|
|
|
condition += " AND author in (" + utils.GetOrmReplaceHolder(len(analystNameArr)) + ")"
|
|
|
pars = append(pars, analystNameArr)
|
|
|
}
|
|
|
+
|
|
|
sortCondition := " ORDER BY published_time "
|
|
|
if sortType == "" {
|
|
|
sortType = "DESC"
|
|
@@ -59,8 +63,8 @@ func (this *MessageController) ReportList() {
|
|
|
sortCondition = sortCondition + sortType
|
|
|
total, err := models.GetReportCountByCondition(condition, pars)
|
|
|
if err != nil {
|
|
|
- br.Msg = "获取研报列表失败"
|
|
|
- br.ErrMsg = "获取研报列表统计失败,Err:" + err.Error()
|
|
|
+ br.Msg = "获取音频列表失败"
|
|
|
+ br.ErrMsg = "获取音频列表统计失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -106,8 +110,9 @@ func (this *MessageController) AudioList() {
|
|
|
pageSize, _ := this.GetInt("PageSize")
|
|
|
currentIndex, _ := this.GetInt("CurrentIndex")
|
|
|
permissionIds := this.GetString("PermissionIds")
|
|
|
- analystNames := this.GetString("AnalystNames")
|
|
|
+ analystIds := this.GetString("AnalystIds")
|
|
|
sortType := this.GetString("SortType")
|
|
|
+ var permissionCondition string
|
|
|
var condition string
|
|
|
var pars []interface{}
|
|
|
|
|
@@ -117,22 +122,37 @@ func (this *MessageController) AudioList() {
|
|
|
if currentIndex <= 0 {
|
|
|
currentIndex = 1
|
|
|
}
|
|
|
+ var permissionPars []interface{}
|
|
|
if permissionIds != "" {
|
|
|
permissionArr := strings.Split(permissionIds, ",")
|
|
|
- condition += " AND permission_id in (" + utils.GetOrmReplaceHolder(len(permissionArr)) + ")"
|
|
|
- pars = append(pars, permissionArr)
|
|
|
+ for _, permissionId := range permissionArr {
|
|
|
+ perId, _ := strconv.Atoi(permissionId)
|
|
|
+ permissionPars = append(permissionPars, perId)
|
|
|
+ }
|
|
|
+ permissionCondition += " AND permission_id in (" + utils.GetOrmReplaceHolder(len(permissionPars)) + ")"
|
|
|
+ ids, err := models.GetMappingsByCondition(permissionCondition, permissionPars)
|
|
|
+ if err != nil {
|
|
|
+ condition += " AND id in (" + utils.GetOrmReplaceHolder(len(ids)) + ")"
|
|
|
+ pars = append(pars, ids)
|
|
|
+ }
|
|
|
}
|
|
|
- if analystNames != "" {
|
|
|
- analystNameArr := strings.Split(analystNames, ",")
|
|
|
- condition += " AND author in (" + utils.GetOrmReplaceHolder(len(analystNameArr)) + ")"
|
|
|
- pars = append(pars, analystNameArr)
|
|
|
+
|
|
|
+ if analystIds != "" {
|
|
|
+ analystIdArr := strings.Split(analystIds, ",")
|
|
|
+ var authorIds []int
|
|
|
+ for _, analystId := range analystIdArr {
|
|
|
+ id, _ := strconv.Atoi(analystId)
|
|
|
+ authorIds = append(authorIds, id)
|
|
|
+ }
|
|
|
+ condition += " AND author_id in (" + utils.GetOrmReplaceHolder(len(authorIds)) + ")"
|
|
|
+ pars = append(pars, authorIds)
|
|
|
}
|
|
|
sortCondition := " ORDER BY published_time "
|
|
|
if sortType == "" {
|
|
|
sortType = "DESC"
|
|
|
}
|
|
|
sortCondition = sortCondition + sortType
|
|
|
- total, err := models.GetReportCountByCondition(condition, pars)
|
|
|
+ total, err := models.GetMediaCountByCondition(models.Audio, condition, pars)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取研报列表失败"
|
|
|
br.ErrMsg = "获取研报列表统计失败,Err:" + err.Error()
|
|
@@ -140,19 +160,110 @@ func (this *MessageController) AudioList() {
|
|
|
}
|
|
|
|
|
|
startSize := utils.StartIndex(currentIndex, pageSize)
|
|
|
- reportList, err := models.GetReportByCondition(condition, sortCondition, pars, startSize, pageSize)
|
|
|
+ reportList, err := models.GetMediaByCondition(models.Audio, condition, sortCondition, pars, startSize, pageSize)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取研报列表失败"
|
|
|
br.ErrMsg = "获取研报列表失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- var reportViewList []*models.ReportView
|
|
|
+ var reportViewList []*models.ESMedia
|
|
|
for _, report := range reportList {
|
|
|
reportView := report.ToView()
|
|
|
reportViewList = append(reportViewList, reportView)
|
|
|
}
|
|
|
page := paging.GetPaging(currentIndex, pageSize, total)
|
|
|
- resp := new(response.ReportListResp)
|
|
|
+ resp := new(response.MediaListResp)
|
|
|
+ resp.List = reportViewList
|
|
|
+ resp.Paging = page
|
|
|
+
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Data = resp
|
|
|
+ br.Msg = "获取成功"
|
|
|
+}
|
|
|
+
|
|
|
+// VideoList
|
|
|
+// @Title 研报列表
|
|
|
+// @Description pdf研报列表
|
|
|
+// @Param PageSize query int true "每页数据条数"
|
|
|
+// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
|
+// @Param ClassifyIds query string true "二级分类id,可多选用英文,隔开"
|
|
|
+// @Param KeyWord query string true "报告标题/创建人"
|
|
|
+// @Param SortType query string true "排序方式"
|
|
|
+// @Success 200 {object} models.ReportAuthorResp
|
|
|
+// @router /videoList [get]
|
|
|
+func (this *MessageController) VideoList() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ pageSize, _ := this.GetInt("PageSize")
|
|
|
+ currentIndex, _ := this.GetInt("CurrentIndex")
|
|
|
+ permissionIds := this.GetString("PermissionIds")
|
|
|
+ analystIds := this.GetString("AnalystIds")
|
|
|
+ sortType := this.GetString("SortType")
|
|
|
+ var permissionCondition string
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+
|
|
|
+ if pageSize <= 0 {
|
|
|
+ pageSize = utils.PageSize20
|
|
|
+ }
|
|
|
+ if currentIndex <= 0 {
|
|
|
+ currentIndex = 1
|
|
|
+ }
|
|
|
+ var permissionPars []interface{}
|
|
|
+ if permissionIds != "" {
|
|
|
+ permissionArr := strings.Split(permissionIds, ",")
|
|
|
+ for _, permissionId := range permissionArr {
|
|
|
+ perId, _ := strconv.Atoi(permissionId)
|
|
|
+ permissionPars = append(permissionPars, perId)
|
|
|
+ }
|
|
|
+ permissionCondition += " AND permission_id in (" + utils.GetOrmReplaceHolder(len(permissionPars)) + ")"
|
|
|
+ ids, err := models.GetMappingsByCondition(permissionCondition, permissionPars)
|
|
|
+ if err != nil {
|
|
|
+ condition += " AND id in (" + utils.GetOrmReplaceHolder(len(ids)) + ")"
|
|
|
+ pars = append(pars, ids)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if analystIds != "" {
|
|
|
+ analystIdArr := strings.Split(analystIds, ",")
|
|
|
+ var authorIds []int
|
|
|
+ for _, analystId := range analystIdArr {
|
|
|
+ id, _ := strconv.Atoi(analystId)
|
|
|
+ authorIds = append(authorIds, id)
|
|
|
+ }
|
|
|
+ condition += " AND author_id in (" + utils.GetOrmReplaceHolder(len(authorIds)) + ")"
|
|
|
+ pars = append(pars, authorIds)
|
|
|
+ }
|
|
|
+ sortCondition := " ORDER BY published_time "
|
|
|
+ if sortType == "" {
|
|
|
+ sortType = "DESC"
|
|
|
+ }
|
|
|
+ sortCondition = sortCondition + sortType
|
|
|
+ total, err := models.GetMediaCountByCondition(models.Video, condition, pars)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取研报列表失败"
|
|
|
+ br.ErrMsg = "获取研报列表统计失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ startSize := utils.StartIndex(currentIndex, pageSize)
|
|
|
+ List, err := models.GetMediaByCondition(models.Video, condition, sortCondition, pars, startSize, pageSize)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取研报列表失败"
|
|
|
+ br.ErrMsg = "获取研报列表失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var reportViewList []*models.ESMedia
|
|
|
+ for _, report := range List {
|
|
|
+ reportView := report.ToView()
|
|
|
+ reportViewList = append(reportViewList, reportView)
|
|
|
+ }
|
|
|
+ page := paging.GetPaging(currentIndex, pageSize, total)
|
|
|
+ resp := new(response.MediaListResp)
|
|
|
resp.List = reportViewList
|
|
|
resp.Paging = page
|
|
|
|