|
@@ -66,8 +66,18 @@ func (this *ReportController) List() {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
classifyMapping := make(map[int]*models.MiniClassify)
|
|
classifyMapping := make(map[int]*models.MiniClassify)
|
|
|
|
+ var classifyIds, firstIds, secondIds, thirdIds []int
|
|
for _, v := range classifies {
|
|
for _, v := range classifies {
|
|
classifyMapping[v.Id] = v
|
|
classifyMapping[v.Id] = v
|
|
|
|
+ classifyIds = append(classifyIds, v.Id)
|
|
|
|
+ switch v.Level {
|
|
|
|
+ case 1:
|
|
|
|
+ firstIds = append(firstIds, v.Id)
|
|
|
|
+ case 2:
|
|
|
|
+ secondIds = append(secondIds, v.Id)
|
|
|
|
+ case 3:
|
|
|
|
+ thirdIds = append(thirdIds, v.Id)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
if params.ClassifyId > 0 {
|
|
if params.ClassifyId > 0 {
|
|
classify := classifyMapping[params.ClassifyId]
|
|
classify := classifyMapping[params.ClassifyId]
|
|
@@ -102,6 +112,36 @@ func (this *ReportController) List() {
|
|
outsideCond += ` AND o.classify_id = ?`
|
|
outsideCond += ` AND o.classify_id = ?`
|
|
outsidePars = append(outsidePars, params.ClassifyId)
|
|
outsidePars = append(outsidePars, params.ClassifyId)
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ // 默认只查询mini_classify分类中的
|
|
|
|
+ if len(classifyIds) > 0 {
|
|
|
|
+ var cond string
|
|
|
|
+ if len(firstIds) > 0 {
|
|
|
|
+ cond += fmt.Sprintf(`r.classify_id_first IN (%s)`, utils.GetOrmInReplace(len(firstIds)))
|
|
|
|
+ reportPars = append(reportPars, firstIds)
|
|
|
|
+ }
|
|
|
|
+ if len(secondIds) > 0 {
|
|
|
|
+ if cond != "" {
|
|
|
|
+ cond += fmt.Sprintf(` OR r.classify_id_second IN (%s)`, utils.GetOrmInReplace(len(secondIds)))
|
|
|
|
+ } else {
|
|
|
|
+ cond += fmt.Sprintf(`r.classify_id_second IN (%s)`, utils.GetOrmInReplace(len(secondIds)))
|
|
|
|
+ }
|
|
|
|
+ reportPars = append(reportPars, secondIds)
|
|
|
|
+ }
|
|
|
|
+ if len(thirdIds) > 0 {
|
|
|
|
+ if cond != "" {
|
|
|
|
+ cond += fmt.Sprintf(` OR r.classify_id_third IN (%s)`, utils.GetOrmInReplace(len(thirdIds)))
|
|
|
|
+ } else {
|
|
|
|
+ cond += fmt.Sprintf(`r.classify_id_third IN (%s)`, utils.GetOrmInReplace(len(thirdIds)))
|
|
|
|
+ }
|
|
|
|
+ reportPars = append(reportPars, thirdIds)
|
|
|
|
+ }
|
|
|
|
+ if cond != "" {
|
|
|
|
+ reportCond += fmt.Sprintf(` AND (%s)`, cond)
|
|
|
|
+ }
|
|
|
|
+ outsideCond += fmt.Sprintf(` AND o.classify_id IN (%s)`, utils.GetOrmInReplace(len(classifyIds)))
|
|
|
|
+ outsidePars = append(outsidePars, classifyIds)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
resp := new(response.ReportList)
|
|
resp := new(response.ReportList)
|
|
|
|
|