Merge branch 'develop' into dev
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m0s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m0s
This commit is contained in:
commit
c037cbca88
1 changed files with 34 additions and 34 deletions
|
|
@ -578,33 +578,33 @@ async function handler_org(msg: amqp.ConsumeMessage): Promise<boolean> {
|
|||
}
|
||||
assignMap.get(dna)!.push(posmasterAssign);
|
||||
}
|
||||
// ดึง permissionProfiles ของ revision เดิม
|
||||
const oldPermissionProfiles = await permissionProfilesRepository.find({
|
||||
relations: ["orgRootTree"],
|
||||
where: {
|
||||
orgRootTree: {
|
||||
orgRevisionId: orgRevisionPublish?.id,
|
||||
}
|
||||
}
|
||||
});
|
||||
// สร้าง Map: ancestorDNA → permissionProfiles[]
|
||||
const permissionMap = new Map<string, PermissionProfile[]>();
|
||||
for (const permissionProfile of oldPermissionProfiles) {
|
||||
const dna = permissionProfile.orgRootTree.ancestorDNA;
|
||||
if (!permissionMap.has(dna)) {
|
||||
permissionMap.set(dna, []);
|
||||
}
|
||||
permissionMap.get(dna)!.push(permissionProfile);
|
||||
}
|
||||
const newRoots = await orgRootRepository.find({
|
||||
where: { orgRevisionId: orgRevisionDraft?.id },
|
||||
});
|
||||
const newRootMap = new Map(
|
||||
newRoots.map(r => [r.ancestorDNA, r.id])
|
||||
);
|
||||
// // ดึง permissionProfiles ของ revision เดิม
|
||||
// const oldPermissionProfiles = await permissionProfilesRepository.find({
|
||||
// relations: ["orgRootTree"],
|
||||
// where: {
|
||||
// orgRootTree: {
|
||||
// orgRevisionId: orgRevisionPublish?.id,
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// // สร้าง Map: ancestorDNA → permissionProfiles[]
|
||||
// const permissionMap = new Map<string, PermissionProfile[]>();
|
||||
// for (const permissionProfile of oldPermissionProfiles) {
|
||||
// const dna = permissionProfile.orgRootTree.ancestorDNA;
|
||||
// if (!permissionMap.has(dna)) {
|
||||
// permissionMap.set(dna, []);
|
||||
// }
|
||||
// permissionMap.get(dna)!.push(permissionProfile);
|
||||
// }
|
||||
// const newRoots = await orgRootRepository.find({
|
||||
// where: { orgRevisionId: orgRevisionDraft?.id },
|
||||
// });
|
||||
// const newRootMap = new Map(
|
||||
// newRoots.map(r => [r.ancestorDNA, r.id])
|
||||
// );
|
||||
const _null: any = null;
|
||||
for (const item of posMaster) {
|
||||
|
||||
|
||||
// Clone posMasterAssign xxx
|
||||
const assigns = assignMap.get(item.ancestorDNA);
|
||||
if (assigns && assigns.length > 0) {
|
||||
|
|
@ -615,15 +615,15 @@ async function handler_org(msg: amqp.ConsumeMessage): Promise<boolean> {
|
|||
await posMasterAssignRepository.save(newAssigns);
|
||||
}
|
||||
// Clone permissionProfiles
|
||||
const perms = permissionMap.get(item.orgRoot.ancestorDNA);
|
||||
const newRootId = newRootMap.get(item.orgRoot.ancestorDNA);
|
||||
if (perms && perms.length > 0 && newRootId) {
|
||||
const newPerms = perms.map(({ id, ...fields }) => ({
|
||||
...fields,
|
||||
orgRootId: newRootId,
|
||||
}));
|
||||
await permissionProfilesRepository.save(newPerms);
|
||||
}
|
||||
// const perms = permissionMap.get(item.ancestorDNA);
|
||||
// const newRootId = newRootMap.get(item.orgRoot.ancestorDNA);
|
||||
// if (perms && perms.length > 0 && newRootId) {
|
||||
// const newPerms = perms.map(({ id, ...fields }) => ({
|
||||
// ...fields,
|
||||
// orgRootId: newRootId,
|
||||
// }));
|
||||
// await permissionProfilesRepository.save(newPerms);
|
||||
// }
|
||||
|
||||
if (item.next_holderId != null) {
|
||||
const profile = await repoProfile.findOne({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue