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() pageSize: number = 30,
|
||||||
@Query() status?: Status,
|
@Query() status?: Status,
|
||||||
@Query() responsibleDistrictId?: string,
|
@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
|
const area = responsibleDistrictId
|
||||||
? await prisma.employmentOffice.findMany({
|
? await prisma.employmentOffice.findMany({
|
||||||
|
|
@ -293,11 +321,18 @@ export class UserController extends Controller {
|
||||||
...whereAddressQuery(query),
|
...whereAddressQuery(query),
|
||||||
]),
|
]),
|
||||||
AND: {
|
AND: {
|
||||||
responsibleArea: area
|
OR: [
|
||||||
? {
|
{
|
||||||
some: { area: { in: area.map((v) => v.id) } },
|
responsibleArea: area
|
||||||
}
|
? {
|
||||||
: undefined,
|
some: { area: { in: area.map((v) => v.id) } },
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: body?.userId ? { in: body.userId } : undefined,
|
||||||
|
},
|
||||||
|
],
|
||||||
userRole: { not: "system" },
|
userRole: { not: "system" },
|
||||||
userType,
|
userType,
|
||||||
...filterStatus(status),
|
...filterStatus(status),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue