package com.youzi.rest.controller;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.converter.json.MappingJacksonValue;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.youzi.rest.pojo.CatResult;
import com.youzi.rest.service.ItemCatService;

@Controller
@RequestMapping(value = "/item/cat")
public class ItemCatController {

	@Autowired
	private ItemCatService itemCatService;
	
	@RequestMapping(value = "/list")
	@ResponseBody
	public Object getItemCatList(String callback){
		CatResult catResult = itemCatService.getCatResult();
		if(StringUtils.isBlank(callback)){
			return catResult;
		}
		MappingJacksonValue value = new MappingJacksonValue(catResult);
		value.setJsonpFunction(callback);
		return value;
	}
}
