import { Injectable } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; import { Repository } from 'typeorm'; import { Tenant } from '../../database/entities/tenant.entity'; @Injectable() export class TenantsService { constructor( @InjectRepository(Tenant) private readonly repo: Repository, ) {} findAll(): Promise { return this.repo.find(); } findBySlug(slug: string): Promise { return this.repo.findOne({ where: { slug } }); } create(data: Partial): Promise { return this.repo.save(this.repo.create(data)); } /** * الإعداد الديناميكي الذي يجلبه تطبيق فلاتر عند الإقلاع (GET /tenant/config). * كل ما يمكن جعله ديناميكياً (نصوص، ميزات، ألوان، دفع) يأتي من هنا — راجع docs/06. */ async config(slug: string) { const t = await this.findBySlug(slug); if (!t) return null; return { slug: t.slug, name: t.name, countryPack: t.countryPack, plan: t.plan, branding: t.branding, features: t.features, }; } }