示例#1
0
func CreateNewBrand(context *api.Context) {
	brandStore := context.GetVar("brand_store").(*brand.BrandStore)
	var brand_json = make(map[string]string)
	if err := api.DecodeBody(context.Request, &brand_json); err != nil {
		context.RespondErrf(http.StatusBadRequest, "FAIL_TO_PARSE %v FROM_REQUEST_BODY %v", "brand", err)
		return
	}
	brand, err := brandStore.CreateNewBrand(brand_json["code_name"], brand_json["full_name"])
	if err != nil {
		context.RespondErrf(http.StatusInternalServerError, "CREATE_NEW_BRAND: %v", err)
		return
	}
	context.RespondOK(brand)
}
示例#2
0
func GetAllBrands(context *api.Context) {
	brandStore := context.GetVar("brand_store").(*brand.BrandStore)
	brands, err := brandStore.GetAllBrands(nil)
	if err != nil {
		context.RespondErrf(http.StatusInternalServerError, "GET_ALL_BRAND_ERROR: %v", err)
		return
	}
	context.RespondOK(brands)
}
示例#3
0
func GetAllUsers(context *api.Context) {
	userStore := context.GetVar("user_store").(*auth.UserStore)
	users, err := userStore.AllUsers(nil)
	if err != nil {
		context.RespondErrf(http.StatusInternalServerError, "%v", err)
		return
	}
	context.RespondOK(users)
}