|
@@ -506,7 +506,8 @@ func (r *RoadVideoController) SimpleReportList() {
|
|
classifyIdSecond, _ := r.GetInt("ClassifyIdSecond", 0)
|
|
classifyIdSecond, _ := r.GetInt("ClassifyIdSecond", 0)
|
|
if classifyIdSecond <= 0 {
|
|
if classifyIdSecond <= 0 {
|
|
// 2023-03-03 直接取classify表relate_video=1的二级分类下的报告
|
|
// 2023-03-03 直接取classify表relate_video=1的二级分类下的报告
|
|
- classifyCond := ` AND parent_id > 0 AND relate_video = 1`
|
|
|
|
|
|
+ //classifyCond := ` AND parent_id > 0 AND relate_video = 1`
|
|
|
|
+ classifyCond := ` AND relate_video = 1`
|
|
classifyPars := make([]interface{}, 0)
|
|
classifyPars := make([]interface{}, 0)
|
|
classifyList, e := models.GetClassifyByCondition(classifyCond, "", classifyPars)
|
|
classifyList, e := models.GetClassifyByCondition(classifyCond, "", classifyPars)
|
|
if e != nil {
|
|
if e != nil {
|
|
@@ -514,28 +515,66 @@ func (r *RoadVideoController) SimpleReportList() {
|
|
br.ErrMsg = "获取路演视频可选报告分类失败, Err: " + e.Error()
|
|
br.ErrMsg = "获取路演视频可选报告分类失败, Err: " + e.Error()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- classifyIds := make([]int, 0)
|
|
|
|
|
|
+ var hasChild bool
|
|
|
|
+ firstClassifyIds := make([]int, 0)
|
|
|
|
+ secondClassifyIds := make([]int, 0)
|
|
|
|
+ thirdClassifyIds := make([]int, 0)
|
|
for _, c := range classifyList {
|
|
for _, c := range classifyList {
|
|
- classifyIds = append(classifyIds, c.Id)
|
|
|
|
|
|
+ switch c.Level {
|
|
|
|
+ case 1:
|
|
|
|
+ firstClassifyIds = append(firstClassifyIds, c.Id)
|
|
|
|
+ hasChild = true
|
|
|
|
+ case 2:
|
|
|
|
+ secondClassifyIds = append(secondClassifyIds, c.Id)
|
|
|
|
+ hasChild = true
|
|
|
|
+ case 3:
|
|
|
|
+ thirdClassifyIds = append(thirdClassifyIds, c.Id)
|
|
|
|
+ hasChild = true
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- if len(classifyIds) > 0 {
|
|
|
|
- cond += ` AND classify_id_second IN ( ` + utils.GetOrmInReplace(len(classifyIds)) + ` ) `
|
|
|
|
- pars = append(pars, classifyIds)
|
|
|
|
|
|
+ if hasChild {
|
|
|
|
+ if len(firstClassifyIds) > 0 {
|
|
|
|
+ cond += ` AND classify_id_first IN ( ` + utils.GetOrmInReplace(len(firstClassifyIds)) + ` ) `
|
|
|
|
+ pars = append(pars, firstClassifyIds)
|
|
|
|
+ }
|
|
|
|
+ if len(secondClassifyIds) > 0 {
|
|
|
|
+ cond += ` AND classify_id_second IN ( ` + utils.GetOrmInReplace(len(secondClassifyIds)) + ` ) `
|
|
|
|
+ pars = append(pars, secondClassifyIds)
|
|
|
|
+ }
|
|
|
|
+ if len(thirdClassifyIds) > 0 {
|
|
|
|
+ cond += ` AND classify_id_third IN ( ` + utils.GetOrmInReplace(len(thirdClassifyIds)) + ` ) `
|
|
|
|
+ pars = append(pars, thirdClassifyIds)
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
cond += ` AND 1 = 2`
|
|
cond += ` AND 1 = 2`
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ classifyItem, err := models.GetClassifyById(classifyIdSecond)
|
|
|
|
+ if err != nil {
|
|
|
|
+ br.Msg = "获取失败"
|
|
|
|
+ br.ErrMsg = "获取分类失败, Err: " + err.Error()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ switch classifyItem.Level {
|
|
|
|
+ case 1:
|
|
|
|
+ cond += ` AND classify_id_first = ? `
|
|
|
|
+ pars = append(pars, classifyIdSecond)
|
|
|
|
+ case 2:
|
|
|
|
+ cond += ` AND classify_id_second = ? `
|
|
|
|
+ pars = append(pars, classifyIdSecond)
|
|
|
|
+ case 3:
|
|
|
|
+ cond += ` AND classify_id_third = ? `
|
|
|
|
+ pars = append(pars, classifyIdSecond)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- if classifyIdSecond > 0 {
|
|
|
|
- cond += ` AND classify_id_second = ? `
|
|
|
|
- pars = append(pars, classifyIdSecond)
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
keyword := r.GetString("Keyword", "")
|
|
keyword := r.GetString("Keyword", "")
|
|
if keyword != "" {
|
|
if keyword != "" {
|
|
kw := fmt.Sprint("%", keyword, "%")
|
|
kw := fmt.Sprint("%", keyword, "%")
|
|
cond += ` AND title LIKE ?`
|
|
cond += ` AND title LIKE ?`
|
|
pars = append(pars, kw)
|
|
pars = append(pars, kw)
|
|
}
|
|
}
|
|
- fieldArr := []string{"id", "classify_id_second", "title", "publish_time"}
|
|
|
|
|
|
+ fieldArr := []string{"id", "classify_id_first", "classify_id_second", "classify_id_third", "title", "publish_time"}
|
|
orderRule := ` ORDER BY publish_time DESC, id DESC`
|
|
orderRule := ` ORDER BY publish_time DESC, id DESC`
|
|
reports, e := models.GetReportByCondition(cond, pars, fieldArr, orderRule, true, 0, 5)
|
|
reports, e := models.GetReportByCondition(cond, pars, fieldArr, orderRule, true, 0, 5)
|
|
if e != nil {
|
|
if e != nil {
|
|
@@ -549,10 +588,16 @@ func (r *RoadVideoController) SimpleReportList() {
|
|
{
|
|
{
|
|
classifyIds := make([]int, 0)
|
|
classifyIds := make([]int, 0)
|
|
for _, v := range reports {
|
|
for _, v := range reports {
|
|
- if utils.InArrayByInt(classifyIds, v.ClassifyIdSecond) {
|
|
|
|
|
|
+ minClassifyId, _, e := services.GetMinClassify(v)
|
|
|
|
+ if e != nil {
|
|
|
|
+ br.Msg = "获取失败"
|
|
|
|
+ br.ErrMsg = "获取报告的最小分类失败, Err: " + e.Error()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if utils.InArrayByInt(classifyIds, minClassifyId) {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
- classifyIds = append(classifyIds, v.ClassifyIdSecond)
|
|
|
|
|
|
+ classifyIds = append(classifyIds, minClassifyId)
|
|
}
|
|
}
|
|
if len(classifyIds) > 0 {
|
|
if len(classifyIds) > 0 {
|
|
classifyIdsPermissions, e := models.GetPermissionsByClassifyIds(classifyIds)
|
|
classifyIdsPermissions, e := models.GetPermissionsByClassifyIds(classifyIds)
|
|
@@ -596,13 +641,20 @@ func (r *RoadVideoController) SimpleReportList() {
|
|
}
|
|
}
|
|
|
|
|
|
for i := range reports {
|
|
for i := range reports {
|
|
|
|
+ tmpReport := reports[i]
|
|
|
|
+ minClassifyId, _, e := services.GetMinClassify(tmpReport)
|
|
|
|
+ if e != nil {
|
|
|
|
+ br.Msg = "获取失败"
|
|
|
|
+ br.ErrMsg = "获取报告的最小分类失败, Err: " + e.Error()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
respList = append(respList, &SimpleReportListResp{
|
|
respList = append(respList, &SimpleReportListResp{
|
|
- ReportId: reports[i].Id,
|
|
|
|
- Title: reports[i].Title,
|
|
|
|
- PublishTime: reports[i].PublishTime.Format(utils.FormatDateTime),
|
|
|
|
- BindVideo: bindMap[reports[i].Id],
|
|
|
|
- BindVideoTitle: bindTitleMap[reports[i].Id],
|
|
|
|
- PermissionIds: classifyPermissions[reports[i].ClassifyIdSecond],
|
|
|
|
|
|
+ ReportId: tmpReport.Id,
|
|
|
|
+ Title: tmpReport.Title,
|
|
|
|
+ PublishTime: tmpReport.PublishTime.Format(utils.FormatDateTime),
|
|
|
|
+ BindVideo: bindMap[tmpReport.Id],
|
|
|
|
+ BindVideoTitle: bindTitleMap[tmpReport.Id],
|
|
|
|
+ PermissionIds: classifyPermissions[minClassifyId],
|
|
})
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|