package systemlog import ( udeModel "udeServer/internal/model" "udeServer/internal/types" ) // ConvertToSystemLog maps the model row to the API response type. func ConvertToSystemLog(v *udeModel.TSystemLog) types.SystemLog { return types.SystemLog{ Id: v.Id, Iden: v.Iden, TraceId: v.TraceId, SpanId: v.SpanId, ParentSpanId: v.ParentSpanId.String, Type: int(v.Type), ServiceName: v.ServiceName, UriPath: v.UriPath.String, HttpMethod: v.HttpMethod.String, Method: v.Method, Level: v.Level, AppKey: v.AppKey.String, UserId: v.UserId.String, UserName: v.UserName.String, ClientIp: v.ClientIp.String, RequestHeader: v.RequestHeader.String, RequestBodyDigest: v.RequestBodyDigest, RequestBodyFileKey: v.RequestBodyFileKey, ResponseCode: v.ResponseCode, ResponseBodyDigest: v.ResponseBodyDigest, ResponseBodyFileKey: v.ResponseBodyFileKey, ErrorMsg: v.ErrorMessage.String, DurationMs: v.DurationMs, CreatedAt: v.CreatedAt.Format("2006-01-02 15:04:05"), Hmac: v.HMac, AuditStatus: int(v.AuditStatus), } } // ConvertToLogArchive maps the model row to the API response type. func ConvertToLogArchive(v *udeModel.TLogArchiveRecord) types.LogArchive { return types.LogArchive{ Id: v.Id, ArchiveName: v.ArchiveName, RecordCount: v.RecordCount, ArchiveFileKey: v.ArchiveFileKey, ArchiveMode: int(v.ArchiveMode), BatchSize: int(v.BatchSize), ArchivedBy: v.ArchivedBy, ArchivedAt: v.ArchivedAt.Format("2006-01-02 15:04:05"), } } // ConvertToLogRestore maps the model row to the API response type. func ConvertToLogRestore(v *udeModel.TLogRestoreRecord) types.LogRestore { return types.LogRestore{ Id: v.Id, ArchiveId: v.ArchiveId, RestoreStatus: int(v.RestoreStatus), RestoreMessage: v.RestoreMessage.String, RestoredBy: v.RestoredBy, RestoredAt: v.RestoredAt.Format("2006-01-02 15:04:05"), } } // normalizePage clamps the paging parameters (default 1/10, max 100). func normalizePage(page, pageSize int64) (int64, int64) { if page < 1 { page = 1 } if pageSize < 10 { pageSize = 10 } if pageSize > 100 { pageSize = 100 } return page, pageSize }