Merge branch 'develop' into dev
All checks were successful
Build & Deploy on Dev / build (push) Successful in 50s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 50s
* develop: add permission brother
This commit is contained in:
commit
5a206769c4
2 changed files with 60 additions and 46 deletions
|
|
@ -174,7 +174,7 @@ export class EvaluationController {
|
|||
_data.child1 != undefined && _data.child1 != null
|
||||
? _data.child1[0] != null
|
||||
? `evaluation.child1DnaId IN (:...child1)`
|
||||
: `evaluation.child1DnaId is null`
|
||||
: `evaluation.child1DnaId is ${_data.privilege == "PARENT" ? "not null" : "null"}`
|
||||
: "1=1",
|
||||
{
|
||||
child1: _data.child1,
|
||||
|
|
@ -234,15 +234,12 @@ export class EvaluationController {
|
|||
}),
|
||||
);
|
||||
}),
|
||||
)
|
||||
);
|
||||
|
||||
if (body.sortBy) {
|
||||
query = query.orderBy(
|
||||
`evaluation.${body.sortBy}`,
|
||||
body.descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else{
|
||||
query = query.orderBy("evaluation.lastUpdatedAt", "DESC")
|
||||
query = query.orderBy(`evaluation.${body.sortBy}`, body.descending ? "DESC" : "ASC");
|
||||
} else {
|
||||
query = query.orderBy("evaluation.lastUpdatedAt", "DESC");
|
||||
}
|
||||
|
||||
const [evaluation, total] = await query
|
||||
|
|
@ -281,8 +278,8 @@ export class EvaluationController {
|
|||
pageSize: number;
|
||||
keyword?: string;
|
||||
status?: string[];
|
||||
sortBy?: string,
|
||||
descending?: boolean,
|
||||
sortBy?: string;
|
||||
descending?: boolean;
|
||||
},
|
||||
) {
|
||||
try {
|
||||
|
|
@ -306,13 +303,10 @@ export class EvaluationController {
|
|||
});
|
||||
}),
|
||||
)
|
||||
.orderBy("evaluation.lastUpdatedAt", "DESC")
|
||||
.orderBy("evaluation.lastUpdatedAt", "DESC");
|
||||
|
||||
if (body.sortBy) {
|
||||
query = query.orderBy(
|
||||
`evaluation.${body.sortBy}`,
|
||||
body.descending ? "DESC" : "ASC"
|
||||
);
|
||||
query = query.orderBy(`evaluation.${body.sortBy}`, body.descending ? "DESC" : "ASC");
|
||||
}
|
||||
|
||||
const [evaluation, total] = await query
|
||||
|
|
@ -3125,7 +3119,9 @@ export class EvaluationController {
|
|||
evaluation.authorDoc2 = body.authorDoc2;
|
||||
evaluation.subjectDoc2 = body.subjectDoc2;
|
||||
evaluation.assignedPosition = body.assignedPosition;
|
||||
evaluation.assignedPosLevel = body.assignedPosLevel ? body.assignedPosLevel : evaluation.assignedPosLevel;
|
||||
evaluation.assignedPosLevel = body.assignedPosLevel
|
||||
? body.assignedPosLevel
|
||||
: evaluation.assignedPosLevel;
|
||||
evaluation.commanderFullnameDoc2 = body.commanderFullnameDoc2;
|
||||
evaluation.commanderOrgDoc2 = body.commanderOrgDoc2 ?? _null;
|
||||
evaluation.commanderOrgOldDoc2 = body.commanderOrgOldDoc2 ?? _null;
|
||||
|
|
|
|||
|
|
@ -94,6 +94,15 @@ class CheckAuth {
|
|||
child4: null,
|
||||
privilege: "ROOT",
|
||||
};
|
||||
} else if (privilege == "PARENT") {
|
||||
data = {
|
||||
root: [x.orgRootId],
|
||||
child1: [null],
|
||||
child2: null,
|
||||
child3: null,
|
||||
child4: null,
|
||||
privilege: "PARENT",
|
||||
};
|
||||
} else if (privilege == "CHILD") {
|
||||
data = {
|
||||
root: node >= 0 ? [x.orgRootId] : null,
|
||||
|
|
@ -103,6 +112,15 @@ class CheckAuth {
|
|||
child4: node >= 4 ? [x.orgChild4Id] : null,
|
||||
privilege: "CHILD",
|
||||
};
|
||||
} else if (privilege == "BROTHER") {
|
||||
data = {
|
||||
// root: node >= 0 ? [x.orgRootId] : null,
|
||||
root: node >= 0 ? [x.orgRootId] : null,
|
||||
child1: node >= 2 ? [x.orgChild1Id] : null,
|
||||
child2: node >= 3 ? [x.orgChild2Id] : null,
|
||||
child3: node >= 4 ? [x.orgChild3Id] : null,
|
||||
privilege: "BROTHER",
|
||||
};
|
||||
} else if (privilege == "NORMAL") {
|
||||
data = {
|
||||
root: [x.orgRootId],
|
||||
|
|
@ -185,38 +203,38 @@ class CheckAuth {
|
|||
}
|
||||
public async checkOrg(token: any, keycloakId: string) {
|
||||
const redisClient = await this.redis.createClient({
|
||||
host: process.env.REDIS_HOST,
|
||||
port: process.env.REDIS_PORT,
|
||||
})
|
||||
const getAsync = promisify(redisClient.get).bind(redisClient)
|
||||
try {
|
||||
let reply = await getAsync("org_" + keycloakId)
|
||||
if (reply != null) {
|
||||
reply = JSON.parse(reply)
|
||||
} else {
|
||||
if (!keycloakId) throw new Error("No KeycloakId provided")
|
||||
const x = await new CallAPI().GetData(
|
||||
{
|
||||
headers: { authorization: token },
|
||||
},
|
||||
`/org/permission/checkOrg/${keycloakId}`,
|
||||
false
|
||||
)
|
||||
host: process.env.REDIS_HOST,
|
||||
port: process.env.REDIS_PORT,
|
||||
});
|
||||
const getAsync = promisify(redisClient.get).bind(redisClient);
|
||||
try {
|
||||
let reply = await getAsync("org_" + keycloakId);
|
||||
if (reply != null) {
|
||||
reply = JSON.parse(reply);
|
||||
} else {
|
||||
if (!keycloakId) throw new Error("No KeycloakId provided");
|
||||
const x = await new CallAPI().GetData(
|
||||
{
|
||||
headers: { authorization: token },
|
||||
},
|
||||
`/org/permission/checkOrg/${keycloakId}`,
|
||||
false,
|
||||
);
|
||||
|
||||
const data = {
|
||||
orgRootId: x.orgRootId,
|
||||
orgChild1Id: x.orgChild1Id,
|
||||
orgChild2Id: x.orgChild2Id,
|
||||
orgChild3Id: x.orgChild3Id,
|
||||
orgChild4Id: x.orgChild4Id,
|
||||
}
|
||||
const data = {
|
||||
orgRootId: x.orgRootId,
|
||||
orgChild1Id: x.orgChild1Id,
|
||||
orgChild2Id: x.orgChild2Id,
|
||||
orgChild3Id: x.orgChild3Id,
|
||||
orgChild4Id: x.orgChild4Id,
|
||||
};
|
||||
|
||||
return data
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error calling API:", error)
|
||||
throw error
|
||||
}
|
||||
return data;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error calling API:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
public async PermissionCreate(req: RequestWithUser, system: string) {
|
||||
return await this.Permission(req, system, "CREATE");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue