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 022bab19..22155098 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 @@ -2,9 +2,7 @@ package cn.iocoder.yudao.module.custom.controller.admin; import cn.iocoder.yudao.module.custom.entity.CarModel; import cn.iocoder.yudao.module.custom.service.CarModelService; -import cn.iocoder.yudao.module.custom.vo.CarMainRespVO; -import cn.iocoder.yudao.module.custom.vo.CarModelReqVO; -import cn.iocoder.yudao.module.custom.vo.CarModelRespVO; +import cn.iocoder.yudao.module.custom.vo.*; import cn.iocoder.yudao.module.custom.vo.CarModelReqVO; import com.baomidou.mybatisplus.core.metadata.IPage; import org.springframework.beans.factory.annotation.Autowired; @@ -137,8 +135,7 @@ public class CarModelController { @GetMapping("/export-excel") @Operation(summary = "导出车辆品牌型号 Excel") @PreAuthorize("@ss.hasPermission('base:car-model:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportCarModelExcel(CarModelReqVO pageReqVO, + public void searchBrand(CarModelReqVO pageReqVO, HttpServletResponse response) throws IOException { pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); List list = carModelService.getCarModelPage(pageReqVO).getRecords(); @@ -146,4 +143,19 @@ public class CarModelController { ExcelUtils.write(response, "车辆品牌型号.xls", "数据", CarModelRespVO.class, list); } + /** + * 筛选品牌型号 + * + * @param reqVO + * @return + */ + @PostMapping("/searchBrand") + @Operation(summary = "筛选品牌型号") + @PreAuthorize("@ss.hasPermission('base:car-main:query')") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + public CommonResult> searchBrand(@RequestBody CarModelReqVO reqVO) { + List result = carModelService.searchBrand(reqVO); + return success(result); + } + } \ No newline at end of file diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/mapper/CarBrandMapper.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/mapper/CarBrandMapper.java index ac5256f8..7e6a70b0 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/mapper/CarBrandMapper.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/mapper/CarBrandMapper.java @@ -3,15 +3,15 @@ package cn.iocoder.yudao.module.custom.mapper; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.custom.entity.CarBrand; import cn.iocoder.yudao.module.custom.entity.CarMain; -import cn.iocoder.yudao.module.custom.vo.CarBrandReqVO; -import cn.iocoder.yudao.module.custom.vo.CarBrandRespVO; -import cn.iocoder.yudao.module.custom.vo.CarMainRespVO; +import cn.iocoder.yudao.module.custom.vo.*; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.List; + /** * 车辆品牌维护 Mapper * @@ -22,4 +22,6 @@ public interface CarBrandMapper extends BaseMapper { IPage findPage(Page page,@Param("dto") CarBrandReqVO reqVO); + List searchBrand(@Param("dto") CarBrandReqVO reqVO); + } \ No newline at end of file diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/mapper/CarModelMapper.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/mapper/CarModelMapper.java index cadbceb9..e798b5e3 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/mapper/CarModelMapper.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/mapper/CarModelMapper.java @@ -3,16 +3,15 @@ package cn.iocoder.yudao.module.custom.mapper; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.custom.entity.CarMain; import cn.iocoder.yudao.module.custom.entity.CarModel; -import cn.iocoder.yudao.module.custom.vo.CarMainReqVO; -import cn.iocoder.yudao.module.custom.vo.CarMainRespVO; -import cn.iocoder.yudao.module.custom.vo.CarModelReqVO; -import cn.iocoder.yudao.module.custom.vo.CarModelRespVO; +import cn.iocoder.yudao.module.custom.vo.*; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.List; + /** * 车辆品牌型号 Mapper * @@ -25,5 +24,11 @@ public interface CarModelMapper extends BaseMapper { IPage getCarModelPageByBrandId(Page page, @Param("dto") CarModelReqVO reqVO); + List searchModelByBrandid(@Param("dto") CarModelReqVO reqVO); + +// List searchModel(@Param("dto") CarModelReqVO reqVO); + + + } \ No newline at end of file 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 d40cc39b..ba97f098 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 @@ -6,8 +6,12 @@ import cn.iocoder.yudao.module.custom.entity.CarModel; import cn.iocoder.yudao.module.custom.vo.CarModelReqVO; import cn.iocoder.yudao.module.custom.vo.CarModelReqVO; import cn.iocoder.yudao.module.custom.vo.CarModelRespVO; +import cn.iocoder.yudao.module.custom.vo.CascaderOptionsVO; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; +import org.springframework.web.bind.annotation.RequestBody; + +import java.util.List; /** * 车辆品牌型号 Service 接口 @@ -62,4 +66,12 @@ public interface CarModelService extends IService { */ IPage getCarModelPageByBrandId(CarModelReqVO pageReqVO); + /** + * 筛选品牌型号 + * + * @param reqVO + * @return + */ + List searchBrand(CarModelReqVO reqVO); + } \ No newline at end of file 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 9c6908fe..6d3a5605 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,7 +1,10 @@ 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; import cn.iocoder.yudao.module.custom.service.CarModelService; import cn.iocoder.yudao.module.custom.vo.*; @@ -9,6 +12,7 @@ import cn.iocoder.yudao.module.custom.vo.CarModelReqVO; 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.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.Resource; import org.springframework.validation.annotation.Validated; @@ -16,6 +20,8 @@ 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; /** @@ -27,6 +33,9 @@ import java.util.UUID; @Validated public class CarModelServiceImpl extends ServiceImpl implements CarModelService { + @Autowired + CarBrandMapper carBrandMapper; + @Override public String createCarModel(CarModelReqVO createReqVO) { // 插入 @@ -71,4 +80,68 @@ public class CarModelServiceImpl extends ServiceImpl i return baseMapper.findPage(page,pageReqVO); } + @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); +// +// } + + return getChildModel(nameResult,reqVO.getModelName()); + } + + /** + * 根据父级品牌集合取所有的型号子选项 + * + * @param brands + * @return + */ + private List getChildModel(List brands,String name){ + //遍历父级数据 + for (CascaderOptionsVO brandItem: brands) { + CarModelReqVO query = new CarModelReqVO(); + query.setBrandId(brandItem.getValue()); + query.setModelName(name); + //取品牌下属型号选项 + List models = baseMapper.searchModelByBrandid(query); + //父级数据拼装 + brandItem.setChildren(models); + + } + return brands; + } + } \ No newline at end of file diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CarModelReqVO.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CarModelReqVO.java index 1781f598..7ecf2663 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CarModelReqVO.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CarModelReqVO.java @@ -44,4 +44,5 @@ public class CarModelReqVO extends PageParam { + } \ No newline at end of file diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CarModelRespVO.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CarModelRespVO.java index f9d47bd4..20348a6a 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CarModelRespVO.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CarModelRespVO.java @@ -17,4 +17,9 @@ public class CarModelRespVO extends CarModel { @ExcelProperty("创建时间") private LocalDateTime createTime; +// /** +// * 车辆品牌型号选项 +// */ +// List modelOptions; + } \ No newline at end of file diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CascaderOptionsVO.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CascaderOptionsVO.java index 4fa1f9e9..f84aa352 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CascaderOptionsVO.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CascaderOptionsVO.java @@ -1,2 +1,29 @@ -package cn.iocoder.yudao.module.custom.vo;public class CascaderOptionsVO { +package cn.iocoder.yudao.module.custom.vo; + + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.List; + +@Data +@Schema(description = "级联选择器选项") +public class CascaderOptionsVO { + /** + * 选项值 + */ + private String value; + /** + * 选项名 + */ + private String label; + /** + * 选项子项 + */ + List children; + /** + * 懒加载:是否为叶子节点 0父 1子 + */ + int leaf; + } diff --git a/dl-module-base/src/main/resources/mapper/custom/CarBrandMapper.xml b/dl-module-base/src/main/resources/mapper/custom/CarBrandMapper.xml index 7b2ebd87..7eec2559 100644 --- a/dl-module-base/src/main/resources/mapper/custom/CarBrandMapper.xml +++ b/dl-module-base/src/main/resources/mapper/custom/CarBrandMapper.xml @@ -54,4 +54,22 @@ tbcb.create_time DESC + + \ No newline at end of file diff --git a/dl-module-base/src/main/resources/mapper/custom/CarModelMapper.xml b/dl-module-base/src/main/resources/mapper/custom/CarModelMapper.xml index 120d79a5..d9cf8579 100644 --- a/dl-module-base/src/main/resources/mapper/custom/CarModelMapper.xml +++ b/dl-module-base/src/main/resources/mapper/custom/CarModelMapper.xml @@ -68,4 +68,46 @@ tbcmod.sort DESC + + + + \ No newline at end of file