Ver Fonte

处理一级分类查询的情况

xyxie há 1 ano atrás
pai
commit
5a19947742
1 ficheiros alterados com 29 adições e 0 exclusões
  1. 29 0
      controllers/english_report/report.go

+ 29 - 0
controllers/english_report/report.go

@@ -323,6 +323,7 @@ func (this *EnglishReportController) ListReport() {
 	frequency := this.GetString("Frequency")
 	classifyIdFirst, _ := this.GetInt("ClassifyIdFirst")
 	classifyIdSecond, _ := this.GetInt("ClassifyIdSecond")
+	classifyIdRoot, _ := this.GetInt("ClassifyIdRoot")
 	state, _ := this.GetInt("State")
 	keyWord := this.GetString("KeyWord")
 	companyType := this.GetString("CompanyType")
@@ -379,6 +380,34 @@ func (this *EnglishReportController) ListReport() {
 		condition += ` AND state = ? `
 		pars = append(pars, state)
 	}
+	if classifyIdRoot > 0 && classifyIdFirst == 0 && classifyIdSecond == 0 {
+		//查询顶级分类下的所有二级分类ID
+		childClassify, err := models.GetEnglishSecondClassifyList([]int{classifyIdRoot})
+		if err != nil {
+			br.Msg = "查询子分类出错"
+			br.ErrMsg = "查询子分类出错, Err:" + err.Error()
+			return
+		}
+		var childClassifyIds []int
+		if len(childClassify) > 0 {
+			for _, v := range childClassify {
+				childClassifyIds = append(childClassifyIds, v.Id)
+			}
+			condition += ` AND classify_id_first IN (` + utils.GetOrmInReplace(len(childClassifyIds)) + `)`
+			pars = append(pars, childClassifyIds)
+		} else {
+			//一级分类下没有子分类,直接返回空列表
+			page := paging.GetPaging(currentIndex, pageSize, 0)
+			resp := new(models.EnglishReportListResp)
+			resp.Paging = page
+			resp.List = make([]*models.EnglishReportList, 0)
+			br.Ret = 200
+			br.Success = true
+			br.Msg = "获取成功"
+			br.Data = resp
+			return
+		}
+	}
 	// 未群发邮件(包含推送邮件失败的)
 	if emailState == 1 {
 		failIds, e := models.GetHasFailEmailLogReportIds()