feat: users filter

This commit is contained in:
louis 2024-03-28 14:35:00 +08:00
parent 8800008d27
commit fdc6af9e20
3 changed files with 17 additions and 3 deletions

View File

@ -71,7 +71,7 @@ docker rmi huaxin-admin-server:stable
```bash
pnpm docker:logs
# or
docker compose --env-file .env --env-file .env.production logs -f
docker-compose --env-file .env --env-file .env.production logs -f
```

View File

@ -95,4 +95,9 @@ export class UserQueryDto extends IntersectionType(PagerDto<UserDto>, PartialTyp
@IsInt()
@IsOptional()
status?: number;
@ApiProperty({ description: '关键字' })
@IsString()
@IsOptional()
keyword?: string;
}

View File

@ -249,7 +249,8 @@ export class UserService {
nickname,
deptId,
email,
status
status,
keyword
}: UserQueryDto): Promise<Pagination<UserEntity>> {
const queryBuilder = this.userRepository
.createQueryBuilder('user')
@ -264,7 +265,15 @@ export class UserService {
});
if (deptId) queryBuilder.andWhere('dept.id = :deptId', { deptId });
if (keyword) {
//关键字模糊查询product的name,productNumber,productSpecification
queryBuilder.andWhere(
'(user.name like :keyword or dept.name like :keyword)',
{
keyword: `%${keyword}%`
}
);
}
return paginate<UserEntity>(queryBuilder, {
page,
pageSize