package com.ejie.ab79.control.AB63;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
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.ejie.ab79.model.AB63.Categorias;
import com.ejie.ab79.service.AB63.CategoriasService;

/**
 * CategoriasController  
 * 
 *  
 */

@Controller
@RequestMapping(value = "/categorias")

public class CategoriasController {

	private static final Logger logger = LoggerFactory.getLogger(CategoriasController.class);

	@Autowired
	private CategoriasService categoriasService;

	@RequestMapping(method = RequestMethod.GET)
	public @ResponseBody List<Categorias> getAll(@ModelAttribute Categorias filterCategorias,
			@RequestParam(value = "tipoEstablecimiento", required = false) String idTipoEstablecimiento) {
		CategoriasController.logger.info("[GET - find_ALL] : Obtener Categorias por filtro");

		if (idTipoEstablecimiento != null) {
			filterCategorias.setIdTipoEstablecimiento(idTipoEstablecimiento);
		}

		return this.categoriasService.findAll(filterCategorias, null);
	}

}
