Skip to content

Commit

Permalink
Merge pull request #30 from Best-offer-finder/chore-clean-car-models-…
Browse files Browse the repository at this point in the history
…code

Clean car models code, change endpoint
  • Loading branch information
Rivixer authored Jun 22, 2024
2 parents d4246e2 + 6c2669e commit 4933fed
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@
@RequestMapping("/api/cars")
public class CarController {

private final CarService carBrandService;
private final CarService carService;

public CarController(CarService carBrandService) {
this.carBrandService = carBrandService;
public CarController(CarService carService) {
this.carService = carService;
}

@GetMapping("list")
public List<CarBrandDto> get() {
return carBrandService.list().stream().map((carBrand) -> CarBrandDto.of(carBrand.getId(), carBrand.getName(), carBrand.getSearchKey())).toList();
return carService.list().stream().map((carBrand) -> CarBrandDto.of(carBrand.getId(), carBrand.getName(), carBrand.getSearchKey())).toList();
}

@GetMapping("/{brand_id}")
public List<CarModelDto> getModels(@PathVariable("brand_id") Integer brandId) {
return carBrandService.getModels(brandId).stream()
@GetMapping("{id}/models")
public List<CarModelDto> getModels(@PathVariable("id") Integer brandId) {
return carService.getModels(brandId).stream()
.map(carModel -> CarModelDto.of(
carModel.getId(),
carModel.getName(),
Expand Down

0 comments on commit 4933fed

Please sign in to comment.