允许userService进行or查询

This commit is contained in:
2025-05-07 00:01:32 +08:00
parent 1d434f03dd
commit 7985b141c0

View File

@@ -3,6 +3,8 @@ import { InjectRepository } from '@nestjs/typeorm';
import { User } from './user.entity'; import { User } from './user.entity';
import { Repository } from 'typeorm'; import { Repository } from 'typeorm';
type UserFindOptions = Partial<Pick<User, 'userId' | 'username' | 'phone' | 'email'>>;
@Injectable() @Injectable()
export class UserService { export class UserService {
constructor( constructor(
@@ -10,7 +12,7 @@ export class UserService {
private readonly userRepository: Repository<User>, private readonly userRepository: Repository<User>,
) { } ) { }
async findOne(options: Partial<Pick<User, 'userId' | 'username' | 'phone' | 'email'>>): Promise<User | null> { async findOne(options: UserFindOptions | UserFindOptions[]): Promise<User | null> {
if (Object.keys(options).length === 0) { if (Object.keys(options).length === 0) {
return null; return null;
} }