package ec.edu.espe.movilidad.MovilidadWS.Controller; import ec.edu.espe.movilidad.MovilidadWS.Dto.DtoUzyTPerfil; import ec.edu.espe.movilidad.MovilidadWS.Service.UzyTPerfil.IServiceUzyTPerfil; import org.springframework.beans.factory.annotation.Autowired; 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 + "/perfil") public class UzyTPerfilController { private final IServiceUzyTPerfil serviceUzyTPerfil; @Autowired public UzyTPerfilController(IServiceUzyTPerfil serviceUzyTPerfil) { this.serviceUzyTPerfil = serviceUzyTPerfil; } @GetMapping("/exampleFindId/{id}") public ResponseEntity<DtoUzyTPerfil> ListarPorID(@PathVariable Long id) { DtoUzyTPerfil dto = serviceUzyTPerfil.ListarPorID(id); return ResponseEntity.ok(dto); } @GetMapping("/getAll") public ResponseEntity<List<DtoUzyTPerfil>> ListarRegistros() { List<DtoUzyTPerfil> dtos = serviceUzyTPerfil.ListarRegistros(); return ResponseEntity.ok(dtos); } @PostMapping("/guardar") public ResponseEntity<DtoUzyTPerfil> guardar(@RequestBody DtoUzyTPerfil dtoUzyTPerfil) { DtoUzyTPerfil savedDto = serviceUzyTPerfil.guardar(dtoUzyTPerfil); return ResponseEntity.ok(savedDto); } @DeleteMapping("/eliminar/{id}") public ResponseEntity<Void> eliminar(@PathVariable Long id) { serviceUzyTPerfil.eliminar(id); return ResponseEntity.ok().build(); } @PutMapping("/editar/{id}") public ResponseEntity<DtoUzyTPerfil> editar(@PathVariable Long id, @RequestBody DtoUzyTPerfil dtoUzyTPerfil) { DtoUzyTPerfil editedDto = serviceUzyTPerfil.editar(id, dtoUzyTPerfil); return ResponseEntity.ok(editedDto); } }