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.MedioPago; 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("/medio") public class MedioPagoController implements Serializable { @Autowired FacadeService facadeService; @RequestMapping(value = "/list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<?> getAll() { List<MedioPago> list = facadeService.getMedioPagoDAO().getAll(); if (!list.isEmpty()) { return new ResponseEntity<>(list, HttpStatus.OK); } else { return new ResponseEntity<>(HttpStatus.BAD_REQUEST); } } }