// view for list model data func (this *CategoryAdminRouter) List() { var cats []models.Category qs := models.Categories().RelatedSel() if err := this.SetObjects(qs, &cats); err != nil { this.Data["Error"] = err beego.Error(err) } }
func (form *CategoryAdminForm) Valid(v *validation.Validation) { qs := models.Categories() if models.CheckIsExist(qs, "Name", form.Name, form.Id) { v.SetError("Name", "admin.field_need_unique") } if models.CheckIsExist(qs, "Slug", form.Slug, form.Id) { v.SetError("Slug", "admin.field_need_unique") } }
func ListCategories(cats *[]models.Category) (int64, error) { return models.Categories().OrderBy("-order").All(cats) }
func (this *CategoryAdminRouter) ObjectQs() orm.QuerySeter { return models.Categories().RelatedSel() }