nestjs rewrite

This commit is contained in:
popovspiridon99
2025-08-01 11:33:40 +09:00
parent 145827ab6d
commit 37bfa912a0
58 changed files with 17130 additions and 0 deletions

View File

@ -0,0 +1,40 @@
import { Injectable } from '@nestjs/common';
import { InjectDataSource } from '@nestjs/typeorm';
import { DataSource } from 'typeorm';
@Injectable()
export class EmsService {
constructor(
@InjectDataSource('emsConnection')
private dataSource: DataSource
) { }
async getTypeRoles(): Promise<any[]> {
const result = await this.dataSource.query(`
SELECT * FROM "TypeRoles";
`)
return result
}
async getImages(city_id?: number, offset?: number, limit?: number): Promise<any[]> {
const result = await this.dataSource.query(`
SELECT * FROM "images"
${city_id ? `WHERE city_id = ${city_id}` : ''}
ORDER BY city_id
OFFSET ${offset || 0} ROWS
FETCH NEXT ${limit || 10} ROWS ONLY;
`)
return result
}
async getFigures(year: number, city_id: number, offset?: number, limit?: number): Promise<any[]> {
const result = await this.dataSource.query(`
SELECT * FROM figures f
JOIN vObjects o ON f.object_id = o.object_id WHERE o.id_city = ${city_id} AND f.year = ${year}
ORDER BY f.year
OFFSET ${Number(offset) || 0} ROWS
FETCH NEXT ${Number(limit) || 10} ROWS ONLY;
`)
return result
}
}