VehicleController.ts 5.2 KB
import { FileInfo } from "autumn-vue/lib/core/bean/FileInfo";
import { Page } from "autumn-vue/lib/core/page/Page";
import { AxiosResponse, AxiosStatic } from "axios";
import dayjs, { Dayjs } from "dayjs";
import { NameCount } from "lib/src/entity/analysis/domain/NameCount";
import { VehicleHistoryProjection } from "lib/src/entity/vehicle/domain/VehicleHistoryProjection";
// region 前端扩展导入包
import { Vehicle } from "lib/src/entity/vehicle/entity/Vehicle";
// endregion

/**
 * 库存车辆(Vehicle) PI接口
 * @author gonglei
 * @since 2025-10-13 12:18:11
 */
export const VehicleController = {
	/**
	 * 新增库存车辆
	 * @param vehicle
	 * @return Vehicle
	 */
	addVehicle(axios: AxiosStatic, vehicle: any): Promise<AxiosResponse<Vehicle>> {
		return axios.post("vehicle/addVehicle", vehicle);
	},

	/**
	 */
	exportCheckedVehicles(axios: AxiosStatic, vehicleIds: any, config?: any): Promise<AxiosResponse<void>> {
		return axios.post("vehicle/exportCheckedVehicles", vehicleIds, config);
	},

	/**
	 */
	exportPriceVehicles(axios: AxiosStatic, pagination: any, config?: any): Promise<AxiosResponse<void>> {
		return axios.post("vehicle/exportPriceVehicles", pagination, config);
	},

	/**
	 * 导出车辆列表
	 * @param pagination
	 * @param response
	 * @throws IOException
	 */
	exportVehicles(axios: AxiosStatic, pagination: any, config?: any): Promise<AxiosResponse<void>> {
		return axios.post("vehicle/exportVehicles", pagination, config);
	},

	/**
	 */
	getTop3VehiclesByInventory(axios: AxiosStatic): Promise<AxiosResponse<Vehicle[]>> {
		return axios.get("vehicle/getTop3VehiclesByInventory");
	},

	/**
	 * 按车辆品牌统计车辆数量
	 * @return List
	 */
	getVehicleBrandCounts(axios: AxiosStatic): Promise<AxiosResponse<NameCount[]>> {
		return axios.get("vehicle/getVehicleBrandCounts");
	},

	/**
	 * 根据id查询库存车辆
	 * @param vehicleId
	 * @return Vehicle
	 */
	getVehicleById(axios: AxiosStatic, vehicleId: number): Promise<AxiosResponse<Vehicle>> {
		return axios.get("vehicle/getVehicleById", { params: { vehicleId } });
	},

	/**
	 */
	getVehicleCountByProvinceName(axios: AxiosStatic): Promise<AxiosResponse<any>> {
		return axios.get("vehicle/getVehicleCountByProvinceName");
	},

	/**
	 */
	getVehicleCountBySource(axios: AxiosStatic): Promise<AxiosResponse<any>> {
		return axios.get("vehicle/getVehicleCountBySource");
	},

	/**
	 */
	getVehicleCountByState(axios: AxiosStatic): Promise<AxiosResponse<any>> {
		return axios.get("vehicle/getVehicleCountByState");
	},

	/**
	 */
	getVehicleCountByStateAndDateRange(
		axios: AxiosStatic,
		startDate: Dayjs | string,
		endDate: Dayjs | string,
	): Promise<AxiosResponse<any>> {
		if (startDate instanceof Object) {
			startDate = dayjs(startDate).format("YYYY-MM-DD");
		}
		if (endDate instanceof Object) {
			endDate = dayjs(endDate).format("YYYY-MM-DD");
		}

		return axios.get("vehicle/getVehicleCountByStateAndDateRange", {
			params: { startDate, endDate },
		});
	},

	/**
	 */
	getVehicleCountByVehicleClass(axios: AxiosStatic): Promise<AxiosResponse<any>> {
		return axios.get("vehicle/getVehicleCountByVehicleClass");
	},

	/**
	 */
	getVehicleHistories(
		axios: AxiosStatic,
		vehicleId: number,
	): Promise<AxiosResponse<VehicleHistoryProjection[]>> {
		return axios.get("vehicle/getVehicleHistories", { params: { vehicleId } });
	},

	/**
	 */
	moveVehicleAlbum(
		axios: AxiosStatic,
		uid: string,
		fileSubtype: string,
		vehicleId: number,
	): Promise<AxiosResponse<number>> {
		return axios.get("vehicle/moveVehicleAlbum", {
			params: { uid, fileSubtype, vehicleId },
		});
	},

	/**
	 */
	pagePriceVehicle(axios: AxiosStatic, pagination: any): Promise<AxiosResponse<Page<Vehicle>>> {
		return axios.post("vehicle/pagePriceVehicle", pagination);
	},

	PAGE_PRICE_VEHICLE : "vehicle/pagePriceVehicle",

	/**
	 * 分页查询库存车辆
	 * @param pagination
	 * @return Page
	 */
	pageVehicle(axios: AxiosStatic, pagination: any): Promise<AxiosResponse<Page<Vehicle>>> {
		return axios.post("vehicle/pageVehicle", pagination);
	},

	PAGE_VEHICLE : "vehicle/pageVehicle",

	/**
	 * 删除库存车辆
	 * @param vehicleId
	 * @return int
	 */
	removeVehicleById(axios: AxiosStatic, vehicleId: number): Promise<AxiosResponse<number>> {
		return axios.delete("vehicle/removeVehicleById", { params: { vehicleId } });
	},

	/**
	 * 修改库存车辆
	 * @param vehicle
	 * @return Vehicle
	 */
	updateVehicle(axios: AxiosStatic, vehicle: any): Promise<AxiosResponse<Vehicle>> {
		return axios.post("vehicle/updateVehicle", vehicle);
	},

	/**
	 * x修改车辆地点
	 * @param vehicleVenue
	 * @return Vehicle
	 */
	updateVehicleVenue(axios: AxiosStatic, vehicleVenue: any): Promise<AxiosResponse<Vehicle>> {
		return axios.post("vehicle/updateVehicleVenue", vehicleVenue);
	},

	/**
	 * 更新车辆封面
	 */
	uploadVehicleCover(axios: AxiosStatic, fileInfo: any, vehicleId: number): Promise<AxiosResponse<FileInfo>> {
		return axios.post("vehicle/uploadVehicleCover", fileInfo, { params: { vehicleId } });
	},

	/**
	 * 整备入库车辆
	 * @param vehicle
	 * @return Vehicle
	 */
	warehousingVehicle(axios: AxiosStatic, vehicle: any): Promise<AxiosResponse<Vehicle>> {
		return axios.post("vehicle/warehousingVehicle", vehicle);
	},

	// region 前端扩展代码区
	// endregion
};