Przeglądaj źródła

Merge branch 'out_report_2.1' into debug

xiziwen 4 miesięcy temu
rodzic
commit
639ab1a2fa

+ 10 - 0
models/classify.go

@@ -617,3 +617,13 @@ func GetClassifyListByIdStrList(classifyIdStrList []string) (items []*Classify,
 	_, err = o.Raw(sql, classifyIdStrList).QueryRows(&items)
 	return
 }
+
+// GetClassifyListByParentId 查询父分类下所有的子分类
+func GetClassifyListByParentId(parentId int) (items []*Classify, err error) {
+	o := orm.NewOrmUsingDB("rddp")
+	sql := `SELECT * FROM classify WHERE parent_id = ? and enabled = 1`
+
+	_, err = o.Raw(sql, parentId).QueryRows(&items)
+
+	return items, err
+}

+ 6 - 2
models/report.go

@@ -1779,9 +1779,13 @@ func GetReportListByCollectListV2(classifyIdFirst, classifyIdSecond, classifyIdT
 
 	// SQL 主体
 	sql := `
-		SELECT DISTINCT t.id, t.title, t.author, t.modify_time, t.publish_time,t.classify_id_first,t.classify_name_first,t.classify_id_second,t.classify_name_second,t.classify_id_third,t.classify_name_third
+		SELECT DISTINCT t.id, t.title, t.author, t.modify_time, t.publish_time,t.classify_id_first,t.classify_name_first,
+t.classify_id_second,t.classify_name_second,t.classify_id_third,t.classify_name_third,
+t.abstract,t.admin_id,t.admin_real_name,t.last_modify_admin_id,t.last_modify_admin_name 
 		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
+			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,
+b.abstract,b.admin_id,b.admin_real_name,b.last_modify_admin_id,b.last_modify_admin_name 
 			FROM report AS b WHERE 1 = 1
 	`
 

+ 44 - 3
services/document_manage_service/document_manage_service.go

@@ -178,6 +178,23 @@ func DocumentReportList(userId, documentType int, chartPermissionIdList []string
 		condition = ` and t1.source!=3`
 	}
 	if len(classifyIdList) > 0 {
+		// 递归查询子分类
+		for _, classifyId := range classifyIdList {
+			id, err := strconv.Atoi(classifyId)
+			if err != nil {
+				return nil, err
+			}
+
+			if id == 0 {
+				classifyIdList = append(classifyIdList, classifyId)
+			} else {
+				childrenClassifyIdList, err := GetAllClassifyIdsByParentId(id)
+				if err != nil {
+					return nil, err
+				}
+				classifyIdList = append(classifyIdList, childrenClassifyIdList...)
+			}
+		}
 		condition += ` and t1.classify_id in (` + utils.GetOrmInReplace(len(classifyIdList)) + `)`
 		for _, classifyId := range classifyIdList {
 			pars = append(pars, classifyId)
@@ -190,7 +207,7 @@ func DocumentReportList(userId, documentType int, chartPermissionIdList []string
 		}
 	}
 	if keyword != "" {
-		condition += ` and (t1.title like ? or t1.sys_user_name like ? )`
+		condition += ` and (t1.title like ? or t1.sys_user_name like ?) `
 		pars = append(pars, "%"+keyword+"%", "%"+keyword+"%")
 	}
 
@@ -207,9 +224,9 @@ func DocumentReportList(userId, documentType int, chartPermissionIdList []string
 	}
 
 	if orderField != "" && orderType != "" {
-		condition += ` group by t1.outside_report_id order by t1.` + orderField + ` ` + orderType
+		condition += ` order by t1.` + orderField + ` ` + orderType
 	} else {
-		condition += ` group by t1.outside_report_id order by t1.report_update_time desc`
+		condition += ` order by t1.report_update_time desc`
 	}
 
 	outsideReportList, err := document_manage_model.GetOutsideReportListByCondition(condition, pars, startSize, pageSize)
@@ -240,6 +257,30 @@ func DocumentReportList(userId, documentType int, chartPermissionIdList []string
 	return &reportPage, nil
 }
 
+// GetAllClassifyIdsByParentId 递归查询子分类
+func GetAllClassifyIdsByParentId(parentId int) ([]string, error) {
+	var classifyIdList []string
+
+	// 获取子分类
+	classifyList, err := models.GetClassifyListByParentId(parentId)
+	if err != nil {
+		return nil, err
+	}
+
+	// 遍历子分类
+	for _, classify := range classifyList {
+		classifyIdList = append(classifyIdList, strconv.Itoa(classify.Id))
+		// 递归调用
+		subClassifyIds, err := GetAllClassifyIdsByParentId(classify.Id)
+		if err != nil {
+			return nil, err
+		}
+		classifyIdList = append(classifyIdList, subClassifyIds...)
+	}
+
+	return classifyIdList, nil
+}
+
 func RuiSiReportList(classifyIdFirst, classifyIdSecond, classifyIdThird []string, keyword, orderField, orderType string, startSize, pageSize int) (*models.ReportListResp, error) {
 	logs.Info("RuiSiReportList")