From 8692c03d0d9f3d766be4af7c8ca2aadb19b22203 Mon Sep 17 00:00:00 2001 From: AdonaiJehosua Date: Sat, 14 Sep 2024 12:38:36 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D1=82=20=D1=82=D0=B8=D0=BF=D1=8B=20=D0=B2=20=D0=BC=D0=BE=D0=B4?= =?UTF-8?q?=D0=B5=D0=BB=D0=B8=20=D0=BF=D1=80=D0=B5=D0=B4=D0=BB=D0=BE=D0=B6?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/shared/modules/offer/offer.entity.ts | 51 ++++++++++++++++-------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/src/shared/modules/offer/offer.entity.ts b/src/shared/modules/offer/offer.entity.ts index b63491d..97b1e3e 100644 --- a/src/shared/modules/offer/offer.entity.ts +++ b/src/shared/modules/offer/offer.entity.ts @@ -1,7 +1,26 @@ -import {defaultClasses, getModelForClass, modelOptions, prop, Ref, Severity} from '@typegoose/typegoose'; +import {defaultClasses, getModelForClass, modelOptions, prop, Ref} from '@typegoose/typegoose'; import {City, Location, OfferGood} from '../../types/index.js'; import {UserEntity} from '../user/index.js'; +class LocationGoose { + @prop({type: Number}) + public latitude: number; + + @prop({type: Number}) + public longitude: number; + + @prop({type: Number}) + public zoom: number; +} + +class CityGoose { + @prop({type: String}) + public name: string; + + @prop({type: LocationGoose}) + public location: LocationGoose; +} + // eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging export interface OfferEntity extends defaultClasses.Base { } @@ -15,49 +34,49 @@ export interface OfferEntity extends defaultClasses.Base { // eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging export class OfferEntity extends defaultClasses.TimeStamps { - @prop({required: true, type: () => String}) + @prop({required: true, type: String}) public title: string; - @prop({required: true, type: () => String}) + @prop({required: true, type: String}) public type: string; - @prop({required: true, type: () => Number}) + @prop({required: true, type: Number}) public price: number; - @prop({required: true, allowMixed: Severity.ALLOW, type: () => Object}) + @prop({required: true, type: CityGoose}) public city: City; - @prop({required: true, allowMixed: Severity.ALLOW, type: () => Object}) + @prop({required: true, type: LocationGoose}) public location: Location; - @prop({required: true, type: () => Boolean}) + @prop({required: true, type: Boolean}) public isFavorite: boolean; - @prop({required: true, type: () => Boolean}) + @prop({required: true, type: Boolean}) public isPremium: boolean; - @prop({required: true, type: () => Number}) + @prop({required: true, type: Number}) public rating: number; - @prop({required: true, type: () => String}) + @prop({required: true, type: String}) public description: string; - @prop({required: true, type: () => Array}) + @prop({required: true, type: Array}) public images: string[]; - @prop({required: true, type: () => String}) + @prop({required: true, type: String}) public previewImage: string; - @prop({required: true, type: () => Array}) + @prop({type: Array}) public goods: OfferGood[]; - @prop({required: true, ref: () => UserEntity, type: () => String}) + @prop({required: true, ref: () => UserEntity, type: String}) public hostId: Ref; - @prop({required: true, type: () => Number}) + @prop({required: true, type: Number}) public bedrooms: number; - @prop({required: true, type: () => Number}) + @prop({required: true, type: Number}) public maxAdults: number; }