From d3d2b7d97283e1ebbab09fbe787f8612420db716 Mon Sep 17 00:00:00 2001 From: Richardkingz2019 Date: Wed, 27 May 2026 14:43:02 +0000 Subject: [PATCH] feat: implement property virtual tours (closes #334) - Add virtualTourUrl and videoUrl optional fields to Property model - Add migration to add virtual_tour_url and video_url columns - Update CreatePropertyDto and UpdatePropertyDto with @IsUrl() validation - Update Property GraphQL ObjectType with new nullable fields --- .../migration.sql | 3 +++ prisma/schema.prisma | 8 ++++--- src/properties/dto/property.dto.ts | 22 ++++++++++++++++++- src/properties/models/property.model.ts | 6 +++++ 4 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 prisma/migrations/20260527000000_add_virtual_tour_fields/migration.sql diff --git a/prisma/migrations/20260527000000_add_virtual_tour_fields/migration.sql b/prisma/migrations/20260527000000_add_virtual_tour_fields/migration.sql new file mode 100644 index 00000000..79024dfd --- /dev/null +++ b/prisma/migrations/20260527000000_add_virtual_tour_fields/migration.sql @@ -0,0 +1,3 @@ +-- AlterTable +ALTER TABLE "properties" ADD COLUMN "virtual_tour_url" TEXT; +ALTER TABLE "properties" ADD COLUMN "video_url" TEXT; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 5e0c6450..379b98ac 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -397,9 +397,11 @@ model Property { ownerId String @map("owner_id") latitude Float? longitude Float? - features String[] // Array of features (pool, garage, etc.) - createdAt DateTime @default(now()) @map("created_at") - updatedAt DateTime @updatedAt @map("updated_at") + features String[] // Array of features (pool, garage, etc.) + virtualTourUrl String? @map("virtual_tour_url") + videoUrl String? @map("video_url") + createdAt DateTime @default(now()) @map("created_at") + updatedAt DateTime @updatedAt @map("updated_at") // Relations owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade) diff --git a/src/properties/dto/property.dto.ts b/src/properties/dto/property.dto.ts index 9289548b..8f42fb8c 100644 --- a/src/properties/dto/property.dto.ts +++ b/src/properties/dto/property.dto.ts @@ -1,4 +1,4 @@ -import { IsString, IsNumber, IsOptional, IsArray, IsIn } from 'class-validator'; +import { IsString, IsNumber, IsOptional, IsArray, IsIn, IsUrl } from 'class-validator'; import { InputType, Field, Float } from '@nestjs/graphql'; export const PROPERTY_STATUS_ENUM = [ @@ -91,6 +91,16 @@ export class CreatePropertyDto { @IsOptional() @IsNumber() longitude?: number; + + @Field({ nullable: true }) + @IsOptional() + @IsUrl() + virtualTourUrl?: string; + + @Field({ nullable: true }) + @IsOptional() + @IsUrl() + videoUrl?: string; } import { PropertyStatus } from '../../common/common.types'; @@ -182,4 +192,14 @@ export class UpdatePropertyDto { @IsOptional() @IsNumber() longitude?: number; + + @Field({ nullable: true }) + @IsOptional() + @IsUrl() + virtualTourUrl?: string; + + @Field({ nullable: true }) + @IsOptional() + @IsUrl() + videoUrl?: string; } diff --git a/src/properties/models/property.model.ts b/src/properties/models/property.model.ts index 581c18fc..f607833e 100644 --- a/src/properties/models/property.model.ts +++ b/src/properties/models/property.model.ts @@ -67,6 +67,12 @@ export class Property { @Field(() => [String]) features: string[]; + @Field({ nullable: true }) + virtualTourUrl?: string; + + @Field({ nullable: true }) + videoUrl?: string; + @Field() createdAt: Date;