enhance: extend unit and inspection
This commit is contained in:
parent
69169aa925
commit
314d607fa8
16 changed files with 67 additions and 1 deletions
|
@ -67,6 +67,7 @@ import { CreateSchema1749296280721 } from "./migrations/1749296280721-CreateSche
|
|||
import { UpdateNewsletterQueryRelation1752502069178 } from "./migrations/1752502069178-updateNewsletterQueryRelation";
|
||||
import { UnitBase1752914551204 } from "./migrations/1752914551204-UnitBase";
|
||||
import { repair } from "./entity/unit/repair";
|
||||
import { UnitExtendImagesAndInspection1753777774744 } from "./migrations/1753777774744-UnitExtendImagesAndInspection";
|
||||
|
||||
configCheck();
|
||||
|
||||
|
@ -142,8 +143,9 @@ const dataSource = new DataSource({
|
|||
migrations: [
|
||||
BackupAndResetDatabase1749296262915,
|
||||
CreateSchema1749296280721,
|
||||
UnitBase1752914551204,
|
||||
UpdateNewsletterQueryRelation1752502069178,
|
||||
UnitBase1752914551204,
|
||||
UnitExtendImagesAndInspection1753777774744,
|
||||
],
|
||||
migrationsRun: true,
|
||||
migrationsTransactionMode: "each",
|
||||
|
|
|
@ -11,6 +11,9 @@ export class equipment {
|
|||
@PrimaryGeneratedColumn("uuid")
|
||||
id: string;
|
||||
|
||||
@Column({ type: "boolean", default: false })
|
||||
hasImage: boolean;
|
||||
|
||||
@Column({ type: "varchar", length: 255, nullable: true, default: null, unique: true })
|
||||
code?: string;
|
||||
|
||||
|
|
|
@ -19,6 +19,9 @@ export class inspectionPlan {
|
|||
@Column({ type: "varchar", length: 255, nullable: true, default: null })
|
||||
remindTime?: PlanTimeDefinition;
|
||||
|
||||
@Column({ type: "boolean", default: false })
|
||||
allInRange: boolean;
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt: Date;
|
||||
|
||||
|
|
|
@ -36,6 +36,9 @@ export class inspectionPoint {
|
|||
@Column({ type: "varchar", length: 255, default: null })
|
||||
others?: string;
|
||||
|
||||
@Column({ type: "boolean", default: false })
|
||||
optional: boolean;
|
||||
|
||||
@Column({ type: "int", default: 0 })
|
||||
sort: number;
|
||||
|
||||
|
|
|
@ -11,6 +11,9 @@ export class vehicle {
|
|||
@PrimaryGeneratedColumn("uuid")
|
||||
id: string;
|
||||
|
||||
@Column({ type: "boolean", default: false })
|
||||
hasImage: boolean;
|
||||
|
||||
@Column({ type: "varchar", length: 255, nullable: true, default: null, unique: true })
|
||||
code?: string;
|
||||
|
||||
|
|
|
@ -12,6 +12,9 @@ export class wearable {
|
|||
@PrimaryGeneratedColumn("uuid")
|
||||
id: string;
|
||||
|
||||
@Column({ type: "boolean", default: false })
|
||||
hasImage: boolean;
|
||||
|
||||
@Column({ type: "varchar", length: 255, nullable: true, default: null, unique: true })
|
||||
code?: string;
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ export default abstract class EquipmentFactory {
|
|||
public static mapToSingle(record: equipment): EquipmentViewModel {
|
||||
return {
|
||||
id: record.id,
|
||||
hasImage: record.hasImage,
|
||||
code: record?.code,
|
||||
name: record.name,
|
||||
location: record.location,
|
||||
|
|
|
@ -49,6 +49,7 @@ export default abstract class InspectionPlanFactory {
|
|||
title: record.title,
|
||||
inspectionInterval: record.inspectionInterval,
|
||||
remindTime: record.remindTime,
|
||||
allInRange: record.allInRange,
|
||||
version: record?.latestVersionedPlan?.version ?? 0,
|
||||
created: record.createdAt,
|
||||
inspectionPoints: record.latestVersionedPlan
|
||||
|
|
|
@ -13,6 +13,7 @@ export default abstract class InspectionPointFactory {
|
|||
title: record.title,
|
||||
description: record.description,
|
||||
type: record.type,
|
||||
optional: record.optional,
|
||||
sort: record.sort,
|
||||
min: record?.min,
|
||||
max: record?.max,
|
||||
|
|
|
@ -11,6 +11,7 @@ export default abstract class VehicleFactory {
|
|||
public static mapToSingle(record: vehicle): VehicleViewModel {
|
||||
return {
|
||||
id: record.id,
|
||||
hasImage: record.hasImage,
|
||||
code: record?.code,
|
||||
name: record.name,
|
||||
location: record.location,
|
||||
|
|
|
@ -15,6 +15,7 @@ export default abstract class WearableFactory {
|
|||
public static mapToSingle(record: wearable): WearableViewModel {
|
||||
return {
|
||||
id: record.id,
|
||||
hasImage: record.hasImage,
|
||||
code: record?.code,
|
||||
name: record.name,
|
||||
location: record.location,
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
import { MigrationInterface, QueryRunner, TableColumn } from "typeorm";
|
||||
import { inspection_plan_table, inspection_point_table } from "./baseSchemaTables/inspection";
|
||||
import { getTypeByORM, getDefaultByORM } from "./ormHelper";
|
||||
import { equipment_table, vehicle_table, wearable_table } from "./baseSchemaTables/unit";
|
||||
|
||||
export class UnitExtendImagesAndInspection1753777774744 implements MigrationInterface {
|
||||
name = "UnitExtendImagesAndInspection1753777774744";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.addColumn(
|
||||
inspection_plan_table.name,
|
||||
new TableColumn({ name: "allInRange", ...getTypeByORM("boolean"), default: getDefaultByORM("boolean", false) })
|
||||
);
|
||||
await queryRunner.addColumn(
|
||||
inspection_point_table.name,
|
||||
new TableColumn({ name: "optional", ...getTypeByORM("boolean"), default: getDefaultByORM("boolean", false) })
|
||||
);
|
||||
await queryRunner.addColumn(
|
||||
vehicle_table.name,
|
||||
new TableColumn({ name: "hasImage", ...getTypeByORM("boolean"), default: getDefaultByORM("boolean", false) })
|
||||
);
|
||||
await queryRunner.addColumn(
|
||||
equipment_table.name,
|
||||
new TableColumn({ name: "hasImage", ...getTypeByORM("boolean"), default: getDefaultByORM("boolean", false) })
|
||||
);
|
||||
await queryRunner.addColumn(
|
||||
wearable_table.name,
|
||||
new TableColumn({ name: "hasImage", ...getTypeByORM("boolean"), default: getDefaultByORM("boolean", false) })
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.dropColumn(inspection_plan_table.name, "allInRange");
|
||||
await queryRunner.dropColumn(inspection_point_table.name, "optional");
|
||||
await queryRunner.dropColumn(vehicle_table.name, "hasImage");
|
||||
await queryRunner.dropColumn(equipment_table.name, "hasImage");
|
||||
await queryRunner.dropColumn(wearable_table.name, "hasImage");
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ import type { EquipmentTypeViewModel } from "./equipmentType.models";
|
|||
|
||||
export interface EquipmentViewModel {
|
||||
id: string;
|
||||
hasImage: boolean;
|
||||
code?: string;
|
||||
name: string;
|
||||
location: string;
|
||||
|
|
|
@ -29,6 +29,7 @@ export type InspectionPlanViewModel = {
|
|||
title: string;
|
||||
inspectionInterval: PlanTimeDefinition;
|
||||
remindTime: PlanTimeDefinition;
|
||||
allInRange: boolean;
|
||||
version: number;
|
||||
created: Date;
|
||||
inspectionPoints: InspectionPointViewModel[];
|
||||
|
@ -49,5 +50,6 @@ export interface InspectionPointViewModel {
|
|||
min?: number;
|
||||
max?: number;
|
||||
others?: string;
|
||||
optional: boolean;
|
||||
sort: number;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import type { VehicleTypeViewModel } from "./vehicleType.models";
|
|||
|
||||
export interface VehicleViewModel {
|
||||
id: string;
|
||||
hasImage: boolean;
|
||||
code?: string;
|
||||
name: string;
|
||||
location: string;
|
||||
|
|
|
@ -3,6 +3,7 @@ import type { WearableTypeViewModel } from "./wearableType.models";
|
|||
|
||||
export interface WearableViewModel {
|
||||
id: string;
|
||||
hasImage: boolean;
|
||||
code?: string;
|
||||
name: string;
|
||||
location: string;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue