车辆管理代码更新

master
tangwenkang 2023-11-23 20:05:01 +08:00
parent bd1724e3c2
commit e1de510a3e
9 changed files with 83 additions and 18 deletions

View File

@ -2,6 +2,7 @@ package com.dragon.vehicle.history.common.domain;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@ -56,6 +57,7 @@ public class Fence {
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/**
*
@ -64,5 +66,6 @@ public class Fence {
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
}

View File

@ -44,9 +44,9 @@ public class ReqCar {
*/
private Integer carTypeId;
/**
* ID
*
*/
private Integer fenceId;
private String fenceName;
/**
* 1-线 0-线
*/

View File

@ -95,7 +95,10 @@
<artifactId>mybatis-plus-join</artifactId>
<version>1.2.4</version>
</dependency>
<dependency>
<groupId>com.dragon</groupId>
<artifactId>dragon-common-security</artifactId>
</dependency>
</dependencies>

View File

@ -59,4 +59,14 @@ public class CarController {
public Result deleteCar(@RequestParam String carVin){
return carService.deleteCar(carVin);
}
/**
*
* @param car
* @return
*/
@PostMapping("/insertCar")
public Result insertCar(@RequestBody Car car){
return carService.insertCar(car);
}
}

View File

@ -1,16 +1,10 @@
package com.dragon.vehicle.history.server.controller;
import com.dragon.common.core.domain.Result;
import com.dragon.vehicle.history.common.domain.VehicleOperation;
import com.dragon.vehicle.history.server.service.HistoricalTrackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author Wenkang Tang
* @date 2023/11/19 19:54
@ -20,4 +14,6 @@ import java.util.List;
public class HistoricalTrackController {
@Autowired
private HistoricalTrackService historicalTrackService;
}

View File

@ -0,0 +1,14 @@
package com.dragon.vehicle.history.server.mapper;
import com.dragon.vehicle.history.common.domain.Fence;
import com.github.yulichang.base.MPJBaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* @author Wenkang Tang
* @date 2023/11/22 20:51
* @description
*/
@Mapper
public interface FenceMapper extends MPJBaseMapper<Fence> {
}

View File

@ -39,4 +39,11 @@ public interface CarService {
* @return
*/
Result deleteCar(String carVin);
/**
*
* @param car
* @return
*/
Result insertCar(Car car);
}

View File

@ -1,5 +1,7 @@
package com.dragon.vehicle.history.server.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dragon.common.core.domain.Result;
import com.dragon.vehicle.history.common.domain.Car;
@ -11,6 +13,7 @@ import com.dragon.vehicle.history.server.mapper.CarMapper;
import com.dragon.vehicle.history.server.mapper.CarTypeMapper;
import com.dragon.vehicle.history.server.service.CarService;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -22,6 +25,7 @@ import java.util.List;
* @description
*/
@Service
@Log4j2
public class CarServiceImpl implements CarService {
@Autowired
private CarMapper carMapper;
@ -35,6 +39,7 @@ public class CarServiceImpl implements CarService {
*/
@Override
public Result<List<ResCar>> listCar(ReqCar reqCar) {
log.info(reqCar);
Page<ResCar> resCarPage = new Page<>(reqCar.getPageNum(), reqCar.getPageSize());
List<ResCar> resCars = carMapper.selectJoinPage(resCarPage, ResCar.class, new MPJLambdaWrapper<Car>()
.selectAll(Car.class)
@ -47,8 +52,9 @@ public class CarServiceImpl implements CarService {
.like(reqCar.getCarVin() != null, Car::getCarVin, reqCar.getCarVin())
.eq(reqCar.getCarStatus() != null, Car::getCarStatus, reqCar.getCarStatus())
.eq(reqCar.getCarTypeId() != null, CarType::getCarTypeId, reqCar.getCarTypeId())
.eq(reqCar.getFenceId() != null, Car::getFenceId, reqCar.getFenceId())).getRecords();
return Result.success(resCars);
.like(reqCar.getFenceName() != null, Fence::getFenceName, reqCar.getFenceName())
).getRecords();
return Result.success(resCars,"查询成功!");
}
/**
@ -58,7 +64,7 @@ public class CarServiceImpl implements CarService {
@Override
public Result<List<CarType>> listCarType() {
MPJLambdaWrapper<CarType> carTypeMPJLambdaWrapper = new MPJLambdaWrapper<CarType>().selectAll(CarType.class);
return Result.success(carTypeMapper.selectList(carTypeMPJLambdaWrapper));
return Result.success(carTypeMapper.selectList(carTypeMPJLambdaWrapper),"查询成功!");
}
/**
@ -69,10 +75,10 @@ public class CarServiceImpl implements CarService {
*/
@Override
public Result updateCar(Car car) {
MPJLambdaWrapper<Car> carMPJLambdaWrapper = new MPJLambdaWrapper<>();
MPJLambdaWrapper<Car> lambdaWrapper = carMPJLambdaWrapper.eq(Car::getCarVin, car.getCarVin());
carMapper.update(car,lambdaWrapper);
return Result.success();
LambdaUpdateWrapper<Car> wrapper = new LambdaUpdateWrapper<>();
LambdaUpdateWrapper<Car> lambdaUpdateWrapper = wrapper.eq(Car::getCarId, car.getCarId());
carMapper.update(car,lambdaUpdateWrapper);
return Result.success("修改成功!");
}
/**
@ -82,7 +88,28 @@ public class CarServiceImpl implements CarService {
*/
@Override
public Result deleteCar(String carVin) {
carMapper.deleteById(carVin);
return Result.success();
LambdaUpdateWrapper<Car> wrapper = new LambdaUpdateWrapper<>();
LambdaUpdateWrapper<Car> carLambdaUpdateWrapper = wrapper.eq(Car::getCarVin, carVin);
carMapper.delete(carLambdaUpdateWrapper);
return Result.success("删除成功!");
}
/**
*
* @param car
* @return
*/
@Override
public Result insertCar(Car car) {
Car inserCar = new Car();
inserCar.setCarTypeId(car.getCarTypeId());
inserCar.setCarBrand(car.getCarBrand());
inserCar.setCarName(car.getCarName());
inserCar.setCarVin(car.getCarVin());
inserCar.setFenceId(car.getFenceId());
inserCar.setIsDelete(0);
inserCar.setCarStatus(0);
carMapper.insert(inserCar);
return Result.success("添加成功!");
}
}

View 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.dragon.vehicle.history.server.mapper.FenceMapper">
</mapper>