"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UserTargetingController = void 0;
const userTargetingService_1 = require("../services/userTargetingService");
const userTargetingService = new userTargetingService_1.UserTargetingService();
class UserTargetingController {
    /**
     * @route POST /api/users/count
     * @desc 根据筛选条件查询满足条件的用户数
     * @access Private (或根据需要调整)
     */
    async countTargetUsers(req, res) {
        try {
            // 从请求体中获取筛选条件数组
            const { filters } = req.body;
            console.log(filters);
            if (!filters || !Array.isArray(filters)) {
                return res.status(400).json({ success: false, message: "Invalid or missing 'filters' array in request body." });
            }
            // 调用服务层方法获取用户数量
            const userCount = await userTargetingService.countTargetUsers(filters);
            return res.status(200).json(userCount);
        }
        catch (error) {
            console.error("Error counting target users from API request:", error);
            return res.status(500).json({ success: false, message: "Server error", error: error.message });
        }
    }
}
exports.UserTargetingController = UserTargetingController;
exports.default = new UserTargetingController();
