|
@@ -164,7 +164,6 @@ func (this *ReportController) PdfList() {
|
|
|
return
|
|
|
}
|
|
|
var condition string
|
|
|
- var pars []interface{}
|
|
|
switch rangeType {
|
|
|
case 1:
|
|
|
condition += ` AND DATE(publish_time)=DATE(NOW()) `
|
|
@@ -175,11 +174,42 @@ func (this *ReportController) PdfList() {
|
|
|
}
|
|
|
|
|
|
startSize := utils.StartIndex(currentIndex, pageSize)
|
|
|
-
|
|
|
+ var leafClassifyIds []int
|
|
|
+ var leafClassifyIdMap map[int]struct{}
|
|
|
+ var classifyMap map[int]*models.ClassifyView
|
|
|
if classifyId != 0 {
|
|
|
- condition += ` AND classify_id_second=?`
|
|
|
- pars = append(pars, classifyId)
|
|
|
- } else if chartPermissionId != 0 {
|
|
|
+ classifyResp, err := services.GetAllClassify()
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取数据失败"
|
|
|
+ br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if classifyResp.Ret != 200 {
|
|
|
+ br.Msg = classifyResp.Msg
|
|
|
+ br.ErrMsg = classifyResp.ErrMsg
|
|
|
+ return
|
|
|
+ }
|
|
|
+ classifyList := classifyResp.Data
|
|
|
+ classifyMap = make(map[int]*models.ClassifyView)
|
|
|
+ isHas := false
|
|
|
+ for _, v := range classifyList {
|
|
|
+ if v.Id == classifyId && classifyId != 0 {
|
|
|
+ isHas = true
|
|
|
+ }
|
|
|
+ classifyMap[v.Id] = v
|
|
|
+ }
|
|
|
+ if !isHas && classifyId != 0 {
|
|
|
+ br.Msg = "分类不存在"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ leafClassifyIds = getLeafClassifyIds(classifyMap, classifyId)
|
|
|
+ leafClassifyIdMap = make(map[int]struct{})
|
|
|
+ for _, v := range leafClassifyIds {
|
|
|
+ leafClassifyIdMap[v] = struct{}{}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var permissionClassifyList []int
|
|
|
+ if chartPermissionId != 0 {
|
|
|
resp, err := services.GetClassifyListByChartPermission(chartPermissionId)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取分类失败"
|
|
@@ -200,20 +230,42 @@ func (this *ReportController) PdfList() {
|
|
|
br.Data = resp
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- condition += ` AND classify_id_second IN (` + utils.GetOrmReplaceHolder(len(classifyList)) + `)`
|
|
|
for _, item := range classifyList {
|
|
|
- pars = append(pars, item.Id)
|
|
|
+ permissionClassifyList = append(permissionClassifyList, item.Id)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ queryClassifyIds := make([]int, 0)
|
|
|
+ if classifyId > 0 {
|
|
|
+ for _, v := range permissionClassifyList {
|
|
|
+ if _, ok := leafClassifyIdMap[v]; ok {
|
|
|
+ queryClassifyIds = append(queryClassifyIds, v)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ queryClassifyIds = permissionClassifyList
|
|
|
+ }
|
|
|
+ firstClassifyIds := make([]int, 0)
|
|
|
+ secondClassifyIds := make([]int, 0)
|
|
|
+ thirdClassifyIds := make([]int, 0)
|
|
|
+ for _, v := range queryClassifyIds {
|
|
|
+ switch classifyMap[v].Level {
|
|
|
+ case 1:
|
|
|
+ firstClassifyIds = append(firstClassifyIds, v)
|
|
|
+ case 2:
|
|
|
+ secondClassifyIds = append(secondClassifyIds, v)
|
|
|
+ case 3:
|
|
|
+ thirdClassifyIds = append(thirdClassifyIds, v)
|
|
|
}
|
|
|
}
|
|
|
- total, err := models.GetReportPdfCountByCondition(condition, pars)
|
|
|
+
|
|
|
+ total, err := models.GetReportPdfCountByCondition(firstClassifyIds, secondClassifyIds, thirdClassifyIds, condition)
|
|
|
if err != nil {
|
|
|
br.Msg = "研报列表查询失败"
|
|
|
br.ErrMsg = "研报列表统计查询失败,系统异常,Err:" + err.Error()
|
|
|
return
|
|
|
|
|
|
}
|
|
|
- reportPdfList, err := models.GetReportPdfListByCondition(condition, pars, startSize, pageSize)
|
|
|
+ reportPdfList, err := models.GetReportPdfListByCondition(firstClassifyIds, secondClassifyIds, thirdClassifyIds, condition, startSize, pageSize)
|
|
|
if err != nil {
|
|
|
br.Msg = "研报列表查询失败"
|
|
|
br.ErrMsg = "研报列表查询失败,系统异常,Err:" + err.Error()
|
|
@@ -231,6 +283,25 @@ func (this *ReportController) PdfList() {
|
|
|
br.Data = resp
|
|
|
}
|
|
|
|
|
|
+func getLeafClassifyIds(classifyMap map[int]*models.ClassifyView, keyId int) []int {
|
|
|
+ var leafClassifyIds []int
|
|
|
+ curClassify := classifyMap[keyId]
|
|
|
+ if curClassify.HasChild == 0 {
|
|
|
+ leafClassifyIds = append(leafClassifyIds, curClassify.Id)
|
|
|
+ return leafClassifyIds
|
|
|
+ }
|
|
|
+ for _, v := range classifyMap {
|
|
|
+ if v.ParentId == curClassify.Id {
|
|
|
+ if v.HasChild == 0 {
|
|
|
+ leafClassifyIds = append(leafClassifyIds, v.Id)
|
|
|
+ } else {
|
|
|
+ leafClassifyIds = append(leafClassifyIds, getLeafClassifyIds(classifyMap, v.Id)...)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return leafClassifyIds
|
|
|
+}
|
|
|
+
|
|
|
// @Title pdf研报详情
|
|
|
// @Description pdf研报详情
|
|
|
// @Param ReportPdfId query int true "品种ID"
|
|
@@ -485,8 +556,7 @@ func (this *ReportController) RecentList() {
|
|
|
return
|
|
|
}
|
|
|
// 查询已发布的pdf
|
|
|
- condition := ` AND state=1 `
|
|
|
- reportPdfList, err := models.GetReportPdfListByCondition(condition, []interface{}{}, 0, 3)
|
|
|
+ reportPdfList, err := models.GetRecentReportPdfList(0, 3)
|
|
|
if err != nil {
|
|
|
br.Msg = "研报列表查询失败"
|
|
|
br.ErrMsg = "研报列表查询失败,系统异常,Err:" + err.Error()
|