mirror of
https://github.com/serty2005/rmser.git
synced 2026-02-05 03:12:34 -06:00
добавил архив фото, откуда можно удалить и посмотреть
This commit is contained in:
54
internal/domain/photos/entity.go
Normal file
54
internal/domain/photos/entity.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package photos
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type PhotoStatus string
|
||||
|
||||
const (
|
||||
PhotoStatusOrphan PhotoStatus = "ORPHAN" // Нет связанного черновика
|
||||
PhotoStatusHasDraft PhotoStatus = "HAS_DRAFT" // Есть черновик
|
||||
PhotoStatusHasInvoice PhotoStatus = "HAS_INVOICE" // Есть накладная в iiko
|
||||
)
|
||||
|
||||
// ReceiptPhoto - фото чека
|
||||
type ReceiptPhoto struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
|
||||
RMSServerID uuid.UUID `gorm:"type:uuid;not null;index" json:"rms_server_id"`
|
||||
UploadedBy uuid.UUID `gorm:"type:uuid;not null" json:"uploaded_by"` // User ID
|
||||
|
||||
FilePath string `gorm:"type:varchar(500);not null" json:"file_path"`
|
||||
FileURL string `gorm:"type:varchar(500);not null" json:"file_url"` // Public URL
|
||||
FileName string `gorm:"type:varchar(255)" json:"file_name"`
|
||||
FileSize int64 `json:"file_size"`
|
||||
|
||||
// Связи (указатели, так как могут быть null)
|
||||
DraftID *uuid.UUID `gorm:"type:uuid;index" json:"draft_id"`
|
||||
InvoiceID *uuid.UUID `gorm:"type:uuid;index" json:"invoice_id"` // RMS Invoice ID (когда накладная создана)
|
||||
|
||||
// Метаданные OCR (чтобы можно было пересоздать черновик без повторного запроса к нейросети)
|
||||
OCRSource string `gorm:"type:varchar(50)" json:"ocr_source"` // qr_api, yandex, etc.
|
||||
OCRRawText string `gorm:"type:text" json:"ocr_raw_text"`
|
||||
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// Repository interface
|
||||
type Repository interface {
|
||||
Create(photo *ReceiptPhoto) error
|
||||
GetByID(id uuid.UUID) (*ReceiptPhoto, error)
|
||||
// GetByServerID возвращает фото с пагинацией
|
||||
GetByServerID(serverID uuid.UUID, page, limit int) ([]ReceiptPhoto, int64, error)
|
||||
|
||||
UpdateDraftLink(photoID uuid.UUID, draftID *uuid.UUID) error
|
||||
UpdateInvoiceLink(photoID uuid.UUID, invoiceID *uuid.UUID) error
|
||||
|
||||
// ClearDraftLinkByDraftID очищает ссылку на черновик (когда черновик удаляется)
|
||||
ClearDraftLinkByDraftID(draftID uuid.UUID) error
|
||||
|
||||
Delete(id uuid.UUID) error
|
||||
}
|
||||
Reference in New Issue
Block a user