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

Method List

controllers/AdminControllers/DocController.go:49–105  ·  view source on GitHub ↗

文档列表管理

()

Source from the content-addressed store, hash-verified

47
48//文档列表管理
49func (this *DocController) List() {
50 var (
51 p, listRows = 1, this.Sys.ListRows
52 totalRows = this.Sys.CntDoc
53 pid, cid, chanelid, uid int
54 slice []int
55 level int //当前分类的level,频道级别,level为0,父类级别,level为1,children级别,level为2
56 CurId int //当前分类的id
57 )
58 params := conv.Path2Map(this.GetString(":splat"))
59 if v, ok := params["p"]; ok {
60 //页码处理
61 p = helper.NumberRange(helper.Interface2Int(v), 1, 100)
62 }
63 if v, ok := params["uid"]; ok {
64 //页码处理
65 uid = helper.Interface2Int(v)
66 }
67 if v, ok := params["chanelid"]; ok {
68 chanelid = helper.Interface2Int(v)
69 this.Data["ChanelId"] = chanelid
70 slice = append(slice, chanelid)
71 }
72 if v, ok := params["pid"]; ok {
73 pid = helper.Interface2Int(v)
74 this.Data["Pid"] = pid
75 slice = append(slice, pid)
76 level = 1
77 }
78 if v, ok := params["cid"]; ok {
79 cid = helper.Interface2Int(v)
80 this.Data["Cid"] = cid
81 slice = append(slice, cid)
82 level = 2
83 }
84 if len(slice) > 0 {
85 sort.Ints(slice)
86 CurId = slice[len(slice)-1]
87 }
88 cates := models.NewCategory().GetSameLevelCategoryById(CurId)
89 for _, cate := range cates {
90 if cate.Id == CurId {
91 totalRows = cate.Cnt
92 }
93 }
94 this.Data["Cates"] = cates
95 this.Data["CurId"] = CurId
96 this.Data["Level"] = level
97 lists, _, err := models.GetDocList(uid, chanelid, pid, cid, p, listRows, "Id", 0, 1)
98 if err != nil {
99 helper.Logger.Error("SQL语句执行错误:%v", err.Error())
100 }
101 this.Data["Lists"] = lists
102 this.Data["Page"] = helper.Paginations(6, totalRows, listRows, p, "/admin/doc/list/", "uid", uid, "chanelid", chanelid, "pid", pid, "cid", cid)
103 this.Data["Tab"] = "list"
104 this.TplName = "list.html"
105}
106

Callers 5

PrepareMethod · 0.45
PagesMethod · 0.45
GetMethod · 0.45
GetMethod · 0.45
GetMethod · 0.45

Calls 1

Tested by

no test coverage detected