Browse Source

最新报告筛选

kobe6258 7 months ago
parent
commit
85150185d0
2 changed files with 34 additions and 10 deletions
  1. 23 3
      controllers/report/report_controller.go
  2. 11 7
      service/report/report_service.go

+ 23 - 3
controllers/report/report_controller.go

@@ -157,7 +157,7 @@ func (r *ReportController) HotRanked(permissionIds string, limit int) {
 // @Description 获取最新发布的报告列表
 // @Success 200 {object}
 // @router /publishRankedList [get]
-func (r *ReportController) PublishRanked(limit int, week bool) {
+func (r *ReportController) PublishRanked(permissionIds string, limit int, week bool) {
 	controllers.Wrap(&r.BaseController, func() (result *controllers.WrapData, err error) {
 		result = r.InitWrapData("获取最新发布报告列表失败")
 		if limit <= 0 {
@@ -169,8 +169,28 @@ func (r *ReportController) PublishRanked(limit int, week bool) {
 			r.FailedResult("获取最新发布报告列表失败", result)
 			return
 		}
-
-		r.SuccessResult("获取最新发布报告列表成功", list, result)
+		//二级品种
+		permissionIdList, err := r.TransPermissionIds(permissionIds)
+		if err != nil {
+			logger.Error("品种列表解析错误:%v", err)
+			r.FailedResult("分页查询报告列表失败", result)
+			err = exception.New(exception.QueryReportPageFailed)
+			return
+		}
+		filterList := make([]report.PublishRankedReport, 0)
+		if len(permissionIdList) > 0 {
+			for _, item := range list {
+				for _, permissionId := range permissionIdList {
+					if _, ok := item.SecondPermissions[permissionId]; ok {
+						filterList = append(filterList, item)
+						break
+					}
+				}
+			}
+		} else {
+			filterList = list
+		}
+		r.SuccessResult("获取最新发布报告列表成功", filterList, result)
 		return
 	})
 }

+ 11 - 7
service/report/report_service.go

@@ -19,13 +19,15 @@ const (
 )
 
 type PublishRankedReport struct {
-	Id              int         `json:"reportId"`
-	OrgId           int         `json:"orgId"`
-	Title           string      `json:"title"`
-	Abstract        string      `json:"abstract"`
-	PermissionNames interface{} `json:"permissionNames,omitempty"`
-	PublishedTime   string      `json:"publishedTime"`
-	CoverUrl        string      `json:"coverUrl"`
+	Id                int            `json:"reportId"`
+	OrgId             int            `json:"orgId"`
+	Title             string         `json:"title"`
+	Abstract          string         `json:"abstract"`
+	SecondPermissions map[int]string `json:"-"`
+	Permissions       map[int]string `json:"-"`
+	PermissionNames   interface{}    `json:"permissionNames,omitempty"`
+	PublishedTime     string         `json:"publishedTime"`
+	CoverUrl          string         `json:"coverUrl"`
 }
 
 type HotRankedReport struct {
@@ -263,6 +265,8 @@ func GetRandedReportByPublishTimeWeekly(limit int, week bool) (reports []Publish
 	for i := 0; i < len(dtoList); i++ {
 		go func(report *reportService.ReportDTO) {
 			defer wg.Done()
+			report.Permissions = getReportPermissionsMap(report.OrgId, report.Source)
+			report.SecondPermission = getReportSecondPermissionsMap(report.OrgId, report.Source)
 			report.PermissionNames = getReportPermissionNames(report.OrgId, report.Source)
 		}(&dtoList[i])
 	}