Files
rmser/internal/domain/photos/entity.go

55 lines
2.2 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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
}