浏览代码

fix: home页排版

hsun 2 年之前
父节点
当前提交
567678caa6
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      models/home.go

+ 5 - 1
models/home.go

@@ -20,12 +20,13 @@ type HomeClassifyItem struct {
 	Child        *Report
 }
 
-func ListHome(userId, maxPermission, userPermission int, permissionStr string) (items []*HomeList, err error) {
+func ListHome(userId, maxPermission, userPermission int, permissionStr string) (homeList []*HomeList, err error) {
 	o := orm.NewOrm()
 	o.Using("rddp")
 	//sql := `SELECT id,classify_name FROM classify WHERE parent_id=0 ORDER BY create_time ASC `
 
 	//暂时将双周报、月报隐藏
+	items := make([]*HomeList, 0)
 	sql := `SELECT id,classify_name FROM classify WHERE parent_id=0 and classify_name not IN("双周报","月报","晨报","周报","草根调研","需求报告","会议纪要","大事点评","年报合集") ORDER BY create_time ASC `
 	_, err = o.Raw(sql).QueryRows(&items)
 	if err != nil {
@@ -78,6 +79,9 @@ func ListHome(userId, maxPermission, userPermission int, permissionStr string) (
 			subItems[k].Child = report
 		}
 		items[i].Child = subItems
+		if lenSub > 0 {
+			homeList = append(homeList, items[i])
+		}
 	}
 	return
 }