"use strict";
// oms/src/models/messageTemplateModel.ts
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MessageTemplate = exports.TEMPLATE_TYPE_MAP = exports.TemplateType = void 0;
const mongoose_1 = __importStar(require("mongoose"));
// 定义模板类型的枚举，确保数据的一致性
var TemplateType;
(function (TemplateType) {
    TemplateType[TemplateType["OTHER"] = 0] = "OTHER";
    TemplateType[TemplateType["NEW_USER_WELCOM"] = 1] = "NEW_USER_WELCOM";
    TemplateType[TemplateType["ENCOURAGE_AND_REWARD"] = 2] = "ENCOURAGE_AND_REWARD";
    TemplateType[TemplateType["DAILY_REWARD_REMINDER"] = 3] = "DAILY_REWARD_REMINDER";
    TemplateType[TemplateType["PERSONALIZED_RECOMMENDATION"] = 4] = "PERSONALIZED_RECOMMENDATION";
    TemplateType[TemplateType["NEW_CONTENT_REMINDER"] = 5] = "NEW_CONTENT_REMINDER";
    TemplateType[TemplateType["HOT_CONTENT_RECOMMENDATION"] = 6] = "HOT_CONTENT_RECOMMENDATION";
    TemplateType[TemplateType["LIMITED_TIME_EVENT_REMINDER"] = 7] = "LIMITED_TIME_EVENT_REMINDER";
    TemplateType[TemplateType["HOLIDAY_CELEBRATION"] = 8] = "HOLIDAY_CELEBRATION";
    TemplateType[TemplateType["COMPLETION_ENCOURAGEMENT"] = 9] = "COMPLETION_ENCOURAGEMENT";
    TemplateType[TemplateType["SOCIAL_SHARING_ENCOURAGEMENT"] = 10] = "SOCIAL_SHARING_ENCOURAGEMENT";
    TemplateType[TemplateType["UNACTIVE_USER_RECALL"] = 11] = "UNACTIVE_USER_RECALL";
    TemplateType[TemplateType["NEW_FEATURE_INTRODUCTION"] = 12] = "NEW_FEATURE_INTRODUCTION";
    TemplateType[TemplateType["CHALLENGE_TASK_REMINDER"] = 13] = "CHALLENGE_TASK_REMINDER";
})(TemplateType || (exports.TemplateType = TemplateType = {}));
// 定义模板类型和中文描述的映射，方便在应用中使用
exports.TEMPLATE_TYPE_MAP = {
    [TemplateType.OTHER]: "其他",
    [TemplateType.NEW_USER_WELCOM]: "欢迎与引导",
    [TemplateType.ENCOURAGE_AND_REWARD]: "鼓励与奖励",
    [TemplateType.DAILY_REWARD_REMINDER]: "每日奖励提醒",
    [TemplateType.PERSONALIZED_RECOMMENDATION]: "个性化推荐",
    [TemplateType.NEW_CONTENT_REMINDER]: "新画作提醒",
    [TemplateType.HOT_CONTENT_RECOMMENDATION]: "热门画作推荐",
    [TemplateType.LIMITED_TIME_EVENT_REMINDER]: "限时活动提醒",
    [TemplateType.HOLIDAY_CELEBRATION]: "假日/节日主题",
    [TemplateType.COMPLETION_ENCOURAGEMENT]: "完成度鼓励",
    [TemplateType.SOCIAL_SHARING_ENCOURAGEMENT]: "社交分享鼓励",
    [TemplateType.UNACTIVE_USER_RECALL]: "长时间不活跃用户召回",
    [TemplateType.NEW_FEATURE_INTRODUCTION]: "新功能介绍",
    [TemplateType.CHALLENGE_TASK_REMINDER]: "挑战任务提醒",
};
// 定义消息模板的 Mongoose Schema，并新增字段
const MessageTemplateSchema = new mongoose_1.Schema({
    templateName: { type: String, required: true, unique: true, trim: true }, // 模板的唯一名称，方便在代码中引用
    templateType: {
        type: Number,
        required: true,
        enum: Object.values(TemplateType).filter((value) => typeof value === "number"), // 使用枚举值来约束此字段
        default: TemplateType.OTHER,
        index: true,
    },
    description: { type: String }, // 描述
    messageTitle: { type: Object, of: String, required: true }, // 消息标题，使用嵌套对象支持多语言
    messageContent: { type: Object, of: String, required: true }, // 消息内容，使用嵌套对象支持多语言
    image: { type: String }, // 通知图片URL
    bigger: { type: Boolean, default: false }, // 消息是否允许展开
    action: { type: String, default: "go/app" }, // 客户端收到消息后的行为
    param: { type: String }, // 消息参数
    extend: { type: String }, // 消息扩展参数
}, {
    timestamps: true, // 自动添加 createdAt 和 updatedAt 字段
});
// 为模板名称字段创建索引以提高查询效率
MessageTemplateSchema.index({ templateName: 1 });
exports.MessageTemplate = mongoose_1.default.model("MessageTemplate", MessageTemplateSchema);
