MCPcopy Index your code
hub / github.com/TruthHun/DocHub / Get

Method Get

controllers/HomeControllers/ListController.go:20–107  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

18}
19
20func (this *ListController) Get() {
21
22 var (
23 pid, cid int // parent id && category id
24 p, listRows = 1, this.Sys.ListRows
25 totalRows = 0
26 seoStr []string
27 )
28
29 if listRows <= 0 {
30 listRows = 10
31 }
32
33 chanel := this.GetString(":chanel")
34 params := conv.Path2Map(this.GetString(":splat"))
35 chanels, rows, err := models.GetList(models.GetTableCategory(), 1, 1, orm.NewCondition().And("Alias", chanel))
36 if err != nil {
37 helper.Logger.Error("SQL语句执行错误:%v", err.Error())
38 }
39
40 if rows == 0 {
41 this.Redirect("/", 302)
42 }
43
44 if v, ok := params["pid"]; ok {
45 pid = helper.Interface2Int(v)
46 }
47
48 if v, ok := params["cid"]; ok {
49 cid = helper.Interface2Int(v)
50 }
51
52 if v, ok := params["p"]; ok { //页码处理
53 p = helper.NumberRange(helper.Interface2Int(v), 1, 100)
54 }
55
56 orderBy := []string{"Sort", "Title"} //分类排序
57 totalRows = helper.Interface2Int(chanels[0]["Cnt"])
58 seoStr = append(seoStr, chanels[0]["Title"].(string))
59 if pid > 0 {
60 totalRows = 0
61 this.Data["Children"], _, _ = models.GetList(models.GetTableCategory(), 1, 50, orm.NewCondition().And("Pid", pid), orderBy...)
62 if curParent, rows, err := models.GetList(models.GetTableCategory(), 1, 1, orm.NewCondition().And("Id", pid), orderBy...); err != nil {
63 helper.Logger.Error(err.Error())
64 } else if rows > 0 {
65 this.Data["CurParent"] = curParent[0]
66 totalRows = helper.Interface2Int(curParent[0]["Cnt"])
67 seoStr = append(seoStr, curParent[0]["Title"].(string))
68 }
69 }
70
71 if cid > 0 {
72 totalRows = 0
73 if curChildren, rows, err := models.GetList(models.GetTableCategory(), 1, 1, orm.NewCondition().And("Id", cid), orderBy...); err != nil {
74 helper.Logger.Error(err.Error())
75 } else if rows > 0 {
76 this.Data["CurChildren"] = curChildren[0]
77 totalRows = helper.Interface2Int(curChildren[0]["Cnt"])

Callers

nothing calls this directly

Calls 2

SimpleListMethod · 0.80
GetByPageMethod · 0.80

Tested by

no test coverage detected