forked from Yara724/api
Fixed claim/blame damagedParts
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
|
||||
import { Types } from "mongoose";
|
||||
import { Schema as MongooseSchema, Types } from "mongoose";
|
||||
import { AiImagesModel } from "./ai-image.schema";
|
||||
import { CarGreenCardModel } from "./car-green-card.schema";
|
||||
import { ImageRequiredModel } from "./image-required.schema";
|
||||
@@ -20,6 +20,39 @@ export class CapturedImage {
|
||||
}
|
||||
export const CapturedImageSchema = SchemaFactory.createForClass(CapturedImage);
|
||||
|
||||
/** One row per selected damaged part (index-aligned with `damage.selectedParts`). */
|
||||
@Schema({ _id: false })
|
||||
export class DamagedPartMediaV2Row {
|
||||
@Prop({ type: Number })
|
||||
id?: number;
|
||||
|
||||
@Prop({ type: String })
|
||||
name?: string;
|
||||
|
||||
@Prop({ type: String })
|
||||
side?: string;
|
||||
|
||||
@Prop({ type: String })
|
||||
label_fa?: string;
|
||||
|
||||
@Prop({ type: String })
|
||||
catalogKey?: string;
|
||||
|
||||
@Prop({ type: String })
|
||||
path?: string;
|
||||
|
||||
@Prop({ type: String })
|
||||
fileName?: string;
|
||||
|
||||
@Prop({ type: String })
|
||||
url?: string;
|
||||
|
||||
@Prop({ type: Date })
|
||||
capturedAt?: Date;
|
||||
}
|
||||
export const DamagedPartMediaV2RowSchema =
|
||||
SchemaFactory.createForClass(DamagedPartMediaV2Row);
|
||||
|
||||
@Schema({ _id: false })
|
||||
export class ClaimMedia {
|
||||
@Prop({ type: CarGreenCardModel })
|
||||
@@ -46,15 +79,10 @@ export class ClaimMedia {
|
||||
carAngles?: Map<string, CapturedImage>;
|
||||
|
||||
/**
|
||||
* V2: Damaged parts captures
|
||||
* Map of part key to captured image
|
||||
* V2: Damaged parts captures — prefer an array (index matches `damage.selectedParts`).
|
||||
* Legacy documents may store a plain object map keyed by part slug until migrated on write.
|
||||
*/
|
||||
@Prop({
|
||||
type: Map,
|
||||
of: CapturedImageSchema,
|
||||
default: () => ({}),
|
||||
})
|
||||
damagedParts?: Map<string, CapturedImage>;
|
||||
@Prop({ type: MongooseSchema.Types.Mixed })
|
||||
damagedParts?: DamagedPartMediaV2Row[] | Record<string, unknown>;
|
||||
}
|
||||
export const ClaimMediaSchema = SchemaFactory.createForClass(ClaimMedia);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user