feat(server): implement server management handlers and database schema

This commit is contained in:
Chang lue Tsen
2025-08-25 14:06:37 -04:00
parent 1ccbdc18b1
commit ad4f3df74e
108 changed files with 3152 additions and 718 deletions
+4 -3
View File
@@ -594,19 +594,20 @@ func (l *ResetTrafficLogic) clearCache(ctx context.Context, list []*user.Subscri
}
}
// Insert traffic reset log
l.insertLog(ctx, sub.Id)
l.insertLog(ctx, sub.Id, sub.UserId)
}
}
}
// insertLog inserts a reset traffic log entry
func (l *ResetTrafficLogic) insertLog(ctx context.Context, subId int64) {
func (l *ResetTrafficLogic) insertLog(ctx context.Context, subId, userId int64) {
trafficLog := log.ResetSubscribe{
Type: log.ResetSubscribeTypeAuto,
UserId: userId,
ResetAt: time.Now().UnixMilli(),
}
content, _ := trafficLog.Marshal()
if err := l.svc.DB.Model(&log.SystemLog{}).Create(&log.SystemLog{
if err := l.svc.DB.WithContext(ctx).Model(&log.SystemLog{}).Create(&log.SystemLog{
Type: log.TypeResetSubscribe.Uint8(),
ObjectID: subId,
Date: time.Now().Format(time.DateOnly),