예제 #1
0
     $foods->VITB12 = (double) $input->VITB12;
     $foods->VITA = (double) $input->VITA;
     $foods->VITD = (double) $input->VITD;
     $foods->VITE = (double) $input->VITE;
     $foods->VITK = (double) $input->GRice;
     $foods->GRice = (double) $input->GRice;
     $foods->GVegetable = (string) $input->GVegetable;
     $foods->GFruit = (string) $input->GFruit;
     $foods->GMeat = (string) $input->GMeat;
     $foods->GFat = (string) $input->GFat;
     $foods->GMilk = (string) $input->GMilk;
     $foods->create_by = (string) $input->create_by;
     $foods->create_date = (string) $input->create_date;
     $foods->modify_by = (string) $input->modify_by;
     $foods->modify_date = (string) $input->modify_date;
     $rs = $fs->updateFoods($foods);
     // 		$foodstyle = (array) $input->foodstyle;
     // 		$fs->updateFoodstyle($rs,$foodstyle);
     if ($rs) {
         $app->response()->header('Content-Type', 'application/json');
         echo json_encode($rs);
     } else {
         throw new ResourceNotFoundException();
     }
 } catch (ResourceNotFoundException $e) {
     $app->response()->status(404);
     $app->response()->header('X-Status-Reason', $e->getMessage());
 } catch (Exception $e) {
     $app->response()->status(400);
     $app->response()->header('X-Status-Reason', $e->getMessage());
 }
예제 #2
0
});
$app->put('/foodgroups/:id(/)', 'authenticate', function ($id) use($app) {
    try {
        $fgs = new FoodsService();
        $request = $app->request();
        $mediaType = $request->getMediaType();
        $body = $request->getBody();
        $input = json_decode($body);
        $foodgs = new Foodgroups();
        $foodgs->id = $id;
        $foodgs->fg_name = (string) $input->fg_name;
        $foodgs->create_by = (string) $input->create_by;
        $foodgs->create_date = (string) $input->create_date;
        $foodgs->modify_by = (string) $input->modify_by;
        $foodgs->modify_date = (string) $input->modify_date;
        $rs = $fgs->updateFoods($foodgs);
        if ($rs) {
            $app->response()->header('Content-Type', 'application/json');
            echo json_encode($rs);
        } else {
            throw new ResourceNotFoundException();
        }
    } catch (ResourceNotFoundException $e) {
        $app->response()->status(404);
        $app->response()->header('X-Status-Reason', $e->getMessage());
    } catch (Exception $e) {
        $app->response()->status(400);
        $app->response()->header('X-Status-Reason', $e->getMessage());
    }
});
$app->delete('/foodgroups/:id(/)', 'authenticate', function ($id) use($app) {