import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Types } from 'mongoose';
import { ObjectType, Field, ID, Float } from '@nestjs/graphql';
import { Base } from '@/models/base.model';

@ObjectType()
@Schema({ timestamps: true })
export class BuildParts extends Base {

    @Field(() => ID)
    readonly _id: string;

    @Field(() => ID)
    @Prop({ type: Types.ObjectId, ref: 'Build', required: true })
    buildId: Types.ObjectId;

    @Field()
    @Prop({ required: true })
    addressGovCode: string;

    @Field(() => Float)
    @Prop({ required: true })
    no: number;

    @Field(() => Float)
    @Prop({ required: true })
    level: number;

    @Field()
    @Prop({ required: true })
    code: string;

    @Field(() => Float)
    @Prop({ required: true })
    grossSize: number;

    @Field(() => Float)
    @Prop({ required: true })
    netSize: number;

    @Field()
    @Prop({ required: true })
    defaultAccessory: string;

    @Field()
    @Prop({ required: true })
    humanLivability: boolean;

    @Field()
    @Prop({ required: true })
    key: string;

    @Field(() => ID, { nullable: true })
    @Prop({ type: Types.ObjectId, ref: 'ApiEnumDropdown', required: false })
    directionId: Types.ObjectId;

    @Field(() => ID, { nullable: true })
    @Prop({ type: Types.ObjectId, ref: 'ApiEnumDropdown', required: false })
    typeId: Types.ObjectId;

}

export type BuildPartsDocument = BuildParts & Document;
export const BuildPartsSchema = SchemaFactory.createForClass(BuildParts);
