| 123456789101112131415161718192021222324252627 |
- const db = require('../config/db');
- const logger = require('../logger');
- class AuthzCheck {
- // 插入授权检查结果
- static insert(authzData, callback) {
- const { client_id, topic, action, result, timestamp } = authzData;
- const sql = `
- INSERT INTO authz_checks (client_id, topic, action, result, timestamp)
- VALUES (?, ?, ?, ?, ?)
- `;
-
- logger.info(`记录授权检查: 客户端=${client_id}, 主题=${topic}, 操作=${action}`);
- logger.debug('执行 SQL:', sql, [client_id, topic, action, result, timestamp]);
-
- db.query(sql, [client_id, topic, action, result, timestamp], (err, result) => {
- if (err) {
- logger.error('记录授权检查失败:', err);
- return callback(err);
- }
- logger.info('授权检查记录成功');
- callback(null, result);
- });
- }
- }
- module.exports = AuthzCheck;
|