From 6e2fb4d874707e83433befc18319354145c9584b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Chhk=E2=80=9D?= <“hhk@mail.com”> Date: Thu, 8 Aug 2024 10:56:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=A6=E8=BE=86=E5=93=81=E7=89=8C=E5=9E=8B?= =?UTF-8?q?=E5=8F=B7=E4=BC=98=E5=8C=96;=E6=B3=A8=E9=87=8A=E8=A1=A5?= =?UTF-8?q?=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/admin/CarBrandController.java | 14 +-- .../controller/admin/CarModelController.java | 2 +- .../module/custom/mapper/CarMainMapper.java | 8 ++ .../custom/service/CarModelService.java | 2 +- .../service/impl/CarBrandServiceImpl.java | 32 ++++++- .../service/impl/CarMainServiceImpl.java | 23 +++-- .../service/impl/CarModelServiceImpl.java | 92 +++++++++---------- .../resources/mapper/custom/CarMainMapper.xml | 26 +++++- 8 files changed, 127 insertions(+), 72 deletions(-) diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/CarBrandController.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/CarBrandController.java index 18c476e8..8f438392 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/CarBrandController.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/CarBrandController.java @@ -39,13 +39,13 @@ public class CarBrandController { private CarBrandService carBrandService; /** - * 创建车辆品牌维护 + * 创建车辆品牌 * * @param createReqVO * @return */ @PostMapping("/create") - @Operation(summary = "创建车辆品牌维护") + @Operation(summary = "创建车辆品牌") @PreAuthorize("@ss.hasPermission('base:car-brand:create')") public CommonResult createCarBrand(@RequestBody CarBrandReqVO createReqVO) { return success(carBrandService.createCarBrand(createReqVO)); @@ -58,7 +58,7 @@ public class CarBrandController { * @return */ @PutMapping("/update") - @Operation(summary = "更新车辆品牌维护") + @Operation(summary = "更新车辆品牌") @PreAuthorize("@ss.hasPermission('base:car-brand:update')") public CommonResult updateCarBrand(@RequestBody CarBrandReqVO updateReqVO) { carBrandService.updateCarBrand(updateReqVO); @@ -66,7 +66,7 @@ public class CarBrandController { } @DeleteMapping("/delete") - @Operation(summary = "删除车辆品牌维护") + @Operation(summary = "删除车辆品牌") @Parameter(name = "id", description = "编号", required = true) @PreAuthorize("@ss.hasPermission('base:car-brand:delete')") public CommonResult deleteCarBrand(@RequestParam("id") String id) { @@ -75,7 +75,7 @@ public class CarBrandController { } @GetMapping("/get") - @Operation(summary = "获得车辆品牌维护") + @Operation(summary = "获得车辆品牌") @Parameter(name = "id", description = "编号", required = true, example = "1024") @PreAuthorize("@ss.hasPermission('base:car-brand:query')") public CommonResult getCarBrand(@RequestParam("id") String id) { @@ -84,7 +84,7 @@ public class CarBrandController { } @GetMapping("/page") - @Operation(summary = "获得车辆品牌维护分页") + @Operation(summary = "获得车辆品牌分页") @PreAuthorize("@ss.hasPermission('base:car-brand:query')") public CommonResult> getCarBrandPage(CarBrandReqVO pageReqVO) { IPage pageResult = carBrandService.getCarBrandPage(pageReqVO); @@ -92,7 +92,7 @@ public class CarBrandController { } @GetMapping("/export-excel") - @Operation(summary = "导出车辆品牌维护 Excel") + @Operation(summary = "导出车辆品牌 Excel") @PreAuthorize("@ss.hasPermission('base:car-brand:export')") @ApiAccessLog(operateType = EXPORT) public void exportCarBrandExcel(CarBrandReqVO pageReqVO, diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/CarModelController.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/CarModelController.java index 22155098..af569312 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/CarModelController.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/CarModelController.java @@ -150,7 +150,7 @@ public class CarModelController { * @return */ @PostMapping("/searchBrand") - @Operation(summary = "筛选品牌型号") + @Operation(summary = "获取品牌型号级联下拉") @PreAuthorize("@ss.hasPermission('base:car-main:query')") @Parameter(name = "id", description = "编号", required = true, example = "1024") public CommonResult> searchBrand(@RequestBody CarModelReqVO reqVO) { diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/mapper/CarMainMapper.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/mapper/CarMainMapper.java index e69e856f..f4223db8 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/mapper/CarMainMapper.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/mapper/CarMainMapper.java @@ -29,6 +29,14 @@ public interface CarMainMapper extends BaseMapper { */ IPage findPage(Page page, @Param("dto") CarMainReqVO pageReqVO); + /** + * 获得车辆信息分页 + * + * @param id + * @return + */ + CarMainRespVO findOne(@Param("id") String id); + /** diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CarModelService.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CarModelService.java index ba97f098..793ee7bd 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CarModelService.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CarModelService.java @@ -67,7 +67,7 @@ public interface CarModelService extends IService { IPage getCarModelPageByBrandId(CarModelReqVO pageReqVO); /** - * 筛选品牌型号 + * 获取品牌型号级联下拉 * * @param reqVO * @return diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CarBrandServiceImpl.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CarBrandServiceImpl.java index dfd890d4..4cb46d9e 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CarBrandServiceImpl.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CarBrandServiceImpl.java @@ -9,9 +9,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import org.springframework.validation.annotation.Validated; -import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import java.util.UUID; @@ -25,6 +23,12 @@ import java.util.UUID; @Validated public class CarBrandServiceImpl extends ServiceImpl implements CarBrandService { + /** + * 创建车辆品牌维护 + * + * @param createReqVO 创建信息 + * @return 编号 + */ @Override public String createCarBrand(CarBrandReqVO createReqVO) { // 插入 @@ -35,6 +39,11 @@ public class CarBrandServiceImpl extends ServiceImpl i return carBrand.getId(); } + /** + * 更新车辆品牌维护 + * + * @param updateReqVO 更新信息 + */ @Override public void updateCarBrand(CarBrandReqVO updateReqVO) { @@ -43,19 +52,34 @@ public class CarBrandServiceImpl extends ServiceImpl i baseMapper.updateById(updateObj); } + /** + * 删除车辆品牌维护 + * + * @param id 编号 + */ @Override public void deleteCarBrand(String id) { - // 删除 baseMapper.deleteById(id); } - + /** + * 获得车辆品牌维护 + * + * @param id 编号 + * @return 车辆品牌维护 + */ @Override public CarBrand getCarBrand(String id) { return baseMapper.selectById(id); } + /** + * 获得车辆品牌维护分页 + * + * @param pageReqVO 分页查询 + * @return 车辆品牌维护分页 + */ @Override public IPage getCarBrandPage(CarBrandReqVO pageReqVO) { Page page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()); diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CarMainServiceImpl.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CarMainServiceImpl.java index 1aedccf2..7e2a5036 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CarMainServiceImpl.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CarMainServiceImpl.java @@ -68,7 +68,12 @@ public class CarMainServiceImpl extends ServiceImpl impl // 插入 CarMain carMain = BeanUtils.toBean(createReqVO, CarMain.class); carMain.setCarBrand(brandAndModel.get(0)); - carMain.setCarModel(brandAndModel.get(1)); + //判断是否仅填入了品牌 + if(brandAndModel.size()>1){ + //填入了型号 + carMain.setCarModel(brandAndModel.get(1)); + } + baseMapper.insert(carMain); // 返回 @@ -128,22 +133,22 @@ public class CarMainServiceImpl extends ServiceImpl impl @Override public CarMainRespVO getCarMain(String id) { //数据单查 - CarMain carMain = baseMapper.selectById(id); + CarMainRespVO carMainRespVO = baseMapper.findOne(id); List brandAndModel = new ArrayList<>(); - brandAndModel.add(carMain.getCarBrand()); - brandAndModel.add(carMain.getCarModel()); - CarMainRespVO result = BeanUtils.toBean(carMain, CarMainRespVO.class); - result.setBrandAndModel(brandAndModel); + brandAndModel.add(carMainRespVO.getCarBrand()); + brandAndModel.add(carMainRespVO.getCarModel()); + + carMainRespVO.setBrandAndModel(brandAndModel); //联查客户信息 List cusList = customerCarMapper.selectCusListByCarId(id); - result.setCusList(cusList); + carMainRespVO.setCusList(cusList); //联查标签信息 List labelList = busiLabelService.listByMainId(id); - result.setLabelList(labelList); + carMainRespVO.setLabelList(labelList); - return result; + return carMainRespVO; } /** diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CarModelServiceImpl.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CarModelServiceImpl.java index 6d3a5605..02d3aed0 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CarModelServiceImpl.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CarModelServiceImpl.java @@ -1,8 +1,6 @@ package cn.iocoder.yudao.module.custom.service.impl; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.module.custom.entity.CarBrand; -import cn.iocoder.yudao.module.custom.entity.CarMain; + import cn.iocoder.yudao.module.custom.entity.CarModel; import cn.iocoder.yudao.module.custom.mapper.CarBrandMapper; import cn.iocoder.yudao.module.custom.mapper.CarModelMapper; @@ -14,13 +12,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import org.springframework.validation.annotation.Validated; -import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import java.util.ArrayList; import java.util.List; import java.util.UUID; @@ -36,6 +31,12 @@ public class CarModelServiceImpl extends ServiceImpl i @Autowired CarBrandMapper carBrandMapper; + /** + * 创建车辆品牌型号 + * + * @param createReqVO 创建信息 + * @return 编号 + */ @Override public String createCarModel(CarModelReqVO createReqVO) { // 插入 @@ -46,6 +47,11 @@ public class CarModelServiceImpl extends ServiceImpl i return carModel.getId(); } + /** + * 更新车辆品牌型号 + * + * @param updateReqVO 更新信息 + */ @Override public void updateCarModel(CarModelReqVO updateReqVO) { // 更新 @@ -53,26 +59,47 @@ public class CarModelServiceImpl extends ServiceImpl i baseMapper.updateById(updateObj); } + /** + * 删除车辆品牌型号 + * + * @param id 编号 + */ @Override public void deleteCarModel(String id) { - // 删除 baseMapper.deleteById(id); } - + /** + * 获得车辆品牌型号 + * + * @param id 编号 + * @return 车辆品牌型号 + */ @Override public CarModel getCarModel(String id) { return baseMapper.selectById(id); } + /** + * 获得车辆品牌型号分页 + * + * @param pageReqVO 分页查询 + * @return 车辆品牌型号分页 + */ @Override public IPage getCarModelPage(CarModelReqVO pageReqVO) { //取分页参数 Page page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()); return baseMapper.findPage(page,pageReqVO); - } - + } + + /** + * 获得车辆品牌型号分页 + * + * @param pageReqVO 分页查询 + * @return 车辆品牌型号分页 + */ @Override public IPage getCarModelPageByBrandId(CarModelReqVO pageReqVO) { //取分页参数 @@ -80,45 +107,18 @@ public class CarModelServiceImpl extends ServiceImpl i return baseMapper.findPage(page,pageReqVO); } + /** + * 获取品牌型号级联下拉 + * + * @param reqVO + * @return + */ @Override public List searchBrand(CarModelReqVO reqVO) { - -// if (ObjectUtil.isNotEmpty(reqVO.getModelName() ) && !"".equals(reqVO.getModelName()) ){ - //有筛选的情况要根据条件查出相关父项品牌和所有子项型号,加入result。仅展示关联父项 - CarBrandReqVO brandQuery = new CarBrandReqVO(); - brandQuery.setBrandName(reqVO.getModelName()); - List nameResult = carBrandMapper.searchBrand(brandQuery); - - - -// CarBrandReqVO brandQueryAbbName = new CarBrandReqVO(); -// brandQueryAbbName.setAbbName(reqVO.getModelName()); -// -// List brands = carBrandMapper.searchBrand(brandQueryAbbName); -//// result.addAll(getChildModel(brands)); -// -// -// -// CarModelReqVO modelQueryModelName = new CarModelReqVO(); -// modelQueryModelName.setModelName(reqVO.getModelName()); -// baseMapper.searchModel(modelQueryModelName); -// -// CarModelReqVO modelQueryAbbName = new CarModelReqVO(); -// modelQueryAbbName.setAbbName(reqVO.getModelName()); -// baseMapper.searchModel(modelQueryAbbName); - - - -// }else { -// //无筛选的情况要查出所有父项品牌,然后根据id加入其下所有子项型号 -// -// //取所有品牌 -// List brands = carBrandMapper.searchBrand(new CarBrandReqVO()); -// //根据父级品牌集合取所有的型号子选项 -//// result = getChildModel(brands); -// -// } + CarBrandReqVO brandQuery = new CarBrandReqVO(); + brandQuery.setBrandName(reqVO.getModelName()); + List nameResult = carBrandMapper.searchBrand(brandQuery); return getChildModel(nameResult,reqVO.getModelName()); } diff --git a/dl-module-base/src/main/resources/mapper/custom/CarMainMapper.xml b/dl-module-base/src/main/resources/mapper/custom/CarMainMapper.xml index 9b478754..708155b5 100644 --- a/dl-module-base/src/main/resources/mapper/custom/CarMainMapper.xml +++ b/dl-module-base/src/main/resources/mapper/custom/CarMainMapper.xml @@ -34,10 +34,13 @@ + +