UzyTavPresupController.java 1.8 KB
Newer Older
1
package ec.edu.espe.movilidad.MovilidadWS.Controller;
2

3 4
import ec.edu.espe.movilidad.MovilidadWS.Model.ModelUzyTavPresup;
import ec.edu.espe.movilidad.MovilidadWS.Service.UzyTavPresup.IServiceUzyTavPresup;
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static ec.edu.espe.movilidad.MovilidadWS.Constant.GlobalConstants.V1_API_VERSION;

@RestController
@CrossOrigin(origins = "*")
@RequestMapping(V1_API_VERSION+"/tavpresup")
public class UzyTavPresupController {
    @Autowired
    IServiceUzyTavPresup serviceUzyTavPresup;

    @GetMapping("/exampleFindId/{id}")
    public ResponseEntity<ModelUzyTavPresup> ListarPorID(@PathVariable Long id) {
        return new ResponseEntity<>(serviceUzyTavPresup.ListarPorID(id), HttpStatus.OK);
    }

    @GetMapping("/getAll")
    public ResponseEntity<List<ModelUzyTavPresup>> ListarRegistros() {
        return new ResponseEntity<>(serviceUzyTavPresup.ListarRegistros(), HttpStatus.OK);
    }


    @PostMapping("/guardar")
    public ResponseEntity<ModelUzyTavPresup> guardar(@RequestBody ModelUzyTavPresup modelUzyTavPresup) {
        return new  ResponseEntity<>(serviceUzyTavPresup.guardar(modelUzyTavPresup), HttpStatus.OK);
    }




    @PutMapping("/editar/{id}")
    public ResponseEntity<ModelUzyTavPresup> editar(@PathVariable Long id, @RequestBody ModelUzyTavPresup modelUzyTavPresup) {
        return new  ResponseEntity<>(serviceUzyTavPresup.editar(id, modelUzyTavPresup), HttpStatus.OK);
    }


    @DeleteMapping("/eliminar/{id}")
    public ResponseEntity<Void> eliminar(@PathVariable Long id) {
        serviceUzyTavPresup.eliminar(id);
        return ResponseEntity.ok().build();
    }
}