This commit is contained in:
2025-10-03 17:05:04 +07:00
3 changed files with 123 additions and 0 deletions

View File

@ -0,0 +1,95 @@
import { Column, CreateDateColumn, DeleteDateColumn, Entity, JoinColumn, JoinTable, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm";
import { GpsDevice } from "./gps_devices";
import { GpsActionType, GpsEngineStatus, GpsIgnitionStatus, GpsReverseGeoStatus } from "../types/gps";
@Entity("gps_device_logs", { schema: "gps" })
export class GpsDeviceLog {
@PrimaryGeneratedColumn("uuid")
id: string;
@ManyToOne(() => GpsDevice, { nullable: true })
@JoinColumn({ name: "deviceId" })
device: GpsDevice;
@Column({
nullable: true,
})
activity_at: Date;
@Column({
nullable: false,
type: "text",
})
socket: string;
@Column({
nullable: false,
type: "text",
})
hex: string;
@Column({
nullable: false,
})
action: GpsActionType;
@Column({
nullable: true,
type: "double precision",
})
latitude: number;
@Column({
nullable: true,
type: "double precision",
})
longitude: number;
@Column({
nullable: true,
type: "float",
})
speed: string;
@Column({
nullable: true,
})
ignition_status: GpsIgnitionStatus;
@Column({
nullable: true,
})
engine_status: GpsEngineStatus;
@Column({
nullable: true,
})
reverse_geo_status: GpsReverseGeoStatus;
@Column({
nullable: true,
type: "jsonb",
})
reverse_geo: string;
@Column()
@CreateDateColumn()
created_at: Date;
@Column({ type: "varchar", length: 255 })
created_by: string;
@Column({ nullable: true })
@UpdateDateColumn()
updated_at: Date;
@Column({ type: "varchar", length: 255, nullable: true })
updated_by: string;
@Column({ nullable: true })
@DeleteDateColumn()
deleted_at: Date;
@Column({ type: "varchar", length: 255, nullable: true })
deleted_by: string;
}

View File

@ -1 +1,3 @@
export * from "../types/gps";
export * from "../entity/gps_devices"; export * from "../entity/gps_devices";
export * from "../entity/gps_device_log";

26
src/types/gps.ts Normal file
View File

@ -0,0 +1,26 @@
export enum GpsActionType {
"login" = "login",
"heartbeat" = "heartbeat",
"location" = "location",
"other" = "other",
}
export enum GpsIgnitionStatus {
"on" = "on",
"off" = "off",
"acc_low" = "acc_low",
"acc_high" = "acc_high",
}
export enum GpsEngineStatus {
"idling" = "idling",
"moving" = "moving",
"stopping" = "stopping",
}
export enum GpsReverseGeoStatus {
"pending" = "pending",
"process" = "process",
"success" = "success",
"fail" = "fail",
}