我的车辆相关接口

This commit is contained in:
zhaotianfeng 2024-09-24 17:09:22 +08:00
parent 8af9224cbb
commit 14343bb679
12 changed files with 485 additions and 0 deletions

View File

@ -0,0 +1,81 @@
package cn.iocoder.yudao.module.app.car.controller;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.app.car.entity.AppCarMain;
import cn.iocoder.yudao.module.app.car.service.AppCarMainService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Tag(name = "小程序 - 我的车辆")
@RestController
@RequestMapping("/userClient/base/myCar")
@Validated
public class AppCarMainController {
@Autowired
private AppCarMainService carMainService;
/**
* 创建车辆信息
*
* @param carMain
* @return
*/
@PostMapping("/create")
@Operation(summary = "创建车辆信息")
// @PreAuthorize("@ss.hasPermission('base:car-main:create')")
public CommonResult<String> createCarMain(@RequestBody AppCarMain carMain) {
return carMainService.createCarMain(carMain);
}
/**
* 更新车辆信息
*
* @param carMain
* @return
*/
@PutMapping("/update")
@Operation(summary = "更新车辆信息")
// @PreAuthorize("@ss.hasPermission('base:car-main:update')")
public CommonResult<String> updateCarMain(@RequestBody AppCarMain carMain) {
return carMainService.updateCarMain(carMain);
}
/**
* 删除车辆信息
*
* @param id
* @return
*/
@DeleteMapping("/delete")
@Operation(summary = "删除车辆信息")
@Parameter(name = "id", description = "编号", required = true)
// @PreAuthorize("@ss.hasPermission('base:car-main:delete')")
public CommonResult<String> deleteCarMain(@RequestParam("id") String id) {
return carMainService.deleteCarMain(id);
}
/**
* 根据当前用户获得车辆信息
*
* @return
*/
@GetMapping("/get")
@Operation(summary = "获得车辆信息")
// @PreAuthorize("@ss.hasPermission('base:car-main:query')")
public CommonResult<List<AppCarMain>> getCarMain() {
List<AppCarMain> carMain = carMainService.getCarMain();
return CommonResult.success(carMain);
}
}

View File

@ -0,0 +1,52 @@
package cn.iocoder.yudao.module.app.car.controller;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.custom.entity.CarModel;
import cn.iocoder.yudao.module.custom.service.CarModelService;
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 io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 车辆品牌型号")
@RestController
@RequestMapping("/userClient/base/carModel")
@Validated
public class AppCarModelController {
@Autowired
private CarModelService carModelService;
/**
* 获得全部车辆品牌
*
* @return
*/
@GetMapping("/list")
@Operation(summary = "查询车辆品牌")
public CommonResult<List<CarModel>> getList() {
List<CarModel> carModelList = carModelService.getCarModelList();
return success(carModelList);
}
}

View File

@ -0,0 +1,136 @@
package cn.iocoder.yudao.module.app.car.entity;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY;
/**
* 车辆信息 DO
*
* @author 后台管理员
*/
@TableName("base_car_main")
@Data
@EqualsAndHashCode(callSuper = true)
public class AppCarMain extends TenantBaseDO {
/**
* 主键标识
*/
@TableId(type = IdType.ASSIGN_UUID)
private String id;
/**
* 发动机号码
*/
private String engineNumber;
/**
* 车架号
*/
private String vin;
/**
* 车牌号
*/
private String licenseNumber;
/**
* 车辆型号
*/
private String carModel;
/**
* 保养日期
*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
private Date maintenanceDate;
/**
* 保养里程
*/
private BigDecimal maintenanceMileage;
/**
* 年检日期
*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
private Date inspectionDate;
/**
* 保险日期
*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
private Date insuranceDate;
/**
* 二级维护时间
*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
private Date checkDate;
/**
* 下次保养日期
*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
private Date nextMaintenanceDate;
/**
* 下次保养里程
*/
private BigDecimal nextMaintenanceMileage;
/**
* 下次年检日期
*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
private Date nextInspectionDate;
/**
* 保险到期日期
*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
private Date insuranceExpiryDate;
/**
* 下次二级维护时间
*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
private Date nextCheckDate;
/**
* 车辆品牌
*/
private String carBrand;
/**
* 车辆性质营运 非营运等
*/
private String carNature;
/**
* 车辆类别私家车 货车 教练车 公务车 出租车
*/
private String carCategory;
/**
* 车辆注册日期
*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
private Date carRegisterDate;
/**
* 行驶证图片
*/
private String carLicenseImg;
/**
* 最近办理业务
*/
private String recentlyHandledBusiness;
/**
* 最近办理业务的时间
*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
private Date recentlyHandleBusinessTime;
/**
* 车辆型号输入框
*/
private String carModelInput;
/**
* 车辆品牌输入框
*/
private String carBrandInput;
}

View File

@ -0,0 +1,17 @@
package cn.iocoder.yudao.module.app.car.mapper;
import cn.iocoder.yudao.module.app.car.entity.AppCarMain;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface AppCarMainMapper extends BaseMapper<AppCarMain> {
// 查询当前用户的所有车辆
List<AppCarMain> getUserCarMain(@Param("userId") Long userId);
}

View File

@ -0,0 +1,49 @@
package cn.iocoder.yudao.module.app.car.service;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.app.car.entity.AppCarMain;
import cn.iocoder.yudao.module.custom.vo.CarMainRespVO;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* 车辆信息 Service 接口
*
* @author 后台管理员
*/
public interface AppCarMainService extends IService<AppCarMain> {
/**
* 创建车辆信息
*
* @param carMain 创建信息
* @return 编号
*/
CommonResult<String> createCarMain(AppCarMain carMain);
/**
* 更新车辆信息
*
* @param carMain 更新信息
*/
CommonResult<String> updateCarMain(AppCarMain carMain);
/**
* 删除车辆信息
*
* @param id 编号
*/
CommonResult<String> deleteCarMain(String id);
/**
* 根据当前用户获得车辆信息
*
* @return 车辆信息
*/
List<AppCarMain> getCarMain();
}

View File

@ -0,0 +1,113 @@
package cn.iocoder.yudao.module.app.car.service.impl;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.app.car.entity.AppCarMain;
import cn.iocoder.yudao.module.app.car.mapper.AppCarMainMapper;
import cn.iocoder.yudao.module.app.car.service.AppCarMainService;
import cn.iocoder.yudao.module.custom.entity.CustomerCar;
import cn.iocoder.yudao.module.custom.entity.CustomerMain;
import cn.iocoder.yudao.module.custom.mapper.CustomerCarMapper;
import cn.iocoder.yudao.module.custom.mapper.CustomerMainMapper;
import cn.iocoder.yudao.module.custom.vo.CarMainRespVO;
import cn.iocoder.yudao.module.label.service.BusiLabelService;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.List;
/**
* 车辆信息 Service 实现类
*
* @author 后台管理员
*/
@Service
public class AppCarMainServiceImpl extends ServiceImpl<AppCarMainMapper, AppCarMain> implements AppCarMainService {
@Autowired
private CustomerCarMapper customerCarMapper;
@Autowired
private CustomerMainMapper customerMainMapper;
/**
* 创建车辆信息
*
* @param carMain 创建信息
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public CommonResult<String> createCarMain(AppCarMain carMain) {
baseMapper.insert(carMain);
// 获取当前登录用户
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
// 根据当前登录用户id 查询 base_customer_main 的id
HashMap<String, Object> m = new HashMap<>();
m.put("user_id", loginUser.getId());
List<CustomerMain> customerMains = customerMainMapper.selectByMap(m);
// 关联表添加数据
CustomerCar customerCar = new CustomerCar();
customerCar.setCarId(carMain.getId());
customerCar.setCusId(customerMains.get(0).getId());
customerCarMapper.insert(customerCar);
// 返回
return CommonResult.success("新增成功");
}
/**
* 更新车辆信息
*
* @param carMain 更新信息
*/
@Override
public CommonResult<String> updateCarMain(AppCarMain carMain) {
baseMapper.updateById(carMain);
return CommonResult.success("修改成功");
}
/**
* 删除车辆信息
*
* @param id 编号
*/
@Override
@Transactional(rollbackFor = Exception.class)
public CommonResult<String> deleteCarMain(String id) {
// 删除主表
baseMapper.deleteById(id);
LambdaUpdateWrapper<CustomerCar> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(CustomerCar::getCarId, id);
CustomerCar customerCar = new CustomerCar();
customerCar.setDeleted(true);
// 删除关联表
customerCarMapper.update(customerCar, updateWrapper);
return CommonResult.success("删除成功");
}
/**
* 获得车辆信息
*
* @return
*/
@Override
public List<AppCarMain> getCarMain() {
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
List<AppCarMain> userCarMain = super.baseMapper.getUserCarMain(loginUser.getId());
return userCarMain;
}
}

View File

@ -74,4 +74,5 @@ public interface CarModelService extends IService<CarModel> {
*/
List<CascaderOptionsVO> searchBrand(CarModelReqVO reqVO);
List<CarModel> getCarModelList();
}

View File

@ -123,6 +123,12 @@ public class CarModelServiceImpl extends ServiceImpl<CarModelMapper, CarModel> i
return getChildModel(nameResult,reqVO.getModelName());
}
@Override
public List<CarModel> getCarModelList() {
List<CarModel> carModels = baseMapper.selectByMap(null);
return carModels;
}
/**
* 根据父级品牌集合取所有的型号子选项
*

View File

@ -0,0 +1,15 @@
<?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="cn.iocoder.yudao.module.app.car.mapper.AppCarMainMapper">
<select id="getUserCarMain" resultType="cn.iocoder.yudao.module.app.car.entity.AppCarMain">
select main.* from base_customer_car car INNER JOIN base_car_main main on car.car_id = main.id
where car.cus_id = (
select id from base_customer_main
where user_id = #{userId}
and deleted = 0
) and main.deleted = 0
</select>
</mapper>

View File

@ -7,6 +7,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataRespVO;
import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataSaveReqVO;
@ -101,4 +102,14 @@ public class DictDataController {
ExcelUtils.write(response, "字典数据.xls", "数据", DictDataRespVO.class,
BeanUtils.toBean(list, DictDataRespVO.class));
}
@GetMapping("/type")
@Operation(summary = "根据字典类型查询字典数据信息")
@Parameter(name = "type", description = "字典类型", required = true, example = "common_status")
@TenantIgnore
public CommonResult<List<AppDictDataRespVO>> getDictDataListByType(@RequestParam("type") String type) {
List<DictDataDO> list = dictDataService.getDictDataList(
CommonStatusEnum.ENABLE.getStatus(), type);
return success(BeanUtils.toBean(list, AppDictDataRespVO.class));
}
}

View File

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.controller.app.dict;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.module.system.controller.app.dict.vo.AppDictDataRespVO;
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
import cn.iocoder.yudao.module.system.service.dict.DictDataService;
@ -32,6 +33,7 @@ public class AppDictDataController {
@GetMapping("/type")
@Operation(summary = "根据字典类型查询字典数据信息")
@Parameter(name = "type", description = "字典类型", required = true, example = "common_status")
@TenantIgnore
public CommonResult<List<AppDictDataRespVO>> getDictDataListByType(@RequestParam("type") String type) {
List<DictDataDO> list = dictDataService.getDictDataList(
CommonStatusEnum.ENABLE.getStatus(), type);

View File

@ -67,6 +67,7 @@ flowable:
# MyBatis Plus 的配置项
mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
global-config:
@ -278,6 +279,7 @@ yudao:
- /admin-api/rescue/loginJcApp
- /admin-api/system/tenant/getListByWebsite
- /admin-api/websocket/**
- /admin-api/system/dict-data/type
ignore-tables:
- system_tenant
- system_tenant_package