MCPcopy Index your code
hub / github.com/TruthHun/BookStack / Category

Method Category

controllers/ManagerController.go:933–967  ·  view source on GitHub ↗

分类管理

()

Source from the content-addressed store, hash-verified

931
932// 分类管理
933func (this *ManagerController) Category() {
934 Model := new(models.Category)
935 if strings.ToLower(this.Ctx.Request.Method) == "post" {
936 //新增分类
937 pid, _ := this.GetInt("pid")
938 if err := Model.AddCates(pid, this.GetString("cates")); err != nil {
939 this.JsonResult(1, "新增失败:"+err.Error())
940 }
941 this.JsonResult(0, "新增成功")
942 }
943
944 //查询所有分类
945 cates, err := Model.GetCates(-1, -1)
946 if err != nil {
947 beego.Error(err)
948 }
949
950 var parents []models.Category
951 for idx, item := range cates {
952 if strings.TrimSpace(item.Icon) == "" { //赋值为默认图片
953 item.Icon = "/static/images/icon.png"
954 } else {
955 item.Icon = utils.ShowImg(item.Icon)
956 }
957 if item.Pid == 0 {
958 parents = append(parents, item)
959 }
960 cates[idx] = item
961 }
962
963 this.Data["Parents"] = parents
964 this.Data["Cates"] = cates
965 this.Data["IsCategory"] = true
966 this.TplName = "manager/category.html"
967}
968
969// 更新分类字段内容
970func (this *ManagerController) UpdateCate() {

Callers

nothing calls this directly

Calls 5

ShowImgFunction · 0.92
AddCatesMethod · 0.80
JsonResultMethod · 0.80
GetCatesMethod · 0.80
appendFunction · 0.50

Tested by

no test coverage detected