Bläddra i källkod

Merge branch 'out_report_2.1' into debug

xiziwen 4 månader sedan
förälder
incheckning
2f47dcfd2d

+ 2 - 2
controllers/document_manage/document_manage_controller.go

@@ -202,7 +202,7 @@ func (this *DocumentManageController) DocumentReportList() {
 	if currentIndex <= 0 {
 		currentIndex = 1
 	}
-	documentReportPage, err := document_manage_service.DocumentReportList(documentType, chartPermissionIdList, classifyIdList, keyword, orderField, orderType, currentIndex, pageSize)
+	documentReportPage, err := document_manage_service.DocumentReportList(this.SysUser.AdminId, documentType, chartPermissionIdList, classifyIdList, keyword, orderField, orderType, currentIndex, pageSize)
 	if err != nil {
 		br.Msg = "获取报告列表失败"
 		br.ErrMsg = "获取报告列表失败,Err:" + err.Error()
@@ -259,7 +259,7 @@ func (this *DocumentManageController) RuiSiReportList() {
 	if currentIndex <= 0 {
 		currentIndex = 1
 	}
-	RuiSiReportPage, err := document_manage_service.RuiSiReportListV2(classifyIdList, chartPermissionIdList, keyword, orderField, orderType, currentIndex, pageSize)
+	RuiSiReportPage, err := document_manage_service.RuiSiReportListV2(classifyIdList, chartPermissionIdList, keyword, orderField, orderType, this.SysUser.AdminId, currentIndex, pageSize)
 	if err != nil {
 		br.Msg = "获取报告列表失败"
 		br.ErrMsg = "获取报告列表失败,Err:" + err.Error()

+ 7 - 2
models/document_manage_model/outside_report.go

@@ -23,8 +23,13 @@ type OutsideReport struct {
 	ReportCode       string `orm:"column(report_code)" description:"报告唯一编码"`
 }
 
+type OutsideReportResp struct {
+	OutsideReport
+	IsCollect  int `description:"是否收藏"`
+}
+
 type OutsideReportPage struct {
-	List   []OutsideReport    `description:"报告列表"`
+	List   []OutsideReportResp    `description:"报告列表"`
 	Paging *paging.PagingItem `description:"分页数据"`
 }
 
@@ -63,7 +68,7 @@ func GetOutsideReportListByConditionCount(condition string, pars []interface{})
 }
 
 // GetOutsideReportListByCondition 根据条件查询列表
-func GetOutsideReportListByCondition(condition string, pars []interface{}, currentIndex int, pageSize int) (list []OutsideReport, err error) {
+func GetOutsideReportListByCondition(condition string, pars []interface{}, currentIndex int, pageSize int) (list []OutsideReportResp, err error) {
 	o := orm.NewOrmUsingDB("rddp")
 	sql := `select distinct t1.* from outside_report t1 left join chart_permission_search_key_word_mapping t2 on t1.classify_id = t2.classify_id  where 1 = 1 `
 	sql += condition

+ 3 - 2
models/report.go

@@ -149,6 +149,7 @@ type ReportList struct {
 	ClassifyIdThird     int       `description:"三级分类id"`
 	ClassifyNameThird   string    `description:"三级分类名称"`
 	InheritReportId     int       `description:"待继承的报告ID"`
+	IsCollect           int       `description:"是否收藏"`
 }
 
 type ReportListResp struct {
@@ -1695,7 +1696,7 @@ func GetReportListByCollectCountV2(classifyIdFirst, classifyIdSecond, classifyId
 		FROM (
 			SELECT b.id
 			FROM report AS b left join chart_permission_search_key_word_mapping c on
-b.classify_id = c.classify_id
+b.classify_id_first = c.classify_id
 			WHERE 1 = 1
 	`
 	if len(chartPermissionIdList) > 0 {
@@ -1767,7 +1768,7 @@ func GetReportListByCollectListV2(classifyIdFirst, classifyIdSecond, classifyIdT
 		FROM (
 			SELECT b.id, b.title, b.author, b.modify_time, b.publish_time,b.classify_id_first,b.classify_name_first,b.classify_id_second,b.classify_name_second,b.classify_id_third,b.classify_name_third
 			FROM report AS b  left join chart_permission_search_key_word_mapping c on
-b.classify_id = c.classify_id 
+b.classify_id_first = c.classify_id 
 			WHERE 1 = 1
 	`
 

+ 40 - 3
services/document_manage_service/document_manage_service.go

@@ -168,7 +168,7 @@ func getChildVariety(permissionList []*models.ChartPermission, permissionId int)
 
 }
 
-func DocumentReportList(documentType int, chartPermissionIdList []string, classifyIdList []string, keyword string, orderField, orderType string, startSize, pageSize int) (*document_manage_model.OutsideReportPage, error) {
+func DocumentReportList(userId, documentType int, chartPermissionIdList []string, classifyIdList []string, keyword string, orderField, orderType string, startSize, pageSize int) (*document_manage_model.OutsideReportPage, error) {
 	logs.Info("DocumentVarietyList")
 
 	var condition string
@@ -217,6 +217,23 @@ func DocumentReportList(documentType int, chartPermissionIdList []string, classi
 		return nil, err
 	}
 
+	// 查询用户已收藏的分类
+	collectClassifyList, err := models.GetUserCollectClassifyList(userId, 0)
+	if err != nil {
+		return nil, err
+	}
+	// 转换成map
+	collectClassifyMap := make(map[int]bool)
+	for _, collectClassify := range collectClassifyList {
+		collectClassifyMap[collectClassify.ClassifyId] = true
+	}
+
+	for i, _ := range outsideReportList {
+		if _, ok := collectClassifyMap[outsideReportList[i].ClassifyId]; ok {
+			outsideReportList[i].IsCollect = 1
+		}
+	}
+
 	reportPage.Paging = page
 	reportPage.List = outsideReportList
 
@@ -418,7 +435,7 @@ func DocumentDelete(outsideReportId int) error {
 	return nil
 }
 
-func RuiSiReportListV2(classifyIdList, chartPermissionIdList []string, keyword, orderField, orderType string, startSize, pageSize int) (*models.ReportListResp, error) {
+func RuiSiReportListV2(classifyIdList, chartPermissionIdList []string, keyword, orderField, orderType string, userId, startSize, pageSize int) (*models.ReportListResp, error) {
 	logs.Info("RuiSiReportList")
 
 	allClassifyList, err := models.GetClassifyListByIdStrList(classifyIdList)
@@ -460,8 +477,28 @@ func RuiSiReportListV2(classifyIdList, chartPermissionIdList []string, keyword,
 		return nil, err
 	}
 
-	for _, report := range reportList {
+	// 查询用户已收藏的分类
+	collectClassifyList, err := models.GetUserCollectClassifyList(userId, 0)
+	if err != nil {
+		return nil, err
+	}
+	// 转换成map
+	collectClassifyMap := make(map[int]bool)
+	for _, collectClassify := range collectClassifyList {
+		collectClassifyMap[collectClassify.ClassifyId] = true
+	}
+
+	for i, report := range reportList {
 		report.ModifyTime = report.ModifyTime.UTC()
+		if _, ok := collectClassifyMap[reportList[i].ClassifyIdFirst]; ok {
+			reportList[i].IsCollect = 1
+		}
+		if _, ok := collectClassifyMap[reportList[i].ClassifyIdSecond]; ok {
+			reportList[i].IsCollect = 1
+		}
+		if _, ok := collectClassifyMap[reportList[i].ClassifyIdThird]; ok {
+			reportList[i].IsCollect = 1
+		}
 	}
 
 	reportPage.Paging = page