Пример #1
0
// @name 物品分类列表
func ItemCateList(w http.ResponseWriter, r *http.Request) {

	var cate model.ItemCate

	v, err := cate.FindAll(0, 0)
	if err != nil {
		NewError(w, ErrInternalServer(err.Error()))
		return
	}

	Response(w, "findall_item_cate", v)

}
Пример #2
0
func CheckCateName(w http.ResponseWriter, r *http.Request) {
	name := r.FormValue("name")
	if name == "" {
		NewError(w, ErrMissParam("name"))
		return
	}

	var cate model.ItemCate

	cate.Name = name

	Response(w, "check_item_cate_name", cate.CheckName())

}
Пример #3
0
// @name 删除分类
func DelItemCate(w http.ResponseWriter, r *http.Request) {
	id := r.FormValue("id")
	if id == "" {
		NewError(w, ErrMissParam("id"))
		return
	}
	if !IsObjectId(id) {
		NewError(w, ErrForbidden("id must be ObjectId format"))
	}

	var cate model.ItemCate

	err := cate.DelById(id)
	if err != nil {
		NewError(w, ErrInternalServer(err.Error()))
		return
	}

	Response(w, "del_item_cate", "")

}