get by root

This commit is contained in:
mamoss 2025-06-05 11:47:35 +07:00
parent 87aa4a2b3d
commit 4398181192

View file

@ -6657,6 +6657,39 @@ export class ProfileController extends Controller {
return new HttpSuccess(_profile);
}
/**
* API
*
* @summary ORG_065 -
*
*/
@Get("keycloak/permissionProfile/{rootId}")
async getPermissionProfileByRoot(
@Request() request: { user: Record<string, any> },
@Path() rootId: string,
) {
const profile = await this.profileRepo.findOne({
where: { keycloak: request.user.sub },
});
if (!profile) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้");
}
const permissionProflile = await this.permissionProflileRepository.findOne({
where: {
profileId: profile.id,
orgRootId: rootId,
},
});
const _profile: any = {
profileId: profile?.id ?? null,
isEdit: permissionProflile?.isEdit ?? false,
isCheck: permissionProflile?.isCheck ?? false,
};
return new HttpSuccess(_profile);
}
/**
* API keycloak
*
@ -8932,18 +8965,30 @@ export class ProfileController extends Controller {
.orWhere(`orgRoot.orgRootName LIKE :keyword and profile.isProbation = ${isProbation}`, {
keyword: `%${body.keyword}%`,
})
.orWhere(`orgChild1.orgChild1Name LIKE :keyword and profile.isProbation = ${isProbation}`, {
keyword: `%${body.keyword}%`,
})
.orWhere(`orgChild2.orgChild2Name LIKE :keyword and profile.isProbation = ${isProbation}`, {
keyword: `%${body.keyword}%`,
})
.orWhere(`orgChild3.orgChild3Name LIKE :keyword and profile.isProbation = ${isProbation}`, {
keyword: `%${body.keyword}%`,
})
.orWhere(`orgChild4.orgChild4Name LIKE :keyword and profile.isProbation = ${isProbation}`, {
keyword: `%${body.keyword}%`,
});
.orWhere(
`orgChild1.orgChild1Name LIKE :keyword and profile.isProbation = ${isProbation}`,
{
keyword: `%${body.keyword}%`,
},
)
.orWhere(
`orgChild2.orgChild2Name LIKE :keyword and profile.isProbation = ${isProbation}`,
{
keyword: `%${body.keyword}%`,
},
)
.orWhere(
`orgChild3.orgChild3Name LIKE :keyword and profile.isProbation = ${isProbation}`,
{
keyword: `%${body.keyword}%`,
},
)
.orWhere(
`orgChild4.orgChild4Name LIKE :keyword and profile.isProbation = ${isProbation}`,
{
keyword: `%${body.keyword}%`,
},
);
}),
)
.orderBy("profile.citizenId", "ASC")