Skip to content

Instantly share code, notes, and snippets.

@sidneydemoraes
Created April 27, 2017 19:13
Show Gist options
  • Save sidneydemoraes/1fce78550948df36923ef01851cefb4c to your computer and use it in GitHub Desktop.
Save sidneydemoraes/1fce78550948df36923ef01851cefb4c to your computer and use it in GitHub Desktop.
TechTalk - Gradle + Spring Boot + Groovy - Controller
import br.com.smc.meurumo.config.ConfigProperties
import br.com.smc.meurumo.domain.busca.dto.Busca
import br.com.smc.meurumo.domain.busca.service.GerenciadorDeAutoComplete
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Controller
import org.springframework.ui.Model
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestMethod
/**
* Controlador responsável pelos endpoints de navegação comum do site.
*/
@Controller
class IndexController {
/**
* URL-Mapping da Home.
* @return
*/
@RequestMapping(path = "/", method = RequestMethod.GET)
public String index(Model model) {
model.addAttribute("buscaExemplo", new Busca())
model.addAttribute("atividadesDeInteresse", gerenciadorDeAutoComplete.obterListaDeAtividadesDeInteresse())
def cidadesDeExemplo = gerenciadorDeAutoComplete.obterListaDeCidadesDeExemplo()
model.addAttribute("cidadesDeExemplo", cidadesDeExemplo)
model.addAttribute("nomesDasCidadesExemplo", cidadesDeExemplo*.nome.join(", "))
model.addAttribute("classesSociais", gerenciadorDeAutoComplete.obterListaDeClassesSociais())
model.addAttribute("config", config)
return "index";
}
/* Componentes injetados */
@Autowired
private GerenciadorDeAutoComplete gerenciadorDeAutoComplete
@Autowired
private ConfigProperties config
/* Outros componentes */
private def log = LoggerFactory.getLogger(IndexController.class)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment