Skip to content

Commit

Permalink
qs in station find
Browse files Browse the repository at this point in the history
  • Loading branch information
endimerkuri committed Jun 2, 2024
1 parent 76ebf01 commit 154934e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/stations/dto/station-query.dto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsEnum, IsOptional } from 'class-validator';
import { IsEnum, IsOptional, IsString } from 'class-validator';
import { PortType } from 'src/ports/port.entity';
import { StationStatus } from '../station.entity';
import { Transform } from 'class-transformer';
Expand All @@ -16,4 +16,9 @@ export class StationQueryDto {
@IsEnum(StationStatus)
@Transform(({ value }) => ('' + value).toLowerCase())
status: StationStatus;

@ApiProperty()
@IsOptional()
@IsString()
qs: string;
}
3 changes: 3 additions & 0 deletions src/stations/stations.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export class StationsService {
if (query.type) {
where.ports = { type: query.type };
}
if (query.qs) {
where.name = query.qs;
}
return this.stationRepository.find({
where,
relations: ['merchant', 'ports'],
Expand Down

0 comments on commit 154934e

Please sign in to comment.