package com.danchu.momuck.controller;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.danchu.momuck.dao.FoodListDao;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

@Controller
@RequestMapping(value = "/foods")
public class ListController {
	
	@Autowired
	FoodListDao foodListDao;
	
	private ObjectMapper mapper = new ObjectMapper();
	private String jsonString;
	
	
	@ResponseBody
	@RequestMapping(method=RequestMethod.GET, produces = "text/json; charset=UTF-8")
	public String getAllFoodList(HttpServletRequest req, HttpServletResponse res) throws JsonProcessingException
	{
		try {
			jsonString = mapper.writeValueAsString(foodListDao.selectAllFood());
		} catch (JsonProcessingException e) {
			throw e;
		}
		return jsonString;
	}
	
	@ResponseBody
	@RequestMapping(params="category", method = RequestMethod.GET, produces = "text/json; charset=UTF-8")
	public String getCategoryFoodList(HttpServletRequest req, HttpServletResponse res, @RequestParam("category") String category) throws JsonProcessingException
	{
		try {
			jsonString = mapper.writeValueAsString(foodListDao.selectCategoryFood(category));
		} catch (JsonProcessingException e) {
			throw e;
		}
		return jsonString;
	}
}

@@ -701,20 +701,20 @@
 c class 
-List
+Food
 Controll
@@ -905,36 +905,43 @@
 ET, produces = %22
-text
+application
 /json; charset=U
@@ -965,19 +965,16 @@
 ring get
-All
 FoodList
@@ -1021,16 +1021,85 @@
 onse res
+, @RequestParam(value = %22category%22, required = false) String category
 ) throws
@@ -1126,32 +1126,55 @@
 tion%0A%09%7B%0A%09%09try %7B%0A
+%09%09%09if(category==null)%0A%09
 %09%09%09jsonString = 
@@ -1221,389 +1221,30 @@
 lect
-All
 Food
+List
 ());%0A%09%09
-%7D catch (JsonProcessingException e) %7B%0A%09%09%09throw e;%0A%09%09%7D%0A%09%09return jsonString;%0A%09%7D%0A%09%0A%09@ResponseBody%0A%09@RequestMapping(params=%22category%22, method = RequestMethod.GET, produces = %22text/json; charset=UTF-8%22)%0A%09public String getCategoryFoodList(HttpServletRequest req, HttpServletResponse res, @RequestParam(%22category%22) String category) throws JsonProcessingException%0A%09%7B%0A%09%09try %7B%0A
+%09else%0A%09
 %09%09%09j
@@ -1303,16 +1303,26 @@
 lect
+FoodListBy
 Category
 Food
@@ -1317,20 +1317,16 @@
 Category
-Food
 (categor

Integrate two methods