| | |
| | | public R<String> add(@RequestBody @Valid XpVehicleModel dto) { |
| | | // 根据名称查询车辆型号,验证是否已存在 |
| | | List<XpVehicleModel> existingModel = xpVehicleModelService.queryByName(dto.getName()); |
| | | if (existingModel != null) { |
| | | if (CollUtil.isNotEmpty(existingModel)) { |
| | | return R.fail("车辆型号名称已存在"); |
| | | } |
| | | boolean b = xpVehicleModelService.save(dto); |
| | |
| | | } |
| | | if(!model.getName().equals(dto.getName())){ |
| | | List<XpVehicleModel> existingModel = xpVehicleModelService.queryByName(dto.getName()); |
| | | if (existingModel != null) { |
| | | if (CollUtil.isNotEmpty(existingModel)) { |
| | | return R.fail("车辆型号名称已存在"); |
| | | } |
| | | } |
| | |
| | | |
| | | @ApiOperation(value = "车型删除", tags = "管理后台-资产-车型管理") |
| | | @DeleteMapping("/logan/inner/xpVehicleModel/deleteById") |
| | | public R<String> deleteById(@RequestParam String id) { |
| | | public R<String> deleteById(@RequestParam Long id) { |
| | | /* |
| | | 1.判断车型是否被 车辆 xp_vehicle使用。 |
| | | 2.判断车型是否被 定价管理 xp_pricing使用。 |
| | |
| | | if (vehicleCount > 0) { |
| | | return R.fail("车辆型号已被车辆使用"); |
| | | } |
| | | R<Long> priceCountByVmidR = xpPricingClient.getPriceCountByVmid(id); |
| | | R<Long> priceCountByVmidR = xpPricingClient.getPriceCountByVmid(id+""); |
| | | if (priceCountByVmidR.getCode() != R.SUCCESS || priceCountByVmidR.getData() == null) { |
| | | return R.fail("根据车型获取定价策略失败"); |
| | | } |
| | | if(priceCountByVmidR.getData()>0){ |
| | | return R.fail("车辆型号已被定价策略使用"); |
| | | } |
| | | boolean b = xpVehicleModelService.logicalRemoveById(id); |
| | | boolean b = xpVehicleModelService.removeById(id); |
| | | if(b){ |
| | | return R.ok(); |
| | | } |