feat: add screening service

This commit is contained in:
Sergey Krylov 2026-04-26 07:55:51 +03:00
parent 336b152fdf
commit 157f501ba8
9 changed files with 125 additions and 11 deletions

View File

@ -8,6 +8,7 @@ import { CategoryModule } from '../modules/category/category.module'
import { HallModule } from '../modules/hall/hall.module' import { HallModule } from '../modules/hall/hall.module'
import { MediaModule } from '../modules/media/media.module' import { MediaModule } from '../modules/media/media.module'
import { MovieModule } from '../modules/movie/movie.module' import { MovieModule } from '../modules/movie/movie.module'
import { ScreeningModule } from '../modules/screening/screening.module'
import { SeatModule } from '../modules/seat/seat.module' import { SeatModule } from '../modules/seat/seat.module'
import { TheaterModule } from '../modules/theater/theater.module' import { TheaterModule } from '../modules/theater/theater.module'
import { UsersModule } from '../modules/users/users.module' import { UsersModule } from '../modules/users/users.module'
@ -37,6 +38,7 @@ import { getPassportConfig } from './config'
TheaterModule, TheaterModule,
HallModule, HallModule,
SeatModule, SeatModule,
ScreeningModule,
PassportModule.registerAsync({ PassportModule.registerAsync({
useFactory: getPassportConfig, useFactory: getPassportConfig,
inject: [ConfigService] inject: [ConfigService]

View File

@ -0,0 +1 @@
export * from './rq'

View File

@ -0,0 +1,19 @@
import { IsDateString, IsNotEmpty, IsString } from 'class-validator'
export class CreateScreeningRequestDto {
@IsNotEmpty()
@IsString()
public movieId: string
@IsNotEmpty()
@IsString()
public hallId: string
@IsNotEmpty()
@IsDateString()
public startAt: string
@IsNotEmpty()
@IsDateString()
public endAt: string
}

View File

@ -0,0 +1,18 @@
import { ApiPropertyOptional } from '@nestjs/swagger'
import { IsISO8601, IsOptional, IsString } from 'class-validator'
export class GetScreeningsRequestDto {
@ApiPropertyOptional({
example: '81lI1385'
})
@IsOptional()
@IsString()
public theaterId?: string
@ApiPropertyOptional({
example: '2018-02-01'
})
@IsOptional()
@IsISO8601()
public date?: string
}

View File

@ -0,0 +1,2 @@
export * from './create-screening.request.dto'
export * from './get-screenings.request.dto'

View File

@ -0,0 +1,47 @@
import {
Body,
Controller,
Get,
HttpCode,
HttpStatus,
Param,
Post,
Query
} from '@nestjs/common'
import { CreateScreeningRequestDto, GetScreeningsRequestDto } from './dto'
import { ScreeningClientGrpc } from './screening.grpc'
@Controller('screenings')
export class ScreeningController {
constructor(private readonly client: ScreeningClientGrpc) {}
@Post()
@HttpCode(HttpStatus.CREATED)
public create(@Body() dto: CreateScreeningRequestDto) {
return this.client.call('createScreening', dto)
}
@Get()
@HttpCode(HttpStatus.OK)
public async getAll(@Query() dto: GetScreeningsRequestDto) {
const { screenings } = await this.client.call('getScreenings', dto)
return screenings
}
@Get(':id')
@HttpCode(HttpStatus.OK)
public async getById(@Param('id') id: string) {
const { screening } = await this.client.call('getScreening', { id })
return screening
}
@Get('movie/:id')
@HttpCode(HttpStatus.OK)
public async getAllByMovieId(@Param('id') movieId: string) {
const { screenings } = await this.client.call('getScreeningsByMovie', {
movieId
})
return screenings
}
}

View File

@ -0,0 +1,13 @@
import { Injectable } from '@nestjs/common'
import type { ClientGrpc } from '@nestjs/microservices'
import { InjectGrpc } from '@teacinema/common'
import { ScreeningServiceClient } from '@teacinema/contracts/gen/ts/screening'
import { AbstractGrpcClient } from '../../shared/grpc/abstract-grpc.client'
@Injectable()
export class ScreeningClientGrpc extends AbstractGrpcClient<ScreeningServiceClient> {
constructor(@InjectGrpc('SCREENING_PACKAGE') client: ClientGrpc) {
super(client, 'ScreeningService')
}
}

View File

@ -0,0 +1,12 @@
import { Module } from '@nestjs/common'
import { GrpcModule } from '@teacinema/common'
import { ScreeningController } from './screening.controller'
import { ScreeningClientGrpc } from './screening.grpc'
@Module({
imports: [GrpcModule.register(['SCREENING_PACKAGE'])],
controllers: [ScreeningController],
providers: [ScreeningClientGrpc]
})
export class ScreeningModule {}

View File

@ -334,9 +334,9 @@
integrity sha512-DDaRehssg1aNrH4+2hnj1B7vnUGEjU6OIlyRdkMd0aUdIUvKXrJfXsy8LVtXAy7DRvYVluWbMspsRhz2lcW0mQ== integrity sha512-DDaRehssg1aNrH4+2hnj1B7vnUGEjU6OIlyRdkMd0aUdIUvKXrJfXsy8LVtXAy7DRvYVluWbMspsRhz2lcW0mQ==
"@bufbuild/protobuf@^2.0.0", "@bufbuild/protobuf@^2.10.2": "@bufbuild/protobuf@^2.0.0", "@bufbuild/protobuf@^2.10.2":
version "2.11.0" version "2.12.0"
resolved "https://registry.yarnpkg.com/@bufbuild/protobuf/-/protobuf-2.11.0.tgz#3ec3985c9074b23aea337957225fe15a0e845f8e" resolved "https://registry.yarnpkg.com/@bufbuild/protobuf/-/protobuf-2.12.0.tgz#53225636a8fcebb2bd94998ad9d42f99f96add4d"
integrity sha512-sBXGT13cpmPR5BMgHE6UEEfEaShh5Ror6rfN3yEK5si7QVrtZg8LEPQb0VVhiLRUslD2yLnXtnRzG035J/mZXQ== integrity sha512-B/XlCaFIP8LOwzo+bz5uFzATYokcwCKQcghqnlfwSmM5eX/qTkvDBnDPs+gXtX/RyjxJ4DRikECcPJbyALA8FA==
"@colors/colors@1.5.0": "@colors/colors@1.5.0":
version "1.5.0" version "1.5.0"
@ -1997,19 +1997,19 @@
"@sinonjs/commons" "^3.0.1" "@sinonjs/commons" "^3.0.1"
"@teacinema/common@^1.0.0": "@teacinema/common@^1.0.0":
version "1.5.0" version "1.6.1"
resolved "https://git.ksv741.keenetic.pro/api/packages/teacinema/npm/%40teacinema%2Fcommon/-/1.5.0/common-1.5.0.tgz#236c1aba248b31773297bf17aad9053116483e93" resolved "https://git.ksv741.keenetic.pro/api/packages/teacinema/npm/%40teacinema%2Fcommon/-/1.6.1/common-1.6.1.tgz#403232158953c986cbd8a7f351d844ee7d3ab6e0"
integrity sha512-GqGx8jFaMP6ADcZP18ariJtAHbJqLhT9Up80SLwU1fInKUthQb5MzLrTc4ce8jAxbczLVMGmikphIQNYNpvCGg== integrity sha512-J0dusJwpb9JgSh6oIoa29WgCy36zZuW9VvQ6gOvPUF2PoE6c/Ktx/RRSn+kCkE7zXEZzxwoVaQh7t+0nSeX4Dg==
dependencies: dependencies:
"@nestjs/common" "^11.1.16" "@nestjs/common" "^11.1.16"
"@nestjs/config" "^4.0.3" "@nestjs/config" "^4.0.3"
"@nestjs/microservices" "^11.1.16" "@nestjs/microservices" "^11.1.16"
"@teacinema/contracts" "^1.1.3" "@teacinema/contracts" "^1.5.0"
"@teacinema/contracts@^1.0.0", "@teacinema/contracts@^1.1.3": "@teacinema/contracts@^1.0.0", "@teacinema/contracts@^1.5.0":
version "1.4.1" version "1.5.0"
resolved "https://git.ksv741.keenetic.pro/api/packages/teacinema/npm/%40teacinema%2Fcontracts/-/1.4.1/contracts-1.4.1.tgz#20feccf1784a41ad6b4b0ebfcc035f991a7473c9" resolved "https://git.ksv741.keenetic.pro/api/packages/teacinema/npm/%40teacinema%2Fcontracts/-/1.5.0/contracts-1.5.0.tgz#d816ab6b847794328d58df1c1d08b4efeceb99bb"
integrity sha512-CcYU/cUQfBw+KJp8d14RONIZahkbUAYxiLqudHhx/kpEPuoQDO8VMJy6SbUqBM1HKZ1VTtyQWfxm/79PBPMe0g== integrity sha512-pLgt117PXVt7XZOko4A2Et97aRZs0QdylZAonWyt6S2U1rmWfn7CKPdPJw77LsA+GaFuE/4ntZbXxTzIFdJYVA==
dependencies: dependencies:
"@nestjs/microservices" "^11.1.12" "@nestjs/microservices" "^11.1.12"
protoc "33.4.0" protoc "33.4.0"