Update codebase
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user