Merge branch 'develop' of github.com:Frappet/bma-ehr-organization into develop
This commit is contained in:
commit
3d379846da
3 changed files with 76 additions and 4 deletions
|
|
@ -2561,7 +2561,17 @@ export class CommandController extends Controller {
|
|||
await Promise.all(
|
||||
body.data.map(async (item) => {
|
||||
const profile = await this.profileRepository.findOne({
|
||||
relations: ["profileSalary","posType","posLevel"],
|
||||
relations: [
|
||||
"profileSalary",
|
||||
"posType",
|
||||
"posLevel",
|
||||
"current_holders",
|
||||
"current_holders.orgRoot",
|
||||
"current_holders.orgChild1",
|
||||
"current_holders.orgChild2",
|
||||
"current_holders.orgChild3",
|
||||
"current_holders.orgChild4",
|
||||
],
|
||||
where: { id: item.profileId },
|
||||
order: {
|
||||
profileSalary: {
|
||||
|
|
|
|||
|
|
@ -36,11 +36,13 @@ import { Profile } from "../entities/Profile";
|
|||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
import { Brackets, In } from "typeorm";
|
||||
import { Brackets, In, IsNull } from "typeorm";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import HttpStatus from "../interfaces/http-status";
|
||||
import { RoleKeycloak } from "../entities/RoleKeycloak";
|
||||
import { addLogSequence } from "../interfaces/utils";
|
||||
import { OrgRevision } from "../entities/OrgRevision";
|
||||
import { Uuid } from "@elastic/elasticsearch/lib/api/types";
|
||||
// import * as io from "../lib/websocket";
|
||||
// import elasticsearch from "../elasticsearch";
|
||||
// import { StorageFolder } from "../interfaces/storage-fs";
|
||||
|
|
@ -429,15 +431,73 @@ export class KeycloakController extends Controller {
|
|||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query() keyword: string = "",
|
||||
@Query() type: string = "",
|
||||
@Request() req: RequestWithUser,
|
||||
) {
|
||||
// sort by org
|
||||
let condition: any = {};
|
||||
|
||||
if (req.user.role.includes("ADMIN")) {
|
||||
const profile = await this.profileRepo.findOne({
|
||||
relations:[
|
||||
"current_holders",
|
||||
"current_holders.orgRevision",
|
||||
],
|
||||
where: {
|
||||
keycloak: req.user.sub,
|
||||
current_holders:{
|
||||
orgRevision:{
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if(profile?.current_holders[0].orgRootId && profile?.current_holders[0].orgChild1Id == null){
|
||||
condition =
|
||||
`current_holders.orgRootId = '${profile?.current_holders[0].orgRootId}'
|
||||
and current_holders.orgChild1Id IS NULL
|
||||
and current_holders.orgChild2Id IS NULL
|
||||
and current_holders.orgChild3Id IS NULL
|
||||
and current_holders.orgChild4Id IS NULL`;
|
||||
}else if(profile?.current_holders[0].orgChild1Id && profile?.current_holders[0].orgChild2Id == null){
|
||||
condition =
|
||||
`current_holders.orgRootId = '${profile?.current_holders[0].orgRootId}'
|
||||
and current_holders.orgChild1Id '${profile?.current_holders[0].orgChild1Id}'
|
||||
and current_holders.orgChild2Id IS NULL
|
||||
and current_holders.orgChild3Id IS NULL
|
||||
and current_holders.orgChild4Id IS NULL`;
|
||||
}else if(profile?.current_holders[0].orgChild2Id && profile?.current_holders[0].orgChild3Id == null){
|
||||
condition =
|
||||
`current_holders.orgRootId = '${profile?.current_holders[0].orgRootId}'
|
||||
and current_holders.orgChild1Id '${profile?.current_holders[0].orgChild1Id}'
|
||||
and current_holders.orgChild2Id '${profile?.current_holders[0].orgChild2Id}'
|
||||
and current_holders.orgChild3Id IS NULL
|
||||
and current_holders.orgChild4Id IS NULL`;
|
||||
}else if(profile?.current_holders[0].orgChild3Id && profile?.current_holders[0].orgChild4Id == null){
|
||||
condition =
|
||||
`current_holders.orgRootId = '${profile?.current_holders[0].orgRootId}'
|
||||
and current_holders.orgChild1Id '${profile?.current_holders[0].orgChild1Id}'
|
||||
and current_holders.orgChild2Id '${profile?.current_holders[0].orgChild2Id}'
|
||||
and current_holders.orgChild3Id '${profile?.current_holders[0].orgChild3Id}'
|
||||
and current_holders.orgChild4Id IS NULL`;
|
||||
}else if(profile?.current_holders[0].orgChild4Id){
|
||||
condition =
|
||||
`current_holders.orgRootId = '${profile?.current_holders[0].orgRootId}'
|
||||
and current_holders.orgChild1Id '${profile?.current_holders[0].orgChild1Id}'
|
||||
and current_holders.orgChild2Id '${profile?.current_holders[0].orgChild2Id}'
|
||||
and current_holders.orgChild3Id '${profile?.current_holders[0].orgChild3Id}'
|
||||
and current_holders.orgChild4Id '${profile?.current_holders[0].orgChild4Id}'`;
|
||||
}
|
||||
}
|
||||
let profiles: any = [];
|
||||
let total: any;
|
||||
if (type.trim().toUpperCase() == "OFFICER") {
|
||||
[profiles, total] = await this.profileRepo
|
||||
.createQueryBuilder("profile")
|
||||
.leftJoinAndSelect("profile.roleKeycloaks", "roleKeycloaks")
|
||||
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||
.where("profile.keycloak IS NOT NULL AND profile.keycloak != ''")
|
||||
.andWhere(condition)
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.orWhere(
|
||||
|
|
@ -460,7 +520,9 @@ export class KeycloakController extends Controller {
|
|||
[profiles, total] = await this.profileEmpRepo
|
||||
.createQueryBuilder("profileEmployee")
|
||||
.leftJoinAndSelect("profileEmployee.roleKeycloaks", "roleKeycloaks")
|
||||
.leftJoinAndSelect("profileEmployee.current_holders", "current_holders")
|
||||
.where("profileEmployee.keycloak IS NOT NULL AND profileEmployee.keycloak != ''")
|
||||
.andWhere(condition)
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.orWhere(
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ async function logMiddleware(req: Request, res: Response, next: NextFunction) {
|
|||
if (req.url.startsWith("/api/v1/org/pos/position/")) system = "master";
|
||||
if (req.url.startsWith("/api/v1/org/pos/type/")) system = "master";
|
||||
if (req.url.startsWith("/api/v1/org/employee/pos/position/")) system = "master";
|
||||
if (req.url.startsWith("api/v1/org/employee/pos/type/")) system = "master";
|
||||
if (req.url.startsWith("/api/v1/org/employee/pos/type/")) system = "master";
|
||||
if (req.url.startsWith("/api/v1/org/auth/authRoleAttr/")) system = "admin";
|
||||
if (req.url.startsWith("/api/v1/org/auth/authRole/")) system = "admin";
|
||||
// if (req.url.startsWith("/api/v1/org/keycloak")) system = "admin";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue