Update codebase

This commit is contained in:
Hamza-Ayed
2026-07-16 16:01:28 +03:00
parent 951f6d80e1
commit 83f2d0854a
16 changed files with 343 additions and 48 deletions
@@ -0,0 +1,25 @@
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { User, UserRole } from './entities/user.entity';
@Injectable()
export class UsersService {
constructor(
@InjectRepository(User)
private readonly userRepository: Repository<User>,
) {}
async findByPhone(tenantId: string, phone: string): Promise<User | null> {
return this.userRepository.findOne({ where: { tenant_id: tenantId, phone } });
}
async findById(tenantId: string, id: string): Promise<User | null> {
return this.userRepository.findOne({ where: { tenant_id: tenantId, id } });
}
async create(tenantId: string, phone: string, role: string = 'rider'): Promise<User> {
const user = this.userRepository.create({ tenant_id: tenantId, phone, role: role as UserRole });
return this.userRepository.save(user);
}
}