@@ -0,0 +1,44 @@
|
||||
package storage
|
||||
|
||||
import "time"
|
||||
|
||||
// MaxImageSize is the largest image payload accepted by storage, in bytes.
|
||||
const MaxImageSize = 10 << 20
|
||||
|
||||
// ImageModelInterface persists garden-owned image data and assignment history.
|
||||
type ImageModelInterface interface {
|
||||
Insert(image Image) (Image, error)
|
||||
Get(gardenID, id int) (Image, error)
|
||||
GetAllForGarden(gardenID int, filter ImageFilter) ([]Image, error)
|
||||
CountForGarden(gardenID int) (int, error)
|
||||
RecordAssignment(change ImageAssignment) error
|
||||
}
|
||||
|
||||
// Image is a binary image stored in a garden's reusable media library.
|
||||
type Image struct {
|
||||
ID int `json:"id"`
|
||||
GardenID int `json:"garden_id"`
|
||||
FileName string `json:"file_name"`
|
||||
MediaType string `json:"media_type"`
|
||||
Size int64 `json:"size"`
|
||||
Source string `json:"source"`
|
||||
CreatedBy int `json:"created_by"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Data []byte `json:"-"`
|
||||
}
|
||||
|
||||
// ImageFilter restricts image-library queries by filename or media type.
|
||||
type ImageFilter struct {
|
||||
Source string
|
||||
Query string
|
||||
}
|
||||
|
||||
// ImageAssignment records an image change on a garden entity.
|
||||
type ImageAssignment struct {
|
||||
GardenID int
|
||||
EntityType string
|
||||
EntityID int
|
||||
PreviousImageID *int
|
||||
ImageID *int
|
||||
ChangedBy int
|
||||
}
|
||||
Reference in New Issue
Block a user