增加车辆查询接口
This commit is contained in:
37
src/main/java/com/sczx/car/controller/CarController.java
Normal file
37
src/main/java/com/sczx/car/controller/CarController.java
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package com.sczx.car.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.sczx.car.common.Result;
|
||||||
|
import com.sczx.car.dto.CarDTO;
|
||||||
|
import com.sczx.car.dto.RentCarRuleDTO;
|
||||||
|
import com.sczx.car.dto.req.CarQueryConditionReq;
|
||||||
|
import com.sczx.car.service.RentCarRuleService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 车型表 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zhangli
|
||||||
|
* @since 2025-07-12 19:55:31
|
||||||
|
*/
|
||||||
|
@Api(value = "车辆接口", tags = "车辆接口")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/car")
|
||||||
|
public class CarController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RentCarRuleService rentCarRuleService;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiOperation(value = "根据查询条件查询车辆")
|
||||||
|
@GetMapping("/getCarByCarCondition")
|
||||||
|
public Result<CarDTO> getCarByCarCondition(@RequestBody CarQueryConditionReq req){
|
||||||
|
return Result.ok(rentCarRuleService.getRentCarRuleByCarRuleId(carRuleId));
|
||||||
|
}
|
||||||
|
}
|
||||||
18
src/main/java/com/sczx/car/convert/CarConvert.java
Normal file
18
src/main/java/com/sczx/car/convert/CarConvert.java
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package com.sczx.car.convert;
|
||||||
|
|
||||||
|
import com.sczx.car.dto.CarDTO;
|
||||||
|
import com.sczx.car.dto.CarModelSimpleDTO;
|
||||||
|
import com.sczx.car.po.CarModelPO;
|
||||||
|
import com.sczx.car.po.CarPO;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.Mapping;
|
||||||
|
import org.mapstruct.Mappings;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface CarConvert {
|
||||||
|
CarConvert INSTANCE = Mappers.getMapper(CarConvert.class);
|
||||||
|
|
||||||
|
CarDTO poToDto(CarPO po);
|
||||||
|
|
||||||
|
}
|
||||||
138
src/main/java/com/sczx/car/dto/CarDTO.java
Normal file
138
src/main/java/com/sczx/car/dto/CarDTO.java
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
package com.sczx.car.dto;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 电动车信息表
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zhangli
|
||||||
|
* @since 2025-07-30 17:05:03
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel(value = "CarDTO对象", description = "电动车信息表")
|
||||||
|
public class CarDTO{
|
||||||
|
|
||||||
|
@ApiModelProperty("主键ID")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@ApiModelProperty("车架号(VIN)")
|
||||||
|
private String vin;
|
||||||
|
|
||||||
|
@ApiModelProperty("车牌号码")
|
||||||
|
private String licensePlate;
|
||||||
|
|
||||||
|
@ApiModelProperty("车辆品牌ID")
|
||||||
|
private Long brandId;
|
||||||
|
|
||||||
|
@ApiModelProperty("车辆品牌名称")
|
||||||
|
private String brandName;
|
||||||
|
|
||||||
|
@ApiModelProperty("车辆型号ID")
|
||||||
|
private Long modelId;
|
||||||
|
|
||||||
|
@ApiModelProperty("车辆型号名称")
|
||||||
|
private String modelName;
|
||||||
|
|
||||||
|
@ApiModelProperty("支持电池类型(48V标准版/100km,48V超长版/200km等)")
|
||||||
|
private String batteryType;
|
||||||
|
|
||||||
|
@ApiModelProperty("整车重量(kg)")
|
||||||
|
private String weight;
|
||||||
|
|
||||||
|
@ApiModelProperty("最高时速(km/h)")
|
||||||
|
private String maxSpeed;
|
||||||
|
|
||||||
|
@ApiModelProperty("LOT识别号")
|
||||||
|
private String lotNumber;
|
||||||
|
|
||||||
|
@ApiModelProperty("采购日期")
|
||||||
|
private LocalDateTime purchaseDate;
|
||||||
|
|
||||||
|
@ApiModelProperty("采购价格(元)")
|
||||||
|
private BigDecimal purchasePrice;
|
||||||
|
|
||||||
|
@ApiModelProperty("车辆归属(0归属于合,1归属运营商)")
|
||||||
|
private String belongType;
|
||||||
|
|
||||||
|
@ApiModelProperty("车辆图片(多个图片用逗号分隔)")
|
||||||
|
private String images;
|
||||||
|
|
||||||
|
@ApiModelProperty("BRS车辆状态(空闲/使用中/维修中/丢失报损等)")
|
||||||
|
private String brsStatus;
|
||||||
|
|
||||||
|
@ApiModelProperty("IoT设备状态")
|
||||||
|
private String iotStatus;
|
||||||
|
|
||||||
|
@ApiModelProperty("IoT识别码")
|
||||||
|
private String iotCode;
|
||||||
|
|
||||||
|
@ApiModelProperty("所属运营商ID")
|
||||||
|
private Long operatorId;
|
||||||
|
|
||||||
|
@ApiModelProperty("所属运营商名称")
|
||||||
|
private String operatorName;
|
||||||
|
|
||||||
|
@ApiModelProperty("所属门店ID")
|
||||||
|
private Long storeId;
|
||||||
|
|
||||||
|
@ApiModelProperty("所属门店名称")
|
||||||
|
private String storeName;
|
||||||
|
|
||||||
|
@ApiModelProperty("应用套餐ID")
|
||||||
|
private Long packageId;
|
||||||
|
|
||||||
|
@ApiModelProperty("应用套餐名称")
|
||||||
|
private String packageName;
|
||||||
|
|
||||||
|
@ApiModelProperty("状态(0正常 1停用)")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@ApiModelProperty("删除标志(0代表存在 2代表删除)")
|
||||||
|
private String delFlag;
|
||||||
|
|
||||||
|
@ApiModelProperty("创建者")
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
@ApiModelProperty("创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("更新者")
|
||||||
|
private String updateBy;
|
||||||
|
|
||||||
|
@ApiModelProperty("更新时间")
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("备注信息")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@ApiModelProperty("扩展字段1")
|
||||||
|
private String extend1;
|
||||||
|
|
||||||
|
@ApiModelProperty("扩展字段2")
|
||||||
|
private String extend2;
|
||||||
|
|
||||||
|
@ApiModelProperty("扩展字段3")
|
||||||
|
private String extend3;
|
||||||
|
|
||||||
|
@ApiModelProperty("扩展字段4")
|
||||||
|
private String extend4;
|
||||||
|
|
||||||
|
@ApiModelProperty("扩展字段5")
|
||||||
|
private String extend5;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
24
src/main/java/com/sczx/car/dto/req/CarQueryConditionReq.java
Normal file
24
src/main/java/com/sczx/car/dto/req/CarQueryConditionReq.java
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package com.sczx.car.dto.req;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: 张黎
|
||||||
|
* @Date: 2025/07/30/17:13
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel(value = "车辆查询请求", description = "CarQueryConditionReq对象")
|
||||||
|
public class CarQueryConditionReq {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "车辆ID")
|
||||||
|
private Long carId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "车牌号码")
|
||||||
|
private String licensePlate;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "车架号(VIN)")
|
||||||
|
private String vin;
|
||||||
|
}
|
||||||
16
src/main/java/com/sczx/car/mapper/CarMapper.java
Normal file
16
src/main/java/com/sczx/car/mapper/CarMapper.java
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package com.sczx.car.mapper;
|
||||||
|
|
||||||
|
import com.sczx.car.po.CarPO;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 电动车信息表 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zhangli
|
||||||
|
* @since 2025-07-30 17:05:03
|
||||||
|
*/
|
||||||
|
public interface CarMapper extends BaseMapper<CarPO> {
|
||||||
|
|
||||||
|
}
|
||||||
140
src/main/java/com/sczx/car/po/CarPO.java
Normal file
140
src/main/java/com/sczx/car/po/CarPO.java
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
package com.sczx.car.po;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 电动车信息表
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zhangli
|
||||||
|
* @since 2025-07-30 17:05:03
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@TableName("zc_car")
|
||||||
|
@ApiModel(value = "CarPO对象", description = "电动车信息表")
|
||||||
|
public class CarPO implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty("主键ID")
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@ApiModelProperty("车架号(VIN)")
|
||||||
|
private String vin;
|
||||||
|
|
||||||
|
@ApiModelProperty("车牌号码")
|
||||||
|
private String licensePlate;
|
||||||
|
|
||||||
|
@ApiModelProperty("车辆品牌ID")
|
||||||
|
private Long brandId;
|
||||||
|
|
||||||
|
@ApiModelProperty("车辆品牌名称")
|
||||||
|
private String brandName;
|
||||||
|
|
||||||
|
@ApiModelProperty("车辆型号ID")
|
||||||
|
private Long modelId;
|
||||||
|
|
||||||
|
@ApiModelProperty("车辆型号名称")
|
||||||
|
private String modelName;
|
||||||
|
|
||||||
|
@ApiModelProperty("支持电池类型(48V标准版/100km,48V超长版/200km等)")
|
||||||
|
private String batteryType;
|
||||||
|
|
||||||
|
@ApiModelProperty("整车重量(kg)")
|
||||||
|
private String weight;
|
||||||
|
|
||||||
|
@ApiModelProperty("最高时速(km/h)")
|
||||||
|
private String maxSpeed;
|
||||||
|
|
||||||
|
@ApiModelProperty("LOT识别号")
|
||||||
|
private String lotNumber;
|
||||||
|
|
||||||
|
@ApiModelProperty("采购日期")
|
||||||
|
private LocalDateTime purchaseDate;
|
||||||
|
|
||||||
|
@ApiModelProperty("采购价格(元)")
|
||||||
|
private BigDecimal purchasePrice;
|
||||||
|
|
||||||
|
@ApiModelProperty("车辆归属(0归属于合,1归属运营商)")
|
||||||
|
private String belongType;
|
||||||
|
|
||||||
|
@ApiModelProperty("车辆图片(多个图片用逗号分隔)")
|
||||||
|
private String images;
|
||||||
|
|
||||||
|
@ApiModelProperty("BRS车辆状态(空闲/使用中/维修中/丢失报损等)")
|
||||||
|
private String brsStatus;
|
||||||
|
|
||||||
|
@ApiModelProperty("IoT设备状态")
|
||||||
|
private String iotStatus;
|
||||||
|
|
||||||
|
@ApiModelProperty("IoT识别码")
|
||||||
|
private String iotCode;
|
||||||
|
|
||||||
|
@ApiModelProperty("所属运营商ID")
|
||||||
|
private Long operatorId;
|
||||||
|
|
||||||
|
@ApiModelProperty("所属运营商名称")
|
||||||
|
private String operatorName;
|
||||||
|
|
||||||
|
@ApiModelProperty("所属门店ID")
|
||||||
|
private Long storeId;
|
||||||
|
|
||||||
|
@ApiModelProperty("所属门店名称")
|
||||||
|
private String storeName;
|
||||||
|
|
||||||
|
@ApiModelProperty("应用套餐ID")
|
||||||
|
private Long packageId;
|
||||||
|
|
||||||
|
@ApiModelProperty("应用套餐名称")
|
||||||
|
private String packageName;
|
||||||
|
|
||||||
|
@ApiModelProperty("状态(0正常 1停用)")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@ApiModelProperty("删除标志(0代表存在 2代表删除)")
|
||||||
|
private String delFlag;
|
||||||
|
|
||||||
|
@ApiModelProperty("创建者")
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
@ApiModelProperty("创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("更新者")
|
||||||
|
private String updateBy;
|
||||||
|
|
||||||
|
@ApiModelProperty("更新时间")
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("备注信息")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@ApiModelProperty("扩展字段1")
|
||||||
|
private String extend1;
|
||||||
|
|
||||||
|
@ApiModelProperty("扩展字段2")
|
||||||
|
private String extend2;
|
||||||
|
|
||||||
|
@ApiModelProperty("扩展字段3")
|
||||||
|
private String extend3;
|
||||||
|
|
||||||
|
@ApiModelProperty("扩展字段4")
|
||||||
|
private String extend4;
|
||||||
|
|
||||||
|
@ApiModelProperty("扩展字段5")
|
||||||
|
private String extend5;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
16
src/main/java/com/sczx/car/repository/CarRepo.java
Normal file
16
src/main/java/com/sczx/car/repository/CarRepo.java
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package com.sczx.car.repository;
|
||||||
|
|
||||||
|
import com.sczx.car.po.CarPO;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 电动车信息表 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zhangli
|
||||||
|
* @since 2025-07-30 17:05:03
|
||||||
|
*/
|
||||||
|
public interface CarRepo extends IService<CarPO> {
|
||||||
|
|
||||||
|
}
|
||||||
20
src/main/java/com/sczx/car/repository/impl/CarRepoImpl.java
Normal file
20
src/main/java/com/sczx/car/repository/impl/CarRepoImpl.java
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package com.sczx.car.repository.impl;
|
||||||
|
|
||||||
|
import com.sczx.car.po.CarPO;
|
||||||
|
import com.sczx.car.mapper.CarMapper;
|
||||||
|
import com.sczx.car.repository.CarRepo;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 电动车信息表 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zhangli
|
||||||
|
* @since 2025-07-30 17:05:03
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class CarRepoImpl extends ServiceImpl<CarMapper, CarPO> implements CarRepo {
|
||||||
|
|
||||||
|
}
|
||||||
19
src/main/java/com/sczx/car/service/CarService.java
Normal file
19
src/main/java/com/sczx/car/service/CarService.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package com.sczx.car.service;
|
||||||
|
|
||||||
|
import com.sczx.car.dto.CarDTO;
|
||||||
|
import com.sczx.car.dto.req.CarQueryConditionReq;
|
||||||
|
import com.sczx.car.po.CarPO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: 张黎
|
||||||
|
* @Date: 2025/07/30/17:19
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
public interface CarService {
|
||||||
|
/**
|
||||||
|
* 根据查询条件查询车辆信息
|
||||||
|
* @param req
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
CarDTO getCarByCondition(CarQueryConditionReq req);
|
||||||
|
}
|
||||||
36
src/main/java/com/sczx/car/service/impl/CarServiceImpl.java
Normal file
36
src/main/java/com/sczx/car/service/impl/CarServiceImpl.java
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
package com.sczx.car.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
|
import com.sczx.car.convert.CarConvert;
|
||||||
|
import com.sczx.car.dto.CarDTO;
|
||||||
|
import com.sczx.car.dto.req.CarQueryConditionReq;
|
||||||
|
import com.sczx.car.po.CarPO;
|
||||||
|
import com.sczx.car.repository.CarRepo;
|
||||||
|
import com.sczx.car.service.CarService;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: 张黎
|
||||||
|
* @Date: 2025/07/30/17:21
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class CarServiceImpl implements CarService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CarRepo carRepo;
|
||||||
|
@Override
|
||||||
|
public CarDTO getCarByCondition(CarQueryConditionReq req) {
|
||||||
|
LambdaQueryWrapper<CarPO> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(StringUtils.isNotBlank(req.getLicensePlate()),CarPO::getLicensePlate, req.getLicensePlate())
|
||||||
|
.eq(StringUtils.isNotBlank(req.getVin()),CarPO::getVin, req.getVin())
|
||||||
|
.eq(Objects.nonNull(req.getCarId()),CarPO::getId, req.getCarId()).last(" limit 1");
|
||||||
|
CarPO carPO = carRepo.getOne(queryWrapper);
|
||||||
|
return CarConvert.INSTANCE.poToDto(carPO);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,5 +1,7 @@
|
|||||||
package com.sczx.car.service.impl;
|
package com.sczx.car.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.sczx.car.convert.RentCarRuleConvert;
|
import com.sczx.car.convert.RentCarRuleConvert;
|
||||||
import com.sczx.car.dto.RentCarRuleDTO;
|
import com.sczx.car.dto.RentCarRuleDTO;
|
||||||
import com.sczx.car.po.RentCarRulePO;
|
import com.sczx.car.po.RentCarRulePO;
|
||||||
|
|||||||
5
src/main/resources/mapper/CarMapper.xml
Normal file
5
src/main/resources/mapper/CarMapper.xml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.sczx.car.mapper.CarMapper">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user