"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const express_1 = require("express");
const userController_1 = __importDefault(require("../controllers/userController"));
const artController_1 = __importDefault(require("../controllers/artController"));
const doneRateController_1 = __importDefault(require("../controllers/doneRateController"));
const messageTemplateController_1 = __importDefault(require("../controllers/messageTemplateController"));
const messageStrategyController_1 = __importDefault(require("../controllers/messageStrategyController")); // 新增：导入消息策略控制器
const messageActivityController_1 = __importDefault(require("../controllers/messageActivityController")); // 新增：导入消息活动控制器
const messageRecordController_1 = __importDefault(require("../controllers/messageRecordController")); // 新增：导入消息记录控制器
const userTargetingController_1 = __importDefault(require("../controllers/userTargetingController"));
const adminController_1 = __importDefault(require("../controllers/adminController"));
const authMiddleware_1 = require("../middleware/authMiddleware");
const router = (0, express_1.Router)();
// 公共的管理员认证路由 (无需认证)
router.post("/admin/register", adminController_1.default.register);
router.post("/admin/login", adminController_1.default.login);
router.post("/users/send-message", userController_1.default.sendDirectMessage); // 点对点
// 新增：消息记录统计路由
router.get("/message/statistics/overall", messageRecordController_1.default.getOverallStatistics);
router.get("/message/statistics/by-activity", messageRecordController_1.default.getStatisticsByActivity);
router.get("/message/statistics/by-strategy", messageRecordController_1.default.getStatisticsByStrategy);
router.get("/message/statistics/by-template", messageRecordController_1.default.getStatisticsByTemplate);
router.get("/message/statistics/by-cc", messageRecordController_1.default.getStatisticsByCc);
router.get("/message/statistics/by-image", messageRecordController_1.default.getStatisticsByImage);
router.get("/message/statistics/daily-trends", messageRecordController_1.default.getDailySentTrends);
router.get("/message/statistics/multi-dimensional", messageRecordController_1.default.getMultiDimensionalStatistics); // 新增：多维度统计路由
// 新增：下钻统计路由
router.get("/message/daily/trends/by-cc/:cc", messageRecordController_1.default.getDailyTrendsByCc);
router.get("/message/daily/trends/by-strategy/:strategyName", messageRecordController_1.default.getDailyTrendsByStrategy);
router.get("/message/daily/trends/by-template/:templateName", messageRecordController_1.default.getDailyTrendsByTemplate);
router.get("/message/daily/trends/by-image/:image", messageRecordController_1.default.getDailyTrendsByImage);
// 应用认证中间件，保护所有下面的路由
router.use(authMiddleware_1.authMiddleware);
// User routes
router.post("/users", userController_1.default.createUser);
// Updated to the paginated user list interface
router.get("/users", userController_1.default.getPaginatedUsers); // GET /api/users?page=1&limit=10&project=1
router.get("/users/:uid", userController_1.default.getUserByUid);
router.put("/users/:uid", userController_1.default.updateUser);
router.delete("/users/:uid", userController_1.default.deleteUser);
// 新增：发送消息接口
router.post("/users/send-bulk-message", userController_1.default.sendBulkMessage); // 群发
router.get("/arts", artController_1.default.getArts); // 获取作品列表 (支持分页、筛选、排序)
router.get("/arts/:id", artController_1.default.getArtById); // 获取单个作品
router.put("/arts/:id", artController_1.default.updateArt); // 更新作品信息
// 完成率 DoneRate 路由 (只读)
router.get("/done-rates/artwork/:resId", doneRateController_1.default.getDoneRatesByArtworkId); // 按作品 ID 获取历史完成率
router.get("/done-rates/date/:date", doneRateController_1.default.getDoneRatesByDate); // 按日期获取所有作品完成率
// 消息模板路由
router.post("/message-template", messageTemplateController_1.default.createTemplate);
router.get("/message-template", messageTemplateController_1.default.getAllTemplates);
router.get("/message-template/:templateName", messageTemplateController_1.default.getTemplateByName);
router.put("/message-template/:templateName", messageTemplateController_1.default.updateTemplate);
router.delete("/message-template/:templateName", messageTemplateController_1.default.deleteTemplate);
// 新增：消息策略路由
router.post("/message-strategy", messageStrategyController_1.default.createStrategy);
router.get("/message-strategies", messageStrategyController_1.default.getStrategies);
router.get("/message-strategy/:id", messageStrategyController_1.default.getStrategyById);
router.put("/message-strategy/:id", messageStrategyController_1.default.updateStrategy);
router.delete("/message-strategy/:id", messageStrategyController_1.default.deleteStrategy);
// 新增：消息活动路由
router.post("/message-activity", messageActivityController_1.default.createActivity);
router.get("/message-activities", messageActivityController_1.default.getActivities);
router.get("/message-activity/:id", messageActivityController_1.default.getActivityById);
router.put("/message-activity/:id", messageActivityController_1.default.updateActivity);
router.delete("/message-activity/:id", messageActivityController_1.default.deleteActivity);
router.put("/message-activity/:id/status", messageActivityController_1.default.updateActivityStatus);
// 新增：用户筛选相关路由
router.post("/users/count", userTargetingController_1.default.countTargetUsers);
// 新增：消息记录路由
router.post("/message-record", messageRecordController_1.default.createRecord);
router.get("/message-records", messageRecordController_1.default.getPaginatedRecords); // 新增分页接口
router.get("/message-records/user/:uid", messageRecordController_1.default.getRecordsByUid);
router.get("/message-record/:id", messageRecordController_1.default.getRecordById);
router.put("/message-record/:id", messageRecordController_1.default.updateRecord);
// 管理员路由
router.get("/admin", adminController_1.default.getAdmins);
router.get("/admin/:id", adminController_1.default.getAdminById);
router.put("/admin/:id", adminController_1.default.updateAdmin);
router.delete("/admin/:id", adminController_1.default.deleteAdmin);
exports.default = router;
