diff --git a/src/main/java/com/sczx/car/controller/CarController.java b/src/main/java/com/sczx/car/controller/CarController.java index 770c7f7..44eec0f 100644 --- a/src/main/java/com/sczx/car/controller/CarController.java +++ b/src/main/java/com/sczx/car/controller/CarController.java @@ -35,4 +35,11 @@ public class CarController { public Result getCarByCarCondition(@RequestBody CarQueryConditionReq req){ return Result.ok(carService.getCarByCondition(req)); } + + + @ApiOperation(value = "统计门店车辆数量") + @GetMapping("/countCarByStoreId") + public Result countCarByStoreId(@RequestParam(name = "storeId") Long storeId){ + return Result.ok(carService.countCarByStoreId(storeId)); + } } diff --git a/src/main/java/com/sczx/car/service/CarService.java b/src/main/java/com/sczx/car/service/CarService.java index 918f9fb..2ca3f06 100644 --- a/src/main/java/com/sczx/car/service/CarService.java +++ b/src/main/java/com/sczx/car/service/CarService.java @@ -16,4 +16,11 @@ public interface CarService { * @return */ CarDTO getCarByCondition(CarQueryConditionReq req); + + /** + * 根据门店查车辆数量 + * @param storeId + * @return + */ + Long countCarByStoreId(Long storeId); } diff --git a/src/main/java/com/sczx/car/service/impl/CarServiceImpl.java b/src/main/java/com/sczx/car/service/impl/CarServiceImpl.java index 25c9e60..9c40d7b 100644 --- a/src/main/java/com/sczx/car/service/impl/CarServiceImpl.java +++ b/src/main/java/com/sczx/car/service/impl/CarServiceImpl.java @@ -35,4 +35,9 @@ public class CarServiceImpl implements CarService { CarPO carPO = carRepo.getOne(queryWrapper); return CarConvert.INSTANCE.poToDto(carPO); } + + @Override + public Long countCarByStoreId(Long storeId) { + return carRepo.count(new LambdaQueryWrapper().eq(CarPO::getStoreId, storeId)); + } }