From cef6ee12bbbb42b8674fc3f9353d08df013115d7 Mon Sep 17 00:00:00 2001 From: zhangzeli <123456> Date: 星期二, 11 一月 2022 15:32:10 +0800 Subject: [PATCH] bug --- xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/CarController.java | 47 +++++++++++++++++++++++++++++++++++++---------- 1 files changed, 37 insertions(+), 10 deletions(-) diff --git a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/CarController.java b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/CarController.java index 7fd6d1d..f7196eb 100644 --- a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/CarController.java +++ b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/CarController.java @@ -4,13 +4,8 @@ import cn.exrick.xboot.core.common.utils.ResultUtil; import cn.exrick.xboot.core.common.vo.PageVo; import cn.exrick.xboot.core.common.vo.Result; -import cn.exrick.xboot.your.entity.AddOil; -import cn.exrick.xboot.your.entity.Car; -import cn.exrick.xboot.your.entity.DrivingRecord; -import cn.exrick.xboot.your.entity.Suggest; -import cn.exrick.xboot.your.service.IAddOilService; -import cn.exrick.xboot.your.service.ICarService; -import cn.exrick.xboot.your.service.IDrivingRecordService; +import cn.exrick.xboot.your.entity.*; +import cn.exrick.xboot.your.service.*; import cn.exrick.xboot.your.vo.CarVo; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.Wrapper; @@ -46,6 +41,9 @@ private IAddOilService iAddOilService; @Autowired private IDrivingRecordService iDrivingRecordService; + @Autowired + private ICustomerService iCustomerService; + @RequestMapping(value = "/get/{id}", method = RequestMethod.GET) @ApiOperation(value = "閫氳繃id鑾峰彇") @@ -65,10 +63,11 @@ @RequestMapping(value = "/getAll", method = RequestMethod.GET) @ApiOperation(value = "鑾峰彇鍏ㄩ儴鏁版嵁") - public Result<List<CarVo>> getAll(String beginTime,String endTime) { + public Result<List<CarVo>> getAll(String beginTime,String endTime,PageVo page) { List<CarVo> carVos = new ArrayList<>(); - List<Car> list = iCarService.getAll2(); - for (Car car:list){ + + IPage<Car> list = iCarService.getAll2(PageUtil.initMpPage(page)); + for (Car car:list.getRecords()){ CarVo carVo = new CarVo(); //鍔犳补淇℃伅 QueryWrapper<AddOil> queryWrapper = new QueryWrapper<>(); @@ -84,6 +83,14 @@ wrapper.le(endTime!=null && endTime!="","in_time",endTime); queryWrapper.le(endTime!=null && endTime!="","add_date",beginTime); + + QueryWrapper<OrderTask> wrapper1 = new QueryWrapper<>(); + + + wrapper1.eq("car_id",car.getId()); + wrapper1.ge(beginTime!=null && beginTime!="","send_date",beginTime); + wrapper1.le(endTime!=null && endTime!="","send_date",endTime); + DrivingRecord drivingRecord = iDrivingRecordService.getOne(wrapper); @@ -101,6 +108,7 @@ carVo.setCar(car); carVos.add(carVo); + carVo.setTotal(list.getTotal()); } return new ResultUtil<List<CarVo>>().setData(carVos); } @@ -141,9 +149,28 @@ @ApiOperation(value = "缂栬緫鎴栨洿鏂版暟鎹�") public Result<Car> saveOrUpdate(Car car) { + QueryWrapper<Car> wrapper = new QueryWrapper<>(); + QueryWrapper<Car> wrapper1 = new QueryWrapper<>(); + if (!car.getUserId().equals("")){ + wrapper.eq("user_id",car.getUserId()); + Car car1 = iCarService.getOne(wrapper); + if (car1!=null && !car1.getId().equals(car.getId())){ + return new ResultUtil<Car>().setErrorMsg("璇ラ┚椹跺憳宸茶鍏朵粬杞﹁締缁戝畾,璇峰厛瑙g粦"); + } + } + + if (!car.getFollowUserId().equals("")){ + wrapper1.eq("follow_user_id",car.getFollowUserId()); + Car car1 = iCarService.getOne(wrapper1); + if (car1!=null && !car1.getId().equals(car.getId())){ + return new ResultUtil<Car>().setErrorMsg("璇ラ厤閫佸憳宸茶鍏朵粬杞﹁締缁戝畾,璇峰厛瑙g粦"); + } + } + if (iCarService.saveOrUpdate(car)) { return new ResultUtil<Car>().setData(car); } + return new ResultUtil<Car>().setErrorMsg("鎿嶄綔澶辫触"); } -- Gitblit v1.9.1