Add AdminId decorator for extracting adminId from requests; refactor AdminController to utilize new decorator for fetching admin details and restaurant-specific admins; update AdminService to handle admin creation and retrieval by restaurant; remove unused role and permission entities for cleaner architecture.
This commit is contained in:
@@ -3,6 +3,7 @@ import { Seeder } from '@mikro-orm/seeder';
|
||||
import { Category } from '../modules/foods/entities/category.entity';
|
||||
import { Food } from '../modules/foods/entities/food.entity';
|
||||
import { Admin } from '../modules/admin/entities/admin.entity';
|
||||
import { AdminRole } from '../modules/admin/entities/adminRole.entity';
|
||||
import { Permission as PermissionEntity } from '../modules/roles/entities/permission.entity';
|
||||
import { Role } from '../modules/roles/entities/role.entity';
|
||||
import { Restaurant } from '../modules/restaurants/entities/restaurant.entity';
|
||||
@@ -421,10 +422,17 @@ export class DatabaseSeeder extends Seeder {
|
||||
phone: '09362532122',
|
||||
firstName: 'مرتضی',
|
||||
lastName: 'مرتضایی',
|
||||
});
|
||||
em.persist(admin);
|
||||
|
||||
// Create AdminRole linking admin to role and restaurant
|
||||
const adminRole = em.create(AdminRole, {
|
||||
admin,
|
||||
role: restaurantRole,
|
||||
restaurant: zhivan,
|
||||
});
|
||||
em.persist(admin);
|
||||
em.persist(adminRole);
|
||||
admin.roles.add(adminRole);
|
||||
}
|
||||
|
||||
const adminHamid = await em.findOne(Admin, { phone: '09185290775' });
|
||||
@@ -433,10 +441,17 @@ export class DatabaseSeeder extends Seeder {
|
||||
phone: '09185290775',
|
||||
firstName: 'حمید',
|
||||
lastName: 'زرگامی',
|
||||
});
|
||||
em.persist(admin);
|
||||
|
||||
// Create AdminRole linking admin to role and restaurant
|
||||
const adminRole = em.create(AdminRole, {
|
||||
admin,
|
||||
role: accountant,
|
||||
restaurant: boote,
|
||||
});
|
||||
em.persist(admin);
|
||||
em.persist(adminRole);
|
||||
admin.roles.add(adminRole);
|
||||
}
|
||||
|
||||
const adminMehrdad = await em.findOne(Admin, { phone: '0912928395' });
|
||||
@@ -445,10 +460,17 @@ export class DatabaseSeeder extends Seeder {
|
||||
phone: '0912928395',
|
||||
firstName: 'مهرداد',
|
||||
lastName: 'مظفری',
|
||||
});
|
||||
em.persist(admin);
|
||||
|
||||
// Create AdminRole linking admin to role (no restaurant for superAdmin)
|
||||
const adminRole = em.create(AdminRole, {
|
||||
admin,
|
||||
role: superAdmin,
|
||||
restaurant: null, // SuperAdmin doesn't belong to a specific restaurant
|
||||
});
|
||||
em.persist(admin);
|
||||
em.persist(adminRole);
|
||||
admin.roles.add(adminRole);
|
||||
}
|
||||
|
||||
await em.flush();
|
||||
|
||||
Reference in New Issue
Block a user