From 14343bb67955b3c6a134b4d3bea1761f3492165b Mon Sep 17 00:00:00 2001 From: zhaotianfeng <12345678> Date: Tue, 24 Sep 2024 17:09:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=91=E7=9A=84=E8=BD=A6=E8=BE=86=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../car/controller/AppCarMainController.java | 81 +++++++++++ .../car/controller/AppCarModelController.java | 52 +++++++ .../module/app/car/entity/AppCarMain.java | 136 ++++++++++++++++++ .../app/car/mapper/AppCarMainMapper.java | 17 +++ .../app/car/service/AppCarMainService.java | 49 +++++++ .../service/impl/AppCarMainServiceImpl.java | 113 +++++++++++++++ .../custom/service/CarModelService.java | 1 + .../service/impl/CarModelServiceImpl.java | 6 + .../resources/mapper/car/AppCarMainMapper.xml | 15 ++ .../admin/dict/DictDataController.java | 11 ++ .../app/dict/AppDictDataController.java | 2 + .../src/main/resources/application.yaml | 2 + 12 files changed, 485 insertions(+) create mode 100644 dl-module-base/src/main/java/cn/iocoder/yudao/module/app/car/controller/AppCarMainController.java create mode 100644 dl-module-base/src/main/java/cn/iocoder/yudao/module/app/car/controller/AppCarModelController.java create mode 100644 dl-module-base/src/main/java/cn/iocoder/yudao/module/app/car/entity/AppCarMain.java create mode 100644 dl-module-base/src/main/java/cn/iocoder/yudao/module/app/car/mapper/AppCarMainMapper.java create mode 100644 dl-module-base/src/main/java/cn/iocoder/yudao/module/app/car/service/AppCarMainService.java create mode 100644 dl-module-base/src/main/java/cn/iocoder/yudao/module/app/car/service/impl/AppCarMainServiceImpl.java create mode 100644 dl-module-base/src/main/resources/mapper/car/AppCarMainMapper.xml diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/app/car/controller/AppCarMainController.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/app/car/controller/AppCarMainController.java new file mode 100644 index 00000000..37874f74 --- /dev/null +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/app/car/controller/AppCarMainController.java @@ -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 createCarMain(@RequestBody AppCarMain carMain) { + return carMainService.createCarMain(carMain); + } + + /** + * 更新车辆信息 + * + * @param carMain + * @return + */ + @PutMapping("/update") + @Operation(summary = "更新车辆信息") +// @PreAuthorize("@ss.hasPermission('base:car-main:update')") + public CommonResult 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 deleteCarMain(@RequestParam("id") String id) { + return carMainService.deleteCarMain(id); + } + + /** + * 根据当前用户获得车辆信息 + * + * @return + */ + @GetMapping("/get") + @Operation(summary = "获得车辆信息") +// @PreAuthorize("@ss.hasPermission('base:car-main:query')") + public CommonResult> getCarMain() { + + List carMain = carMainService.getCarMain(); + return CommonResult.success(carMain); + } + + +} \ No newline at end of file diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/app/car/controller/AppCarModelController.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/app/car/controller/AppCarModelController.java new file mode 100644 index 00000000..40c7320c --- /dev/null +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/app/car/controller/AppCarModelController.java @@ -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> getList() { + List carModelList = carModelService.getCarModelList(); + return success(carModelList); + } + + + +} \ No newline at end of file diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/app/car/entity/AppCarMain.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/app/car/entity/AppCarMain.java new file mode 100644 index 00000000..51fdd255 --- /dev/null +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/app/car/entity/AppCarMain.java @@ -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; + +} \ No newline at end of file diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/app/car/mapper/AppCarMainMapper.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/app/car/mapper/AppCarMainMapper.java new file mode 100644 index 00000000..3a0c852e --- /dev/null +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/app/car/mapper/AppCarMainMapper.java @@ -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 { + + +// 查询当前用户的所有车辆 + List getUserCarMain(@Param("userId") Long userId); + +} diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/app/car/service/AppCarMainService.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/app/car/service/AppCarMainService.java new file mode 100644 index 00000000..50f23cb4 --- /dev/null +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/app/car/service/AppCarMainService.java @@ -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 { + + /** + * 创建车辆信息 + * + * @param carMain 创建信息 + * @return 编号 + */ + CommonResult createCarMain(AppCarMain carMain); + + /** + * 更新车辆信息 + * + * @param carMain 更新信息 + */ + CommonResult updateCarMain(AppCarMain carMain); + + /** + * 删除车辆信息 + * + * @param id 编号 + */ + CommonResult deleteCarMain(String id); + + /** + * 根据当前用户获得车辆信息 + * + * @return 车辆信息 + */ + List getCarMain(); + + + + +} \ No newline at end of file diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/app/car/service/impl/AppCarMainServiceImpl.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/app/car/service/impl/AppCarMainServiceImpl.java new file mode 100644 index 00000000..84204cf1 --- /dev/null +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/app/car/service/impl/AppCarMainServiceImpl.java @@ -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 implements AppCarMainService { + + @Autowired + private CustomerCarMapper customerCarMapper; + @Autowired + private CustomerMainMapper customerMainMapper; + + /** + * 创建车辆信息 + * + * @param carMain 创建信息 + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public CommonResult createCarMain(AppCarMain carMain) { + + baseMapper.insert(carMain); +// 获取当前登录用户 + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); +// 根据当前登录用户id 查询 base_customer_main 的id + HashMap m = new HashMap<>(); + m.put("user_id", loginUser.getId()); + List 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 updateCarMain(AppCarMain carMain) { + baseMapper.updateById(carMain); + return CommonResult.success("修改成功"); + } + + /** + * 删除车辆信息 + * + * @param id 编号 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public CommonResult deleteCarMain(String id) { +// 删除主表 + baseMapper.deleteById(id); + LambdaUpdateWrapper 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 getCarMain() { + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + List userCarMain = super.baseMapper.getUserCarMain(loginUser.getId()); + + + return userCarMain; + } + + + + +} \ 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 793ee7bd..8376736c 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 @@ -74,4 +74,5 @@ public interface CarModelService extends IService { */ List searchBrand(CarModelReqVO reqVO); + List getCarModelList(); } \ 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 02d3aed0..8154d6c4 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 @@ -123,6 +123,12 @@ public class CarModelServiceImpl extends ServiceImpl i return getChildModel(nameResult,reqVO.getModelName()); } + @Override + public List getCarModelList() { + List carModels = baseMapper.selectByMap(null); + return carModels; + } + /** * 根据父级品牌集合取所有的型号子选项 * diff --git a/dl-module-base/src/main/resources/mapper/car/AppCarMainMapper.xml b/dl-module-base/src/main/resources/mapper/car/AppCarMainMapper.xml new file mode 100644 index 00000000..9ecbb1a6 --- /dev/null +++ b/dl-module-base/src/main/resources/mapper/car/AppCarMainMapper.xml @@ -0,0 +1,15 @@ + + + + + + + \ No newline at end of file diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dict/DictDataController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dict/DictDataController.java index 8a987f6f..902d09ca 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dict/DictDataController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dict/DictDataController.java @@ -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> getDictDataListByType(@RequestParam("type") String type) { + List list = dictDataService.getDictDataList( + CommonStatusEnum.ENABLE.getStatus(), type); + return success(BeanUtils.toBean(list, AppDictDataRespVO.class)); + } } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/dict/AppDictDataController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/dict/AppDictDataController.java index 8c4b97f6..a421f710 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/dict/AppDictDataController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/dict/AppDictDataController.java @@ -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> getDictDataListByType(@RequestParam("type") String type) { List list = dictDataService.getDictDataList( CommonStatusEnum.ENABLE.getStatus(), type); diff --git a/yudao-server/src/main/resources/application.yaml b/yudao-server/src/main/resources/application.yaml index ff6900d0..de144cf1 100644 --- a/yudao-server/src/main/resources/application.yaml +++ b/yudao-server/src/main/resources/application.yaml @@ -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