log and fix bug act role & menu
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:
parent
e69320005c
commit
af88dffbbe
1 changed files with 42 additions and 7 deletions
|
|
@ -325,16 +325,33 @@ export class PosMasterActController extends Controller {
|
|||
// ลบ Redis cache ของคนที่เป็น acting
|
||||
if (posMasterAct != null && posMasterAct.posMasterChild?.current_holderId) {
|
||||
const profileId = posMasterAct.posMasterChild.current_holderId;
|
||||
const redisClient = await this.redis.createClient({
|
||||
const redisClient = this.redis.createClient({
|
||||
host: REDIS_HOST,
|
||||
port: REDIS_PORT,
|
||||
});
|
||||
|
||||
const delAsync = promisify(redisClient.del).bind(redisClient);
|
||||
await delAsync("role_" + profileId);
|
||||
await delAsync("menu_" + profileId);
|
||||
const quitAsync = promisify(redisClient.quit).bind(redisClient);
|
||||
try {
|
||||
const [roleDeleted, menuDeleted] = await Promise.all([
|
||||
delAsync("role_" + profileId),
|
||||
delAsync("menu_" + profileId),
|
||||
]);
|
||||
|
||||
redisClient.quit();
|
||||
if (roleDeleted === 0) {
|
||||
console.warn(`[PosMasterActController] Redis key not found: role_${profileId}`);
|
||||
}
|
||||
if (menuDeleted === 0) {
|
||||
console.warn(`[PosMasterActController] Redis key not found: menu_${profileId}`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(
|
||||
`[PosMasterActController] Redis delete error for profile ${profileId}:`,
|
||||
error,
|
||||
);
|
||||
} finally {
|
||||
await quitAsync();
|
||||
}
|
||||
}
|
||||
|
||||
return new HttpSuccess();
|
||||
|
|
@ -868,10 +885,28 @@ export class PosMasterActController extends Controller {
|
|||
});
|
||||
|
||||
const delAsync = promisify(redisClient.del).bind(redisClient);
|
||||
await delAsync("role_" + profileId);
|
||||
await delAsync("menu_" + profileId);
|
||||
const quitAsync = promisify(redisClient.quit).bind(redisClient);
|
||||
|
||||
redisClient.quit();
|
||||
try {
|
||||
const [roleDeleted, menuDeleted] = await Promise.all([
|
||||
delAsync("role_" + profileId),
|
||||
delAsync("menu_" + profileId),
|
||||
]);
|
||||
|
||||
if (roleDeleted === 0) {
|
||||
console.warn(`[PosMasterActController] Redis key not found: role_${profileId}`);
|
||||
}
|
||||
if (menuDeleted === 0) {
|
||||
console.warn(`[PosMasterActController] Redis key not found: menu_${profileId}`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(
|
||||
`[PosMasterActController] Redis delete error for profile ${profileId}:`,
|
||||
error,
|
||||
);
|
||||
} finally {
|
||||
await quitAsync();
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue