<commit_before>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;<commit_msg>Integrate two methods<commit_after>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 FoodController {
	
	@Autowired
	FoodListDao foodListDao;
	
	private ObjectMapper mapper = new ObjectMapper();
	private String jsonString;
	
	
	@ResponseBody
	@RequestMapping(method=RequestMethod.GET, produces = "application/json; charset=UTF-8")
	public String getFoodList(HttpServletRequest req, HttpServletResponse res, @RequestParam(value = "category", required = false) String category) throws JsonProcessingException
	{
		try {
			if(category==null)
				jsonString = mapper.writeValueAsString(foodListDao.selectFoodList());
			else
				jsonString = mapper.writeValueAsString(foodListDao.selectFoodListByCategory(category));
		} catch (JsonProcessingException e) {
			throw e;
{'fraction_non_alphanumeric': 0.09369951534733441, 'fraction_numerical': 0.0009693053311793214, 'mean_word_length': 6.663366336633663, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4155929', 'n_tokens_mistral': 911, 'n_tokens_neox': 854, 'n_words': 163}