feat: users filter
This commit is contained in:
parent
8800008d27
commit
fdc6af9e20
|
@ -71,7 +71,7 @@ docker rmi huaxin-admin-server:stable
|
||||||
```bash
|
```bash
|
||||||
pnpm docker:logs
|
pnpm docker:logs
|
||||||
# or
|
# or
|
||||||
docker compose --env-file .env --env-file .env.production logs -f
|
docker-compose --env-file .env --env-file .env.production logs -f
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -95,4 +95,9 @@ export class UserQueryDto extends IntersectionType(PagerDto<UserDto>, PartialTyp
|
||||||
@IsInt()
|
@IsInt()
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
status?: number;
|
status?: number;
|
||||||
|
|
||||||
|
@ApiProperty({ description: '关键字' })
|
||||||
|
@IsString()
|
||||||
|
@IsOptional()
|
||||||
|
keyword?: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -249,7 +249,8 @@ export class UserService {
|
||||||
nickname,
|
nickname,
|
||||||
deptId,
|
deptId,
|
||||||
email,
|
email,
|
||||||
status
|
status,
|
||||||
|
keyword
|
||||||
}: UserQueryDto): Promise<Pagination<UserEntity>> {
|
}: UserQueryDto): Promise<Pagination<UserEntity>> {
|
||||||
const queryBuilder = this.userRepository
|
const queryBuilder = this.userRepository
|
||||||
.createQueryBuilder('user')
|
.createQueryBuilder('user')
|
||||||
|
@ -264,7 +265,15 @@ export class UserService {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (deptId) queryBuilder.andWhere('dept.id = :deptId', { deptId });
|
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, {
|
return paginate<UserEntity>(queryBuilder, {
|
||||||
page,
|
page,
|
||||||
pageSize
|
pageSize
|
||||||
|
|
Loading…
Reference in New Issue