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);
|
assignMap.get(dna)!.push(posmasterAssign);
|
||||||
}
|
}
|
||||||
// ดึง permissionProfiles ของ revision เดิม
|
// // ดึง permissionProfiles ของ revision เดิม
|
||||||
const oldPermissionProfiles = await permissionProfilesRepository.find({
|
// const oldPermissionProfiles = await permissionProfilesRepository.find({
|
||||||
relations: ["orgRootTree"],
|
// relations: ["orgRootTree"],
|
||||||
where: {
|
// where: {
|
||||||
orgRootTree: {
|
// orgRootTree: {
|
||||||
orgRevisionId: orgRevisionPublish?.id,
|
// orgRevisionId: orgRevisionPublish?.id,
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
// สร้าง Map: ancestorDNA → permissionProfiles[]
|
// // สร้าง Map: ancestorDNA → permissionProfiles[]
|
||||||
const permissionMap = new Map<string, PermissionProfile[]>();
|
// const permissionMap = new Map<string, PermissionProfile[]>();
|
||||||
for (const permissionProfile of oldPermissionProfiles) {
|
// for (const permissionProfile of oldPermissionProfiles) {
|
||||||
const dna = permissionProfile.orgRootTree.ancestorDNA;
|
// const dna = permissionProfile.orgRootTree.ancestorDNA;
|
||||||
if (!permissionMap.has(dna)) {
|
// if (!permissionMap.has(dna)) {
|
||||||
permissionMap.set(dna, []);
|
// permissionMap.set(dna, []);
|
||||||
}
|
// }
|
||||||
permissionMap.get(dna)!.push(permissionProfile);
|
// permissionMap.get(dna)!.push(permissionProfile);
|
||||||
}
|
// }
|
||||||
const newRoots = await orgRootRepository.find({
|
// const newRoots = await orgRootRepository.find({
|
||||||
where: { orgRevisionId: orgRevisionDraft?.id },
|
// where: { orgRevisionId: orgRevisionDraft?.id },
|
||||||
});
|
// });
|
||||||
const newRootMap = new Map(
|
// const newRootMap = new Map(
|
||||||
newRoots.map(r => [r.ancestorDNA, r.id])
|
// newRoots.map(r => [r.ancestorDNA, r.id])
|
||||||
);
|
// );
|
||||||
const _null: any = null;
|
const _null: any = null;
|
||||||
for (const item of posMaster) {
|
for (const item of posMaster) {
|
||||||
|
|
||||||
// Clone posMasterAssign xxx
|
// Clone posMasterAssign xxx
|
||||||
const assigns = assignMap.get(item.ancestorDNA);
|
const assigns = assignMap.get(item.ancestorDNA);
|
||||||
if (assigns && assigns.length > 0) {
|
if (assigns && assigns.length > 0) {
|
||||||
|
|
@ -615,15 +615,15 @@ async function handler_org(msg: amqp.ConsumeMessage): Promise<boolean> {
|
||||||
await posMasterAssignRepository.save(newAssigns);
|
await posMasterAssignRepository.save(newAssigns);
|
||||||
}
|
}
|
||||||
// Clone permissionProfiles
|
// Clone permissionProfiles
|
||||||
const perms = permissionMap.get(item.orgRoot.ancestorDNA);
|
// const perms = permissionMap.get(item.ancestorDNA);
|
||||||
const newRootId = newRootMap.get(item.orgRoot.ancestorDNA);
|
// const newRootId = newRootMap.get(item.orgRoot.ancestorDNA);
|
||||||
if (perms && perms.length > 0 && newRootId) {
|
// if (perms && perms.length > 0 && newRootId) {
|
||||||
const newPerms = perms.map(({ id, ...fields }) => ({
|
// const newPerms = perms.map(({ id, ...fields }) => ({
|
||||||
...fields,
|
// ...fields,
|
||||||
orgRootId: newRootId,
|
// orgRootId: newRootId,
|
||||||
}));
|
// }));
|
||||||
await permissionProfilesRepository.save(newPerms);
|
// await permissionProfilesRepository.save(newPerms);
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (item.next_holderId != null) {
|
if (item.next_holderId != null) {
|
||||||
const profile = await repoProfile.findOne({
|
const profile = await repoProfile.findOne({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue