车辆品牌型号优化;注释补充

This commit is contained in:
“hhk” 2024-08-08 10:56:21 +08:00
parent 4ed7438318
commit 6e2fb4d874
8 changed files with 127 additions and 72 deletions

View File

@ -39,13 +39,13 @@ public class CarBrandController {
private CarBrandService carBrandService; private CarBrandService carBrandService;
/** /**
* 创建车辆品牌维护 * 创建车辆品牌
* *
* @param createReqVO * @param createReqVO
* @return * @return
*/ */
@PostMapping("/create") @PostMapping("/create")
@Operation(summary = "创建车辆品牌维护") @Operation(summary = "创建车辆品牌")
@PreAuthorize("@ss.hasPermission('base:car-brand:create')") @PreAuthorize("@ss.hasPermission('base:car-brand:create')")
public CommonResult<String> createCarBrand(@RequestBody CarBrandReqVO createReqVO) { public CommonResult<String> createCarBrand(@RequestBody CarBrandReqVO createReqVO) {
return success(carBrandService.createCarBrand(createReqVO)); return success(carBrandService.createCarBrand(createReqVO));
@ -58,7 +58,7 @@ public class CarBrandController {
* @return * @return
*/ */
@PutMapping("/update") @PutMapping("/update")
@Operation(summary = "更新车辆品牌维护") @Operation(summary = "更新车辆品牌")
@PreAuthorize("@ss.hasPermission('base:car-brand:update')") @PreAuthorize("@ss.hasPermission('base:car-brand:update')")
public CommonResult<Boolean> updateCarBrand(@RequestBody CarBrandReqVO updateReqVO) { public CommonResult<Boolean> updateCarBrand(@RequestBody CarBrandReqVO updateReqVO) {
carBrandService.updateCarBrand(updateReqVO); carBrandService.updateCarBrand(updateReqVO);
@ -66,7 +66,7 @@ public class CarBrandController {
} }
@DeleteMapping("/delete") @DeleteMapping("/delete")
@Operation(summary = "删除车辆品牌维护") @Operation(summary = "删除车辆品牌")
@Parameter(name = "id", description = "编号", required = true) @Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('base:car-brand:delete')") @PreAuthorize("@ss.hasPermission('base:car-brand:delete')")
public CommonResult<Boolean> deleteCarBrand(@RequestParam("id") String id) { public CommonResult<Boolean> deleteCarBrand(@RequestParam("id") String id) {
@ -75,7 +75,7 @@ public class CarBrandController {
} }
@GetMapping("/get") @GetMapping("/get")
@Operation(summary = "获得车辆品牌维护") @Operation(summary = "获得车辆品牌")
@Parameter(name = "id", description = "编号", required = true, example = "1024") @Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('base:car-brand:query')") @PreAuthorize("@ss.hasPermission('base:car-brand:query')")
public CommonResult<CarBrandRespVO> getCarBrand(@RequestParam("id") String id) { public CommonResult<CarBrandRespVO> getCarBrand(@RequestParam("id") String id) {
@ -84,7 +84,7 @@ public class CarBrandController {
} }
@GetMapping("/page") @GetMapping("/page")
@Operation(summary = "获得车辆品牌维护分页") @Operation(summary = "获得车辆品牌分页")
@PreAuthorize("@ss.hasPermission('base:car-brand:query')") @PreAuthorize("@ss.hasPermission('base:car-brand:query')")
public CommonResult<IPage<CarBrandRespVO>> getCarBrandPage(CarBrandReqVO pageReqVO) { public CommonResult<IPage<CarBrandRespVO>> getCarBrandPage(CarBrandReqVO pageReqVO) {
IPage<CarBrandRespVO> pageResult = carBrandService.getCarBrandPage(pageReqVO); IPage<CarBrandRespVO> pageResult = carBrandService.getCarBrandPage(pageReqVO);
@ -92,7 +92,7 @@ public class CarBrandController {
} }
@GetMapping("/export-excel") @GetMapping("/export-excel")
@Operation(summary = "导出车辆品牌维护 Excel") @Operation(summary = "导出车辆品牌 Excel")
@PreAuthorize("@ss.hasPermission('base:car-brand:export')") @PreAuthorize("@ss.hasPermission('base:car-brand:export')")
@ApiAccessLog(operateType = EXPORT) @ApiAccessLog(operateType = EXPORT)
public void exportCarBrandExcel(CarBrandReqVO pageReqVO, public void exportCarBrandExcel(CarBrandReqVO pageReqVO,

View File

@ -150,7 +150,7 @@ public class CarModelController {
* @return * @return
*/ */
@PostMapping("/searchBrand") @PostMapping("/searchBrand")
@Operation(summary = "筛选品牌型号") @Operation(summary = "获取品牌型号级联下拉")
@PreAuthorize("@ss.hasPermission('base:car-main:query')") @PreAuthorize("@ss.hasPermission('base:car-main:query')")
@Parameter(name = "id", description = "编号", required = true, example = "1024") @Parameter(name = "id", description = "编号", required = true, example = "1024")
public CommonResult<List<CascaderOptionsVO>> searchBrand(@RequestBody CarModelReqVO reqVO) { public CommonResult<List<CascaderOptionsVO>> searchBrand(@RequestBody CarModelReqVO reqVO) {

View File

@ -29,6 +29,14 @@ public interface CarMainMapper extends BaseMapper<CarMain> {
*/ */
IPage<CarMainRespVO> findPage(Page<CarMainReqVO> page, @Param("dto") CarMainReqVO pageReqVO); IPage<CarMainRespVO> findPage(Page<CarMainReqVO> page, @Param("dto") CarMainReqVO pageReqVO);
/**
* 获得车辆信息分页
*
* @param id
* @return
*/
CarMainRespVO findOne(@Param("id") String id);
/** /**

View File

@ -67,7 +67,7 @@ public interface CarModelService extends IService<CarModel> {
IPage<CarModelRespVO> getCarModelPageByBrandId(CarModelReqVO pageReqVO); IPage<CarModelRespVO> getCarModelPageByBrandId(CarModelReqVO pageReqVO);
/** /**
* 筛选品牌型号 * 获取品牌型号级联下拉
* *
* @param reqVO * @param reqVO
* @return * @return

View File

@ -9,9 +9,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import java.util.UUID; import java.util.UUID;
@ -25,6 +23,12 @@ import java.util.UUID;
@Validated @Validated
public class CarBrandServiceImpl extends ServiceImpl<CarBrandMapper, CarBrand> implements CarBrandService { public class CarBrandServiceImpl extends ServiceImpl<CarBrandMapper, CarBrand> implements CarBrandService {
/**
* 创建车辆品牌维护
*
* @param createReqVO 创建信息
* @return 编号
*/
@Override @Override
public String createCarBrand(CarBrandReqVO createReqVO) { public String createCarBrand(CarBrandReqVO createReqVO) {
// 插入 // 插入
@ -35,6 +39,11 @@ public class CarBrandServiceImpl extends ServiceImpl<CarBrandMapper, CarBrand> i
return carBrand.getId(); return carBrand.getId();
} }
/**
* 更新车辆品牌维护
*
* @param updateReqVO 更新信息
*/
@Override @Override
public void updateCarBrand(CarBrandReqVO updateReqVO) { public void updateCarBrand(CarBrandReqVO updateReqVO) {
@ -43,19 +52,34 @@ public class CarBrandServiceImpl extends ServiceImpl<CarBrandMapper, CarBrand> i
baseMapper.updateById(updateObj); baseMapper.updateById(updateObj);
} }
/**
* 删除车辆品牌维护
*
* @param id 编号
*/
@Override @Override
public void deleteCarBrand(String id) { public void deleteCarBrand(String id) {
// 删除 // 删除
baseMapper.deleteById(id); baseMapper.deleteById(id);
} }
/**
* 获得车辆品牌维护
*
* @param id 编号
* @return 车辆品牌维护
*/
@Override @Override
public CarBrand getCarBrand(String id) { public CarBrand getCarBrand(String id) {
return baseMapper.selectById(id); return baseMapper.selectById(id);
} }
/**
* 获得车辆品牌维护分页
*
* @param pageReqVO 分页查询
* @return 车辆品牌维护分页
*/
@Override @Override
public IPage<CarBrandRespVO> getCarBrandPage(CarBrandReqVO pageReqVO) { public IPage<CarBrandRespVO> getCarBrandPage(CarBrandReqVO pageReqVO) {
Page<CarBrandReqVO> page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()); Page<CarBrandReqVO> page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());

View File

@ -68,7 +68,12 @@ public class CarMainServiceImpl extends ServiceImpl<CarMainMapper, CarMain> impl
// 插入 // 插入
CarMain carMain = BeanUtils.toBean(createReqVO, CarMain.class); CarMain carMain = BeanUtils.toBean(createReqVO, CarMain.class);
carMain.setCarBrand(brandAndModel.get(0)); carMain.setCarBrand(brandAndModel.get(0));
carMain.setCarModel(brandAndModel.get(1)); //判断是否仅填入了品牌
if(brandAndModel.size()>1){
//填入了型号
carMain.setCarModel(brandAndModel.get(1));
}
baseMapper.insert(carMain); baseMapper.insert(carMain);
// 返回 // 返回
@ -128,22 +133,22 @@ public class CarMainServiceImpl extends ServiceImpl<CarMainMapper, CarMain> impl
@Override @Override
public CarMainRespVO getCarMain(String id) { public CarMainRespVO getCarMain(String id) {
//数据单查 //数据单查
CarMain carMain = baseMapper.selectById(id); CarMainRespVO carMainRespVO = baseMapper.findOne(id);
List<String> brandAndModel = new ArrayList<>(); List<String> brandAndModel = new ArrayList<>();
brandAndModel.add(carMain.getCarBrand()); brandAndModel.add(carMainRespVO.getCarBrand());
brandAndModel.add(carMain.getCarModel()); brandAndModel.add(carMainRespVO.getCarModel());
CarMainRespVO result = BeanUtils.toBean(carMain, CarMainRespVO.class);
result.setBrandAndModel(brandAndModel); carMainRespVO.setBrandAndModel(brandAndModel);
//联查客户信息 //联查客户信息
List<CustomerMainRespVO> cusList = customerCarMapper.selectCusListByCarId(id); List<CustomerMainRespVO> cusList = customerCarMapper.selectCusListByCarId(id);
result.setCusList(cusList); carMainRespVO.setCusList(cusList);
//联查标签信息 //联查标签信息
List<BusiLabel> labelList = busiLabelService.listByMainId(id); List<BusiLabel> labelList = busiLabelService.listByMainId(id);
result.setLabelList(labelList); carMainRespVO.setLabelList(labelList);
return result; return carMainRespVO;
} }
/** /**

View File

@ -1,8 +1,6 @@
package cn.iocoder.yudao.module.custom.service.impl; 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.entity.CarModel;
import cn.iocoder.yudao.module.custom.mapper.CarBrandMapper; import cn.iocoder.yudao.module.custom.mapper.CarBrandMapper;
import cn.iocoder.yudao.module.custom.mapper.CarModelMapper; 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 com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -36,6 +31,12 @@ public class CarModelServiceImpl extends ServiceImpl<CarModelMapper, CarModel> i
@Autowired @Autowired
CarBrandMapper carBrandMapper; CarBrandMapper carBrandMapper;
/**
* 创建车辆品牌型号
*
* @param createReqVO 创建信息
* @return 编号
*/
@Override @Override
public String createCarModel(CarModelReqVO createReqVO) { public String createCarModel(CarModelReqVO createReqVO) {
// 插入 // 插入
@ -46,6 +47,11 @@ public class CarModelServiceImpl extends ServiceImpl<CarModelMapper, CarModel> i
return carModel.getId(); return carModel.getId();
} }
/**
* 更新车辆品牌型号
*
* @param updateReqVO 更新信息
*/
@Override @Override
public void updateCarModel(CarModelReqVO updateReqVO) { public void updateCarModel(CarModelReqVO updateReqVO) {
// 更新 // 更新
@ -53,26 +59,47 @@ public class CarModelServiceImpl extends ServiceImpl<CarModelMapper, CarModel> i
baseMapper.updateById(updateObj); baseMapper.updateById(updateObj);
} }
/**
* 删除车辆品牌型号
*
* @param id 编号
*/
@Override @Override
public void deleteCarModel(String id) { public void deleteCarModel(String id) {
// 删除 // 删除
baseMapper.deleteById(id); baseMapper.deleteById(id);
} }
/**
* 获得车辆品牌型号
*
* @param id 编号
* @return 车辆品牌型号
*/
@Override @Override
public CarModel getCarModel(String id) { public CarModel getCarModel(String id) {
return baseMapper.selectById(id); return baseMapper.selectById(id);
} }
/**
* 获得车辆品牌型号分页
*
* @param pageReqVO 分页查询
* @return 车辆品牌型号分页
*/
@Override @Override
public IPage<CarModelRespVO> getCarModelPage(CarModelReqVO pageReqVO) { public IPage<CarModelRespVO> getCarModelPage(CarModelReqVO pageReqVO) {
//取分页参数 //取分页参数
Page<CarModelReqVO> page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()); Page<CarModelReqVO> page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
return baseMapper.findPage(page,pageReqVO); return baseMapper.findPage(page,pageReqVO);
} }
/**
* 获得车辆品牌型号分页
*
* @param pageReqVO 分页查询
* @return 车辆品牌型号分页
*/
@Override @Override
public IPage<CarModelRespVO> getCarModelPageByBrandId(CarModelReqVO pageReqVO) { public IPage<CarModelRespVO> getCarModelPageByBrandId(CarModelReqVO pageReqVO) {
//取分页参数 //取分页参数
@ -80,45 +107,18 @@ public class CarModelServiceImpl extends ServiceImpl<CarModelMapper, CarModel> i
return baseMapper.findPage(page,pageReqVO); return baseMapper.findPage(page,pageReqVO);
} }
/**
* 获取品牌型号级联下拉
*
* @param reqVO
* @return
*/
@Override @Override
public List<CascaderOptionsVO> searchBrand(CarModelReqVO reqVO) { public List<CascaderOptionsVO> searchBrand(CarModelReqVO reqVO) {
CarBrandReqVO brandQuery = new CarBrandReqVO();
// if (ObjectUtil.isNotEmpty(reqVO.getModelName() ) && !"".equals(reqVO.getModelName()) ){ brandQuery.setBrandName(reqVO.getModelName());
//有筛选的情况要根据条件查出相关父项品牌和所有子项型号加入result仅展示关联父项 List<CascaderOptionsVO> nameResult = carBrandMapper.searchBrand(brandQuery);
CarBrandReqVO brandQuery = new CarBrandReqVO();
brandQuery.setBrandName(reqVO.getModelName());
List<CascaderOptionsVO> nameResult = carBrandMapper.searchBrand(brandQuery);
// CarBrandReqVO brandQueryAbbName = new CarBrandReqVO();
// brandQueryAbbName.setAbbName(reqVO.getModelName());
//
// List<CarBrandRespVO> 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<CarBrandRespVO> brands = carBrandMapper.searchBrand(new CarBrandReqVO());
// //根据父级品牌集合取所有的型号子选项
//// result = getChildModel(brands);
//
// }
return getChildModel(nameResult,reqVO.getModelName()); return getChildModel(nameResult,reqVO.getModelName());
} }

View File

@ -34,10 +34,13 @@
<select id="findPage" resultType="cn.iocoder.yudao.module.custom.vo.CarMainRespVO"> <select id="findPage" resultType="cn.iocoder.yudao.module.custom.vo.CarMainRespVO">
SELECT SELECT
<include refid="baseCarMainColumn"></include>,bcb.brand_name AS brandStr,bcm.model_name AS modelStr <include refid="baseCarMainColumn"></include>,
FROM `base_car_main` tbcm bcb.brand_name AS brandStr,
left join base_car_brand bcb ON bcb.deleted = 0 AND tbcm.car_brand = bcb.id bcm.model_name AS modelStr
left join base_car_model bcm ON bcm.deleted = 0 AND tbcm.car_model = bcm.id FROM
`base_car_main` tbcm
LEFT JOIN base_car_brand bcb ON bcb.deleted = 0 AND tbcm.car_brand = bcb.id
LEFT JOIN base_car_model bcm ON bcm.deleted = 0 AND tbcm.car_model = bcm.id
WHERE WHERE
tbcm.deleted = 0 tbcm.deleted = 0
<if test="dto.licenseNumber != null and dto.licenseNumber != ''"> <if test="dto.licenseNumber != null and dto.licenseNumber != ''">
@ -74,6 +77,21 @@
tbcm.car_register_date DESC tbcm.car_register_date DESC
</select> </select>
<select id="findOne" resultType="cn.iocoder.yudao.module.custom.vo.CarMainRespVO">
SELECT
<include refid="baseCarMainColumn"></include>,
bcb.brand_name AS brandStr,
bcm.model_name AS modelStr
FROM
`base_car_main` tbcm
LEFT JOIN base_car_brand bcb ON bcb.deleted = 0 AND tbcm.car_brand = bcb.id
LEFT JOIN base_car_model bcm ON bcm.deleted = 0 AND tbcm.car_model = bcm.id
WHERE
tbcm.deleted = 0
AND
tbcm.id = #{id}
</select>
<select id="isDataKeyValueRepeat" resultType="cn.iocoder.yudao.module.custom.entity.CarMain"> <select id="isDataKeyValueRepeat" resultType="cn.iocoder.yudao.module.custom.entity.CarMain">
SELECT SELECT
tbcm.id tbcm.id