Files
tehran_taj/apps/api/src/modules/admin-cities/admin-cities.controller.ts
T
s.esmaeiliandClaude Opus 5.5 fbe4f38e06 feat(cities): cities are a tree again, as legacy's; old dashboard permissions merged (PERS-02, PERM-01)
Cities (owner: as legacy)
- City.parentId (self relation) replaces the flat `province` label; the
  migration turns each label into a parent row («استان …») first, so nothing
  is lost.
- Admin pickers are legacy's tree (CityTreeSelect): the top level, the
  country, is a heading. The city form and grid get «والد».
- Restored legacy _getP: a city without its own percent takes its
  ancestor's. Restored the omde-customer form's city → percent autofill.
- Import copies legacy parents; delete refuses a city with children; a
  parent loop is refused.

Permissions (owner approved the deletion)
- dashboard / dashboard.omde / dashboard.tak rows become dashboard.view,
  then are deleted.
- Import maps them the same way: legacy types 102, 104, 105, 108 and 135
  had lost the dashboard.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 16:31:12 +03:30

32 lines
1.0 KiB
TypeScript

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' } });
// 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,
})),
};
}
}