const db = require('../config/database'); class OperationLog { static async add(logData) { const { user_id, type, target, description, ip } = logData; const sql = ` INSERT INTO operation_logs (user_id, operation_type, operation_target, description, ip_address) VALUES (?, ?, ?, ?, ?) `; return await db.query(sql, [user_id, type, target, description, ip]); } static async findAll(params = {}) { const limit = parseInt(params.limit) || 50; const offset = parseInt(params.offset) || 0; const sql = ` SELECT l.*, u.name as user_name FROM operation_logs l LEFT JOIN users u ON l.user_id = u.id ORDER BY l.created_at DESC LIMIT ? OFFSET ? `; return await db.query(sql, [limit, offset]); } } module.exports = OperationLog;