feat: add support for complex query for user
This commit is contained in:
parent
ff4c100497
commit
53251ac214
1 changed files with 40 additions and 5 deletions
|
|
@ -263,6 +263,34 @@ export class UserController extends Controller {
|
|||
@Query() pageSize: number = 30,
|
||||
@Query() status?: Status,
|
||||
@Query() responsibleDistrictId?: string,
|
||||
) {
|
||||
return this.getUserByCriteria(
|
||||
req,
|
||||
userType,
|
||||
includeBranch,
|
||||
query,
|
||||
page,
|
||||
pageSize,
|
||||
status,
|
||||
responsibleDistrictId,
|
||||
);
|
||||
}
|
||||
|
||||
@Post("list")
|
||||
@Security("keycloak")
|
||||
async getUserByCriteria(
|
||||
@Request() req: RequestWithUser,
|
||||
@Query() userType?: UserType,
|
||||
@Query() includeBranch: boolean = false,
|
||||
@Query() query: string = "",
|
||||
@Query() page: number = 1,
|
||||
@Query() pageSize: number = 30,
|
||||
@Query() status?: Status,
|
||||
@Query() responsibleDistrictId?: string,
|
||||
@Body()
|
||||
body?: {
|
||||
userId?: string[];
|
||||
},
|
||||
) {
|
||||
const area = responsibleDistrictId
|
||||
? await prisma.employmentOffice.findMany({
|
||||
|
|
@ -293,11 +321,18 @@ export class UserController extends Controller {
|
|||
...whereAddressQuery(query),
|
||||
]),
|
||||
AND: {
|
||||
responsibleArea: area
|
||||
? {
|
||||
some: { area: { in: area.map((v) => v.id) } },
|
||||
}
|
||||
: undefined,
|
||||
OR: [
|
||||
{
|
||||
responsibleArea: area
|
||||
? {
|
||||
some: { area: { in: area.map((v) => v.id) } },
|
||||
}
|
||||
: undefined,
|
||||
},
|
||||
{
|
||||
id: body?.userId ? { in: body.userId } : undefined,
|
||||
},
|
||||
],
|
||||
userRole: { not: "system" },
|
||||
userType,
|
||||
...filterStatus(status),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue