user module

This commit is contained in:
2026-01-13 19:59:06 +03:30
parent 6522acff5f
commit d630cb844a
62 changed files with 1137 additions and 3040 deletions
+16 -16
View File
@@ -27,19 +27,19 @@ export class AdminService {
return this.adminRepository.findOne({ phone: normalizedPhone });
}
async findById(adminId: string, restId: string): Promise<Admin | null> {
async findById(adminId: string, : string): Promise<Admin | null> {
const admin = await this.adminRepository.findOne(
{ id: adminId, roles: { restaurant: { id: restId } } },
{ id: adminId, roles: { restaurant: { id: } } },
{ populate: ['roles', 'roles.role'] },
);
return admin;
}
async findAllByRestaurantId(restId: string): Promise<Admin[]> {
return this.adminRepository.find({ roles: { restaurant: { id: restId } } }, { populate: ['roles', 'roles.role'] });
async findAllBy(: string): Promise<Admin[]> {
return this.adminRepository.find({ roles: { restaurant: { id: } } }, { populate: ['roles', 'roles.role'] });
}
async createAdminForMyRestaurant(restId: string, dto: CreateMyRestaurantAdminDto) {
async createAdminForMyRestaurant(: string, dto: CreateMyRestaurantAdminDto) {
const { phone, firstName, lastName, roleId } = dto;
const normalizedPhone = normalizePhone(phone);
let admin: Admin | null = null;
@@ -57,7 +57,7 @@ export class AdminService {
const role = await this.em.findOne(Role, { id: roleId, isSystem: false });
if (!role) throw new NotFoundException('Role not found');
const restaurant = await this.em.findOne(Restaurant, { id: restId });
const restaurant = await this.em.findOne(Restaurant, { id: });
if (!restaurant) throw new NotFoundException('Restaurant not found');
let adminRole = await this.adminRoleRepository.findOne({
@@ -79,7 +79,7 @@ export class AdminService {
return admin;
}
async createAdminForRestaurantBySuperAdmin(restId: string, dto: CreateMyRestaurantAdminDto) {
async createAdminForRestaurantBySuperAdmin(: string, dto: CreateMyRestaurantAdminDto) {
const { phone, firstName, lastName, roleId } = dto;
const normalizedPhone = normalizePhone(phone);
let admin: Admin | null = null;
@@ -97,7 +97,7 @@ export class AdminService {
const role = await this.em.findOne(Role, { id: roleId });
if (!role) throw new NotFoundException('Role* not found' + roleId);
const restaurant = await this.em.findOne(Restaurant, { id: restId });
const restaurant = await this.em.findOne(Restaurant, { id: });
if (!restaurant) throw new NotFoundException('Restaurant not found');
let adminRole = await this.adminRoleRepository.findOne({
@@ -119,16 +119,16 @@ export class AdminService {
return admin;
}
async getAdminsForRestaurantBySuperAdmin(restId: string): Promise<Admin[]> {
const restaurant = await this.em.findOne(Restaurant, { id: restId });
async getAdminsForRestaurantBySuperAdmin(: string): Promise<Admin[]> {
const restaurant = await this.em.findOne(Restaurant, { id: });
if (!restaurant) throw new NotFoundException('Restaurant not found');
return this.adminRepository.find({ roles: { restaurant: restaurant } }, { populate: ['roles', 'roles.role'] });
}
async update(adminId: string, restId: string, dto: UpdateAdminDto): Promise<Admin> {
async update(adminId: string, : string, dto: UpdateAdminDto): Promise<Admin> {
const admin = await this.adminRepository.findOne(
{ id: adminId, roles: { restaurant: { id: restId } } },
{ id: adminId, roles: { restaurant: { id: } } },
{ populate: ['roles', 'roles.role', 'roles.restaurant'] },
);
@@ -164,14 +164,14 @@ export class AdminService {
// Find existing AdminRole for this admin and restaurant
const existingAdminRole = await this.em.findOne(AdminRole, {
admin: { id: adminId },
restaurant: { id: restId },
restaurant: { id: },
});
if (existingAdminRole) {
// Update existing role
existingAdminRole.role = role;
} else {
const restaurant = await this.em.findOne(Restaurant, { id: restId });
const restaurant = await this.em.findOne(Restaurant, { id: });
if (!restaurant) throw new NotFoundException('Restaurant not found');
// Create new AdminRole
const newAdminRole = this.em.create(AdminRole, {
@@ -187,8 +187,8 @@ export class AdminService {
return admin;
}
async remove(adminId: string, restId: string): Promise<void> {
const adminRole = await this.adminRoleRepository.findOne({ admin: { id: adminId }, restaurant: { id: restId } });
async remove(adminId: string, : string): Promise<void> {
const adminRole = await this.adminRoleRepository.findOne({ admin: { id: adminId }, restaurant: { id: } });
if (!adminRole) {
throw new NotFoundException('Admin role not found');
}