Ajusta endpoints
This commit is contained in:
@@ -7,7 +7,7 @@ import {
|
||||
IsUrl,
|
||||
MaxLength,
|
||||
} from 'class-validator';
|
||||
import { EVideoSituation } from '../../../generated/prisma';
|
||||
import { video_situation } from '../../../generated/prisma';
|
||||
|
||||
export class CreateVideoDto {
|
||||
@IsUrl()
|
||||
@@ -15,8 +15,8 @@ export class CreateVideoDto {
|
||||
url!: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsEnum(EVideoSituation)
|
||||
situation?: EVideoSituation;
|
||||
@IsEnum(video_situation)
|
||||
situation?: video_situation;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Type } from 'class-transformer';
|
||||
import { IsInt, IsOptional, Max, Min } from 'class-validator';
|
||||
import { IsIn, IsInt, IsOptional, IsString, Max, Min } from 'class-validator';
|
||||
|
||||
export class PaginatedQueryDto {
|
||||
@IsOptional()
|
||||
@@ -14,12 +14,19 @@ export class PaginatedQueryDto {
|
||||
@Min(1)
|
||||
@Max(100)
|
||||
perPage: number = 20;
|
||||
|
||||
@IsOptional()
|
||||
@Type(() => String)
|
||||
@IsString()
|
||||
@IsIn(['asc', 'desc'])
|
||||
direction: string = 'desc';
|
||||
}
|
||||
|
||||
export type PaginatedResponse<T> = {
|
||||
content: T[];
|
||||
pagination: {
|
||||
page: number;
|
||||
direction: string;
|
||||
perPage: number;
|
||||
total: number;
|
||||
totalPages: number;
|
||||
|
||||
@@ -1,12 +1,41 @@
|
||||
import { EVideoSituation } from 'generated/prisma';
|
||||
import { Expose, Transform, TransformFnParams } from 'class-transformer';
|
||||
import dayjs from 'dayjs';
|
||||
import { video_situation } from 'generated/prisma';
|
||||
|
||||
export interface VideoResponseDto {
|
||||
id: number;
|
||||
title: string | null;
|
||||
url: string;
|
||||
situation: EVideoSituation;
|
||||
clips_quantity: number;
|
||||
videoid: string;
|
||||
filename: string;
|
||||
datetime_download: Date | string;
|
||||
export class VideoResponseDto {
|
||||
@Expose()
|
||||
id!: number;
|
||||
|
||||
@Expose()
|
||||
title!: string | null;
|
||||
|
||||
@Expose()
|
||||
url!: string;
|
||||
|
||||
@Expose()
|
||||
situation!: video_situation;
|
||||
|
||||
@Expose()
|
||||
@Transform(({ value }: TransformFnParams) =>
|
||||
typeof value === 'number' ? value : 0,
|
||||
)
|
||||
clips_quantity!: number;
|
||||
|
||||
@Expose()
|
||||
@Transform(({ value }: TransformFnParams) =>
|
||||
typeof value === 'string' ? value : '',
|
||||
)
|
||||
videoid!: string;
|
||||
|
||||
@Expose()
|
||||
@Transform(({ value }: TransformFnParams) =>
|
||||
typeof value === 'string' ? value : '',
|
||||
)
|
||||
filename!: string;
|
||||
|
||||
@Expose()
|
||||
@Transform(({ value }: TransformFnParams) =>
|
||||
value ? dayjs(value as Date | string).format('DD/MM/YYYY HH:mm:ss') : '',
|
||||
)
|
||||
datetime_download!: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user