
import mongoose, { Schema, Document, models } from "mongoose";
import { Base } from "./base";

interface IBuildPartsInterface extends Base, Document {
    addressGovCode: string;
    no: number;
    level: number;
    code: string;
    grossSize: number;
    netSize: number;
    defaultAccessory: string;
    humanLivability: boolean;
    key: string;
    directionId: Schema.Types.ObjectId;
    typeId: Schema.Types.ObjectId;
}

const BuildPartsSchema = new Schema({
    buildId: { type: Schema.Types.ObjectId, ref: "Build", required: true },
    addressGovCode: { type: String, required: true },
    no: { type: Number, required: true },
    level: { type: Number, required: true },
    code: { type: String, required: true },
    grossSize: { type: Number, required: true },
    netSize: { type: Number, required: true },
    defaultAccessory: { type: String, required: true },
    humanLivability: { type: Boolean, required: true },
    key: { type: String, required: true },
    directionId: { type: Schema.Types.ObjectId, ref: "ApiEnumDropdown", required: true },
    typeId: { type: Schema.Types.ObjectId, ref: "ApiEnumDropdown", required: true },
});

const BuildParts = models.BuildParts || mongoose.model<IBuildPartsInterface>("BuildParts", BuildPartsSchema);

export { BuildParts };
export type { IBuildPartsInterface };
