Initial commit: Telegram Management System
Some checks failed
Deploy / deploy (push) Has been cancelled

Full-stack web application for Telegram management
- Frontend: Vue 3 + Vben Admin
- Backend: NestJS
- Features: User management, group broadcast, statistics

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
你的用户名
2025-11-04 15:37:50 +08:00
commit 237c7802e5
3674 changed files with 525172 additions and 0 deletions

View File

@@ -0,0 +1,80 @@
import mongoose from 'mongoose';
const eventSchema = new mongoose.Schema({
// Multi-tenant support
tenantId: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Tenant',
required: true,
index: true
},
id: {
type: String,
required: true,
unique: true,
index: true
},
type: {
type: String,
required: true,
index: true
},
accountId: {
type: String,
required: true,
index: true
},
userId: {
type: String,
index: true
},
sessionId: {
type: String,
index: true
},
action: {
type: String,
required: true,
index: true
},
target: String,
value: Number,
metadata: {
type: Map,
of: mongoose.Schema.Types.Mixed
},
properties: {
type: Map,
of: mongoose.Schema.Types.Mixed
},
timestamp: {
type: Date,
required: true,
index: true
}
}, {
timestamps: true,
timeseries: {
timeField: 'timestamp',
metaField: 'metadata',
granularity: 'seconds'
}
});
// Compound indexes for common queries
eventSchema.index({ accountId: 1, timestamp: -1 });
eventSchema.index({ accountId: 1, type: 1, timestamp: -1 });
eventSchema.index({ accountId: 1, userId: 1, timestamp: -1 });
eventSchema.index({ type: 1, action: 1, timestamp: -1 });
// TTL index to auto-delete old events after 1 year
eventSchema.index({ timestamp: 1 }, { expireAfterSeconds: 31536000 });
// Multi-tenant indexes
eventSchema.index({ tenantId: 1, accountId: 1, timestamp: -1 });
eventSchema.index({ tenantId: 1, accountId: 1, type: 1, timestamp: -1 });
eventSchema.index({ tenantId: 1, accountId: 1, userId: 1, timestamp: -1 });
eventSchema.index({ tenantId: 1, type: 1, action: 1, timestamp: -1 });
eventSchema.index({ tenantId: 1, timestamp: 1 }, { expireAfterSeconds: 31536000 });
export const Event = mongoose.model('Event', eventSchema);