mirror of
https://gitlab.com/mobicoop/v3/service/ad.git
synced 2026-01-03 08:22:41 +00:00
adding transformation pipes and update prisma schema
This commit is contained in:
@@ -41,6 +41,8 @@ export class AdController {
|
||||
|
||||
@GrpcMethod('AdsService', 'Create')
|
||||
async createAd(data: CreateAdRequest): Promise<AdPresenter> {
|
||||
console.log('controler');
|
||||
console.log(data);
|
||||
try {
|
||||
const ad = await this._commandBus.execute(new CreateAdCommand(data));
|
||||
return this._mapper.map(ad, Ad, AdPresenter);
|
||||
|
||||
@@ -6,12 +6,11 @@ import {
|
||||
IsDate,
|
||||
IsInt,
|
||||
ValidateIf,
|
||||
ArrayMinSize,
|
||||
IsArray,
|
||||
IsEnum,
|
||||
} from 'class-validator';
|
||||
import { Frequency } from '../entities/frequency.enum';
|
||||
import { Address } from '../entities/address';
|
||||
import { Transform, Type } from 'class-transformer';
|
||||
|
||||
export class CreateAdRequest {
|
||||
@IsString()
|
||||
@@ -35,48 +34,57 @@ export class CreateAdRequest {
|
||||
@AutoMap()
|
||||
passenger?: boolean;
|
||||
|
||||
@Transform(({ value }) => Frequency[value])
|
||||
@AutoMap()
|
||||
@IsEnum(Frequency)
|
||||
frequency: Frequency;
|
||||
|
||||
@Type(() => Date)
|
||||
@IsDate()
|
||||
@AutoMap()
|
||||
fromDate: Date;
|
||||
|
||||
@Type(() => Date)
|
||||
@IsDate()
|
||||
@AutoMap()
|
||||
toDate: Date;
|
||||
|
||||
@Type(() => Date)
|
||||
@IsDate()
|
||||
@IsOptional()
|
||||
@AutoMap()
|
||||
monTime?: Date;
|
||||
|
||||
@Type(() => Date)
|
||||
@IsDate()
|
||||
@IsOptional()
|
||||
@AutoMap()
|
||||
tueTime?: Date;
|
||||
|
||||
@Type(() => Date)
|
||||
@IsDate()
|
||||
@IsOptional()
|
||||
@AutoMap()
|
||||
wedTime?: Date;
|
||||
|
||||
@Type(() => Date)
|
||||
@IsDate()
|
||||
@IsOptional()
|
||||
@AutoMap()
|
||||
thuTime?: Date;
|
||||
|
||||
@Type(() => Date)
|
||||
@IsDate()
|
||||
@IsOptional()
|
||||
@AutoMap()
|
||||
friTime?: Date;
|
||||
|
||||
@Type(() => Date)
|
||||
@IsDate()
|
||||
@IsOptional()
|
||||
@AutoMap()
|
||||
satTime?: Date;
|
||||
|
||||
@Type(() => Date)
|
||||
@IsDate()
|
||||
@IsOptional()
|
||||
@AutoMap()
|
||||
@@ -128,12 +136,12 @@ export class CreateAdRequest {
|
||||
@IsInt()
|
||||
@AutoMap()
|
||||
seatsPassenger?: number;
|
||||
|
||||
@Type(() => Date)
|
||||
@IsDate()
|
||||
@IsOptional()
|
||||
@AutoMap()
|
||||
createdAt?: Date;
|
||||
|
||||
@Type(() => Date)
|
||||
@IsDate()
|
||||
@IsOptional()
|
||||
@AutoMap()
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
MinLength,
|
||||
ValidateIf,
|
||||
} from 'class-validator';
|
||||
import { Frequency } from './frequency.enum';
|
||||
import { Address } from '../entities/address';
|
||||
|
||||
export class Ad {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export enum Frequency {
|
||||
PUNCTUAL = 1,
|
||||
RECURRENT = 2,
|
||||
PUNCTUAL,
|
||||
RECURRENT,
|
||||
}
|
||||
|
||||
@@ -88,6 +88,7 @@ export abstract class PrismaRepository<T> implements IRepository<T> {
|
||||
|
||||
return res;
|
||||
} catch (e) {
|
||||
console.log('repository');
|
||||
console.log(e);
|
||||
if (e instanceof Prisma.PrismaClientKnownRequestError) {
|
||||
throw new DatabaseException(
|
||||
|
||||
Reference in New Issue
Block a user