| | |
| | | import com.xiaopeng.api.model.maintenance.XpVehicleModel; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.web.page.PageInfo; |
| | | import com.xiaopeng.common.log.annotation.AdminOperationLog; |
| | | import com.xiaopeng.common.log.enums.AdminBusinessType; |
| | | import com.xiaopeng.common.log.enums.AdminOperationType; |
| | | import com.xiaopeng.maintenance.model.query.XpVehicleModelPageQuery; |
| | | import com.xiaopeng.maintenance.service.IXpVehicleModelService; |
| | | import io.swagger.annotations.Api; |
| | |
| | | |
| | | |
| | | @ApiOperation(value = "车型分页列表", tags = "管理后台-资产-车型管理") |
| | | @PostMapping("/logan/inner/xpVehicleModel/pageList") |
| | | @PostMapping("/api/v1/xpVehicleModel/pageList") |
| | | public R<PageInfo<XpVehicleModel>> pageList(@RequestBody XpVehicleModelPageQuery query) { |
| | | PageInfo<XpVehicleModel> pageInfo = xpVehicleModelService.pageList(query); |
| | | return R.ok(pageInfo); |
| | |
| | | |
| | | |
| | | @ApiOperation(value = "车型根据ID查询", tags = "管理后台-资产-车型管理") |
| | | @GetMapping("/logan/inner/xpVehicleModel/getById") |
| | | @GetMapping("/api/v1/xpVehicleModel/getById") |
| | | public R<XpVehicleModel> getById(@RequestParam String id) { |
| | | if (id == null || id.isEmpty()) { |
| | | return R.fail("参数错误"); |
| | |
| | | |
| | | |
| | | @ApiOperation(value = "车型新增", tags = "管理后台-资产-车型管理") |
| | | @PostMapping("/logan/inner/xpVehicleModel/add") |
| | | @PostMapping("/api/v1/xpVehicleModel/add") |
| | | @AdminOperationLog( |
| | | businessType = AdminBusinessType.VEHICLE_MODEL_MANAGEMENT, |
| | | operationType = AdminOperationType.ADD, |
| | | content = "车型新增", |
| | | appendRequestData = true |
| | | ) |
| | | 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); |
| | |
| | | } |
| | | |
| | | @ApiOperation(value = "车型编辑", tags = "管理后台-资产-车型管理") |
| | | @PostMapping("/logan/inner/xpVehicleModel/edit") |
| | | @PostMapping("/api/v1/xpVehicleModel/edit") |
| | | @AdminOperationLog( |
| | | businessType = AdminBusinessType.VEHICLE_MODEL_MANAGEMENT, |
| | | operationType = AdminOperationType.EDIT, |
| | | content = "车型编辑", |
| | | appendRequestData = true |
| | | ) |
| | | public R<String> edit(@RequestBody @Valid XpVehicleModel dto) { |
| | | if(dto.getId() == null){ |
| | | return R.fail("参数错误"); |
| | |
| | | } |
| | | 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) { |
| | | @DeleteMapping("/api/v1/xpVehicleModel/deleteById") |
| | | @AdminOperationLog( |
| | | businessType = AdminBusinessType.VEHICLE_MODEL_MANAGEMENT, |
| | | operationType = AdminOperationType.DELETE, |
| | | contentExpression = "'车型删除,id=' + #p0", |
| | | appendRequestData = false |
| | | ) |
| | | 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(); |
| | | } |
| | |
| | | |
| | | |
| | | @ApiOperation(value = "车型全列表查询", tags = "管理后台-车型全列表查询") |
| | | @PostMapping("/logan/inner/xpVehicleModel/list") |
| | | @PostMapping("/api/v1/xpVehicleModel/list") |
| | | public R<List<XpVehicleModel>> list() { |
| | | List<XpVehicleModel> list = xpVehicleModelService.queryList(); |
| | | return R.ok(list); |