-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathClienteController.java
More file actions
46 lines (40 loc) · 1.42 KB
/
ClienteController.java
File metadata and controls
46 lines (40 loc) · 1.42 KB
1
2
3
4
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
package com.example.project.management.Controller;
import com.example.project.management.Model.Cliente;
import com.example.project.management.Service.ClienteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/clientes")
public class ClienteController {
@Autowired
private ClienteService clienteService;
// Obtener todos los clientes
@GetMapping
public ResponseEntity<List<Cliente>> getAll() {
return ResponseEntity.ok(clienteService.getAll());
}
// Obtener un cliente por id
@GetMapping("/{id}")
public ResponseEntity<Cliente> getById(Integer id) {
return ResponseEntity.ok(clienteService.getById(id));
}
// Crear un nuevo cliente
@PostMapping
public ResponseEntity<Cliente> save(@RequestBody Cliente cliente) {
return ResponseEntity.ok(clienteService.save(cliente));
}
// // Actualizar un cliente
// @PutMapping("/{id}")
// public ResponseEntity<Cliente> update(Integer id, Cliente cliente) {
// return ResponseEntity.ok(clienteService.update(id, cliente));
// }
//
// // Eliminar un cliente
// @DeleteMapping("/{id}")
// public ResponseEntity<Void> delete(Integer id) {
// clienteService.delete(id);
// return ResponseEntity.ok().build();
// }
}