| | | 1 | | // SPDX-FileCopyrightText: 2026 Alper Çelik <alper@alper-celik.dev> |
| | | 2 | | // |
| | | 3 | | // SPDX-License-Identifier: AGPL-3.0-or-later |
| | | 4 | | |
| | | 5 | | using System.ComponentModel.DataAnnotations; |
| | | 6 | | using System.ComponentModel.DataAnnotations.Schema; |
| | | 7 | | using Microsoft.EntityFrameworkCore; |
| | | 8 | | // Mostly Ai Generated - Start |
| | | 9 | | using Riok.Mapperly.Abstractions; |
| | | 10 | | |
| | | 11 | | // Mostly Ai Generated - End |
| | | 12 | | |
| | | 13 | | namespace Api.Files.Models; |
| | | 14 | | |
| | | 15 | | [Table("file_records")] |
| | | 16 | | [Index(nameof(OwnerId), nameof(FileKind))] |
| | | 17 | | // Mostly Ai Generated - Start |
| | | 18 | | public class FileRecord : IDbEntityMetadata |
| | | 19 | | // Mostly Ai Generated - End |
| | | 20 | | { |
| | 1 | 21 | | public static byte IdPostfix => (byte)IdPostfixes.FileRecord; |
| | | 22 | | |
| | | 23 | | [Key] |
| | | 24 | | public Guid Id { get; set; } |
| | | 25 | | public int RowVersion { get; set; } |
| | | 26 | | public NodaTime.Instant MetadataAddedAt { get; set; } |
| | | 27 | | public NodaTime.Instant MetadataUpdatedAt { get; set; } |
| | | 28 | | |
| | | 29 | | // Mostly Ai Generated - Start |
| | | 30 | | [MapperIgnore] |
| | | 31 | | // Mostly Ai Generated - End |
| | | 32 | | public Guid OwnerId { get; set; } |
| | | 33 | | |
| | | 34 | | public FileKind FileKind { get; set; } |
| | | 35 | | |
| | | 36 | | [ForeignKey(nameof(FileProviderBackendConfig))] |
| | | 37 | | public required Guid FileProviderBackendConfigId { get; set; } |
| | | 38 | | |
| | 1 | 39 | | public bool Uploaded { get; set; } = false; |
| | | 40 | | |
| | | 41 | | [MaxLength(1000)] |
| | | 42 | | public string? OriginalFileName { get; set; } |
| | | 43 | | public required string ContentType { get; set; } |
| | | 44 | | public long SizeBytes { get; set; } |
| | | 45 | | public required byte[] SHA256 { get; set; } |
| | | 46 | | |
| | | 47 | | //Navigation properties |
| | | 48 | | // Mostly Ai Generated - Start |
| | | 49 | | [MapperIgnore] |
| | | 50 | | // Mostly Ai Generated - End |
| | 1 | 51 | | public FileProviderBackendConfig FileProviderBackendConfig { get; set; } = null!; |
| | | 52 | | } |