| | |
| | | package com.xiaopeng.maintenance.controller; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.xiaopeng.api.feignClient.operation.XpPricingClient; |
| | | 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; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.validation.Valid; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | | @Api(tags = "车辆检测") |
| | | @Api(tags = "车型") |
| | | @RestController |
| | | @RequestMapping("") |
| | | public class XpVehicleModelController { |
| | |
| | | private XpPricingClient xpPricingClient; |
| | | |
| | | |
| | | @ApiOperation(value = "列表", tags = "管理后台-列表") |
| | | @PostMapping("/logan/inner/xpVehicleModel/pageList") |
| | | @ApiOperation(value = "车型分页列表", tags = "管理后台-资产-车型管理") |
| | | @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 = "管理后台-根据ID查询") |
| | | @GetMapping("/logan/inner/xpVehicleModel/getById") |
| | | |
| | | |
| | | @PostMapping("/logan/inner/xpVehicleModel/listByIds") |
| | | @ApiOperation(value = "车型根据ID列表批量查询", tags = {"内部接口"}) |
| | | public R<List<XpVehicleModel>> listByIds(@RequestBody List<String> ids) { |
| | | if (CollUtil.isEmpty(ids)) { |
| | | return R.ok(new ArrayList<>()); |
| | | } |
| | | return R.ok(xpVehicleModelService.listByIds(ids)); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "车型根据ID查询", tags = "管理后台-资产-车型管理") |
| | | @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") |
| | | @ApiOperation(value = "车型新增", tags = "管理后台-资产-车型管理") |
| | | @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); |
| | |
| | | return R.fail("保存失败"); |
| | | } |
| | | |
| | | @ApiOperation(value = "编辑", tags = "管理后台-编辑") |
| | | @PostMapping("/logan/inner/xpVehicleModel/edit") |
| | | @ApiOperation(value = "车型编辑", tags = "管理后台-资产-车型管理") |
| | | @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("车辆型号名称已存在"); |
| | | } |
| | | } |
| | |
| | | return R.fail("保存失败"); |
| | | } |
| | | |
| | | @ApiOperation(value = "删除", tags = "管理后台-删除") |
| | | @DeleteMapping("/logan/inner/xpVehicleModel/deleteById") |
| | | public R<String> deleteById(@RequestParam String id) { |
| | | @ApiOperation(value = "车型删除", tags = "管理后台-资产-车型管理") |
| | | @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") |
| | | @ApiOperation(value = "车型全列表查询", tags = "管理后台-车型全列表查询") |
| | | @PostMapping("/api/v1/xpVehicleModel/list") |
| | | public R<List<XpVehicleModel>> list() { |
| | | List<XpVehicleModel> list = xpVehicleModelService.queryList(); |
| | | return R.ok(list); |
| | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @GetMapping("/drainage/v1/vehicleModel/list") |
| | | @ApiOperation(value = "查询可使用的车型列表", notes = "流量接入-基础信息") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "token", name = "token", required = true, paramType = "header") |
| | | }) |
| | | public R<List<XpVehicleModel>> getVehicleModelList() { |
| | | List<XpVehicleModel> list = xpVehicleModelService.queryList(); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | |
| | | |