24 lines
571 B
JavaScript
24 lines
571 B
JavaScript
export function createMindSpaceAuditWriter(pool) {
|
|
const write = async ({
|
|
userId,
|
|
action,
|
|
objectType,
|
|
objectId,
|
|
ip = null,
|
|
result = 'success',
|
|
riskLevel = null,
|
|
now = Date.now(),
|
|
}) => {
|
|
if (!pool) return;
|
|
if (!userId) return;
|
|
await pool.query(
|
|
`INSERT INTO h5_mindspace_audit_logs
|
|
(user_id, action, object_type, object_id, ip, result, risk_level, created_at)
|
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
[userId, action, objectType, objectId, ip, result, riskLevel, now],
|
|
);
|
|
};
|
|
|
|
return { write };
|
|
}
|