From ae32c3a7d77e2ed114555623c70e3fbd1d6aba59 Mon Sep 17 00:00:00 2001 From: wang-hao-jie <1550036656@qq.com> Date: 星期四, 10 三月 2022 08:47:45 +0800 Subject: [PATCH] 违章记录 --- xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/CarController.java | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 54 insertions(+), 5 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 c6a087a..df00ea4 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 @@ -2,8 +2,10 @@ import cn.exrick.xboot.core.common.utils.PageUtil; import cn.exrick.xboot.core.common.utils.ResultUtil; +import cn.exrick.xboot.core.common.utils.SecurityUtil; import cn.exrick.xboot.core.common.vo.PageVo; import cn.exrick.xboot.core.common.vo.Result; +import cn.exrick.xboot.core.entity.User; import cn.exrick.xboot.your.entity.*; import cn.exrick.xboot.your.service.*; import cn.exrick.xboot.your.vo.CarVo; @@ -42,7 +44,7 @@ @Autowired private IDrivingRecordService iDrivingRecordService; @Autowired - private ICustomerService iCustomerService; + private SecurityUtil securityUtil; @RequestMapping(value = "/get/{id}", method = RequestMethod.GET) @@ -59,6 +61,16 @@ List<Car> list = iCarService.list(); return new ResultUtil<List<Car>>().setData(list); + } + + @RequestMapping(value = "/getBindCar", method = RequestMethod.GET) + @ApiOperation(value = "鑾峰彇缁戝畾鐨勮溅杈�") + public Result<Car> getBindCar() { + String userId = securityUtil.getCurrUser().getId(); + QueryWrapper<Car> carQueryWrapper = new QueryWrapper<Car>(); + carQueryWrapper.eq("user_id",userId).or().eq("follow_user_id",userId); + Car car = iCarService.getOne(carQueryWrapper); + return new ResultUtil<Car>().setData(car); } @RequestMapping(value = "/getAll", method = RequestMethod.GET) @@ -181,10 +193,47 @@ @RequestMapping(value = "/bindCar", method = RequestMethod.POST) @ApiOperation(value = "缁戝畾杞﹁締浜哄憳") - public Result<Car> bindCar(String carId,String userId) { - Car car = iCarService.getById(carId); - car.setUserId(userId); - iCarService.saveOrUpdate(car); + public Result<Car> bindCar(String carId,String userId) {//A杞﹀紶涓� 鏉庡洓 B杞︾帇浜旓紝璧靛叚 + User user = securityUtil.getCurrUser(); + QueryWrapper<Car> queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("user_id",user.getId()).or().eq("follow_user_id",user.getId()); + Car one = iCarService.getOne(queryWrapper);//鍘熸潵鐨勮溅 + + if(one!=null){ + //濡傛灉杩樻槸閫変簡鍘熸潵鐨勮溅鍒欎笉鐢ㄥ彉 + if(one.getId().equals(carId)){ + + }else{ + //濡傛灉閫変簡鍙︿竴杈嗚溅锛屽厛鎶婂師鏉ョ殑杞︾殑浜哄憳娓呯┖ + if(user.getType2()==0){ + one.setUserId(""); + }else{ + one.setFollowUserId(""); + } + iCarService.saveOrUpdate(one); + + //缁戝畾涓婃柊閫夌殑杞� + Car car = iCarService.getById(carId); + if(car!=null){ + if(user.getType2()==0){ + car.setUserId(user.getId()); + }else{ + car.setFollowUserId(user.getId()); + } + iCarService.saveOrUpdate(car); + } + } + }else{ + Car car = iCarService.getById(carId); + if(car!=null){ + if(user.getType2()==0){ + car.setUserId(user.getId()); + }else{ + car.setFollowUserId(user.getId()); + } + iCarService.saveOrUpdate(car); + } + } return ResultUtil.success("缁戝畾鎴愬姛"); } -- Gitblit v1.9.1