Skip to content

Commit

Permalink
feat: add networks to movie
Browse files Browse the repository at this point in the history
  • Loading branch information
mdwitr0 committed Oct 25, 2023
1 parent 935ec87 commit 240792d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/movie/dto/v1.4/movie.dto.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ApiNullableProperty } from 'src/common/decorators/api-nullable-property.decorator';
import { MovieDtoV1_3 } from '../v1.3/movie.dto';
import { LinkedMovie, Rating } from '../../schemas/movie.schema';
import { ApiProperty } from '@nestjs/swagger';
import { LinkedMovie, Logo, Rating } from '../../schemas/movie.schema';
import { ApiProperty, OmitType } from '@nestjs/swagger';

export class LinkedMovieV1_4 extends LinkedMovie {
@ApiProperty({ type: () => Rating })
Expand All @@ -11,9 +11,21 @@ export class LinkedMovieV1_4 extends LinkedMovie {
year: number;
}

export class MovieDtoV1_4 extends MovieDtoV1_3 {
export class NetworkItemV1_4 {
@ApiProperty({ type: () => String, example: 'Netflix' })
name: string;

@ApiProperty({ type: () => Logo })
logo: Logo;
}
export class NetworksV1_4 {
@ApiProperty({ type: () => NetworkItemV1_4, isArray: true })
items: NetworkItemV1_4[];
}

export class MovieDtoV1_4 extends OmitType(MovieDtoV1_3, ['productionCompanies']) {
@ApiNullableProperty({
example: true,
example: ['250 лучших сериалов'],
description: 'Список коллекций, в которых находится тайтл.',
})
lists: string[];
Expand All @@ -23,4 +35,7 @@ export class MovieDtoV1_4 extends MovieDtoV1_3 {

@ApiProperty({ type: () => LinkedMovieV1_4, isArray: true })
sequelsAndPrequels: LinkedMovieV1_4[];

@ApiProperty({ type: () => NetworksV1_4, isArray: true })
networks: NetworksV1_4;
}
15 changes: 15 additions & 0 deletions src/movie/schemas/movie.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,18 @@ export class Audience {
country: string;
}

export class NetworkItem {
@Prop()
name: string;

@Prop({ type: () => Logo })
logo: Logo;
}
export class Networks {
@Prop({ type: () => [NetworkItem] })
items: NetworkItem[];
}

// INFO:Movie model
export type MovieDocument = HydratedDocument<Movie>;
@Schema({
Expand Down Expand Up @@ -534,6 +546,9 @@ export class Movie {

@Prop()
lists: string[];

@Prop({ type: () => Networks })
networks: Networks;
}

export const MovieSchema = SchemaFactory.createForClass(Movie);

0 comments on commit 240792d

Please sign in to comment.