Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.ar.dev.tierra.api.controller; import com.ar.dev.tierra.api.model.Sexo; import com.ar.dev.tierra.api.resource.FacadeService; import java.io.Serializable; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; /** * * @author PauloGaldo */ @RestController @RequestMapping("/sexo") public class SexoController implements Serializable { @Autowired FacadeService facadeService; @RequestMapping(value = "/list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<?> getAll() { List<Sexo> sexo = facadeService.getSexoDAO().getAll(); if (!sexo.isEmpty()) { return new ResponseEntity<>(sexo, HttpStatus.OK); } else { return new ResponseEntity<>(HttpStatus.BAD_REQUEST); } } }