mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-02 23:13:40 +00:00
Enhance DTOs and services to support sequence and operational status for coaches and stations
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { IsString, IsNumber, IsOptional } from 'class-validator';
|
||||
import { IsString, IsNumber, IsOptional, IsInt, IsBoolean } from 'class-validator';
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
|
||||
export class CreateStationDto {
|
||||
@@ -6,6 +6,9 @@ export class CreateStationDto {
|
||||
@ApiProperty({ example: 'Addis Ababa' }) @IsString() name: string;
|
||||
@ApiProperty({ example: 'Addis Ababa' }) @IsString() city: string;
|
||||
@ApiPropertyOptional() @IsOptional() @IsString() timezone?: string;
|
||||
@ApiPropertyOptional() @IsOptional() @IsString() countryCode?: string;
|
||||
@ApiProperty({ example: 9.0054 }) @IsNumber() lat: number;
|
||||
@ApiProperty({ example: 38.7636 }) @IsNumber() lng: number;
|
||||
@ApiPropertyOptional({ example: 1 }) @IsOptional() @IsInt() sequence?: number;
|
||||
@ApiPropertyOptional({ example: true }) @IsOptional() @IsBoolean() isOperational?: boolean;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Injectable, NotFoundException, Inject, Optional } from '@nestjs/common';
|
||||
import { Injectable, NotFoundException, Inject, Optional, BadRequestException } from '@nestjs/common';
|
||||
import { REQUEST } from '@nestjs/core';
|
||||
import { PrismaService } from '../../common/prisma.service';
|
||||
import { AuditService } from '../../common/audit.service';
|
||||
@@ -65,9 +65,15 @@ export class StationsService {
|
||||
|
||||
async update(id: string, dto: Partial<CreateStationDto>) {
|
||||
const oldStation = await this.findOne(id);
|
||||
const { code, name, city, timezone, lat, lng } = dto;
|
||||
const data: any = { code, name, city, timezone, lat, lng };
|
||||
if ('countryCode' in dto) data.countryCode = (dto as any).countryCode;
|
||||
if ('sequence' in dto) data.sequence = (dto as any).sequence;
|
||||
if ('isOperational' in dto) data.isOperational = (dto as any).isOperational;
|
||||
|
||||
const updatedStation = await this.prisma.station.update({
|
||||
where: { id },
|
||||
data: dto,
|
||||
data,
|
||||
});
|
||||
|
||||
await this.auditService.log({
|
||||
|
||||
Reference in New Issue
Block a user