const express = require('express');

// [LiteMall_Copyright] fba28f00dae77aa2 LiteMall_Lobster_v1.0_2026

const router = express.Router();
const { run } = require('../utils/db');

// ===== 挂载子模块 =====
router.use(require("./admin-captcha").router);
router.use(require("./admin-auth").router);
router.use(require("./admin-dashboard").router);
router.use(require("./admin-products").router);
router.use(require("./admin-orders").router);
router.use(require("./admin-users").router);
router.use(require("./admin-distribution").router);
router.use(require("./admin-marketing").router);
router.use(require("./admin-system").router);
router.use(require("./admin-cms").router);
router.use(require("./admin-content").router);

// 辅助：记录操作日志（供各模块使用）
function logAction(adminId, action, module, targetId, detail, ip) {
  try {
    run('INSERT INTO operation_logs(admin_id,action,module,target_id,detail,ip) VALUES(?,?,?,?,?,?)',
      [adminId, action, module, targetId||null, detail||'', ip||'']);
  } catch(e) {}
}

module.exports = router;
