2026-09-13 21:02:25 +03:30
|
|
|
import { Controller, HttpCode, Post } from '@nestjs/common';
|
|
|
|
|
import { PrismaService } from '../../prisma/prisma.service';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Legacy `POST cities/list` — the city lookup the table filters use.
|
|
|
|
|
* Returns `{ rows }`, matching what the users store's setCities() reads.
|
|
|
|
|
*
|
|
|
|
|
* Deliberately NOT permission-gated: legacy called this from table models at
|
|
|
|
|
* module load, before any rid check, and it exposes nothing sensitive.
|
|
|
|
|
*/
|
|
|
|
|
@Controller('admin/cities')
|
|
|
|
|
export class AdminCitiesController {
|
|
|
|
|
constructor(private readonly prisma: PrismaService) {}
|
|
|
|
|
|
|
|
|
|
@Post('list')
|
|
|
|
|
@HttpCode(200)
|
|
|
|
|
async list() {
|
|
|
|
|
const cities = await this.prisma.city.findMany({ orderBy: { name: 'asc' } });
|
2026-10-08 16:29:51 +03:30
|
|
|
// legacy shape: the cities row — { id, title, parent, percent, percent_aux }.
|
|
|
|
|
// `parent` lets the admin pickers draw legacy's tree (PERS-02).
|
|
|
|
|
return {
|
|
|
|
|
rows: cities.map((c) => ({
|
|
|
|
|
id: c.id,
|
|
|
|
|
title: c.name,
|
|
|
|
|
parent: c.parentId,
|
|
|
|
|
percent: c.percent,
|
|
|
|
|
percent_aux: c.percentAux,
|
|
|
|
|
})),
|
|
|
|
|
};
|
2026-09-13 21:02:25 +03:30
|
|
|
}
|
|
|
|
|
}
|