models

package
v0.0.0-...-d92ad30 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2022 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalcNewSize

func CalcNewSize(width, height int, ratio float64) (int, int)

func CreateNewFileName

func CreateNewFileName(fileName string, w, h int) string

func CreateUploadPath

func CreateUploadPath(
	uploadPrefix, accountDir, fileName, date string) string

func DeleteHandler

func DeleteHandler(data Deleter, db *sql.DB) (err error)

func DownloadFile

func DownloadFile(url, filePath string) (err error)

func ForeignKeyUpdateHandler

func ForeignKeyUpdateHandler(data ForeignKeyUpdater, db *sql.DB) (err error)

func GetFileName

func GetFileName(url string) (string, string)

func JoinCollectionContentUpsert

func JoinCollectionContentUpsert(db *sql.DB, svUserId, collectionId, contentId string) (err error)

func LoadValidateHandler

func LoadValidateHandler(data LoaderValidator, fileBuffer *[]byte) (err error)

func Md5Hasher

func Md5Hasher(data []string) (out string)

func PreProcessHandler

func PreProcessHandler(data PreProcessor, accountId string, db *sql.DB) (err error)

func PutFile

func PutFile(
	c context.Context, api S3PutObjectAPI, input *s3.PutObjectInput) (
	*s3.PutObjectOutput, error)

func RelatedTableUpsertHandler

func RelatedTableUpsertHandler(data RelatedTableUpserter, accountId string, db *sql.DB) (err error)

func ResizeBaseImage

func ResizeBaseImage(decodedImg image.Image, w, h int) image.Image

func ResizedImgHandler

func ResizedImgHandler(i resizedImgHandler, accountId string, db *sql.DB) (err error)

func UpsertHandler

func UpsertHandler(data Upserter, accountId string, db *sql.DB) (err error)

func ValidateUrl

func ValidateUrl(url string) bool

Types

type Account

type Account struct {
	Id        string `json:"id" validate:"required,uuid4"`
	ParentId  string `json:"parentId" validate:"omitempty,uuid4"`
	Auth      string `json:"auth" validate:"required,uuid4"`
	Key       string `json:"key" validate:"required,uuid4"`
	Username  string `json:"username" validate:"omitempty,gte=8,lte=100"`
	Firstname string `json:"firstname" validate:"omitempty,lte=100"`
	Lastname  string `json:"lastname" validate:"omitempty,lte=100"`
	Nickname  string `json:"nickname" validate:"omitempty,lte=100"`
	Document  string
}

type AccountNodes

type AccountNodes struct {
	Nodes []*Account `json:"accountNodes" validate:"dive"`
	Gjson gjson.Result
}

func (*AccountNodes) Delete

func (s *AccountNodes) Delete(db *sql.DB) (err error)

func (*AccountNodes) ForeignKeyUpdate

func (s *AccountNodes) ForeignKeyUpdate(db *sql.DB) (err error)

func (*AccountNodes) Load

func (s *AccountNodes) Load(fileBuffer *[]byte) (err error)

func (*AccountNodes) RelatedTableUpsert

func (s *AccountNodes) RelatedTableUpsert(accountId string, db *sql.DB) (err error)

func (*AccountNodes) Upsert

func (s *AccountNodes) Upsert(accountId string, db *sql.DB) (err error)

func (*AccountNodes) Validate

func (s *AccountNodes) Validate() (err error)

type BaseData

type BaseData struct {
	Id        string `json:"id" validate:"required,uuid4"`
	ParentId  string `json:"parentId" validate:"omitempty,uuid4"`
	Type      string `json:"type" validate:"omitempty,lte=20"`
	AccountId string
	Document  string
}

type BaseIdData

type BaseIdData struct {
	Id         string `json:"id" validate:"uuid4"`
	Attributes string `json:"attributes" validate:"omitempty,json"`
}

type Collection

type Collection struct {
	BaseData
	AllIdNodes
}

type CollectionIdNodes

type CollectionIdNodes struct {
	Nodes []CollectionIds `json:"collectionIdNodes" validate:"dive,omitempty"`
	// contains filtered or unexported fields
}

func (*CollectionIdNodes) Upsert

func (s *CollectionIdNodes) Upsert(accountId string, db *sql.DB) (err error)

type CollectionIds

type CollectionIds struct {
	BaseIdData
}

type CollectionNodes

type CollectionNodes struct {
	Nodes []*Collection `json:"collectionNodes" validate:"dive"`
	Gjson gjson.Result
}

func (*CollectionNodes) Delete

func (s *CollectionNodes) Delete(db *sql.DB) (err error)

func (*CollectionNodes) ForeignKeyUpdate

func (s *CollectionNodes) ForeignKeyUpdate(db *sql.DB) (err error)

func (*CollectionNodes) Load

func (s *CollectionNodes) Load(fileBuffer *[]byte) (err error)

func (*CollectionNodes) RelatedTableUpsert

func (s *CollectionNodes) RelatedTableUpsert(accountId string, db *sql.DB) (err error)

func (*CollectionNodes) Upsert

func (s *CollectionNodes) Upsert(accountId string, db *sql.DB) (err error)

func (*CollectionNodes) Validate

func (s *CollectionNodes) Validate() (err error)

type Content

type Content struct {
	BaseData
	AllIdNodes
}

type ContentIdNodes

type ContentIdNodes struct {
	Nodes []ContentIds `json:"contentIdNodes" validate:"dive,omitempty"`
	// contains filtered or unexported fields
}

func (*ContentIdNodes) Upsert

func (s *ContentIdNodes) Upsert(accountId string, db *sql.DB) (err error)

type ContentIds

type ContentIds struct {
	BaseIdData
}

type ContentNodes

type ContentNodes struct {
	Nodes []*Content `json:"contentNodes" validate:"dive"`
	Gjson gjson.Result
}

func (*ContentNodes) Delete

func (s *ContentNodes) Delete(db *sql.DB) (err error)

func (*ContentNodes) ForeignKeyUpdate

func (s *ContentNodes) ForeignKeyUpdate(db *sql.DB) (err error)

func (*ContentNodes) Load

func (s *ContentNodes) Load(fileBuffer *[]byte) (err error)

func (*ContentNodes) RelatedTableUpsert

func (s *ContentNodes) RelatedTableUpsert(accountId string, db *sql.DB) (err error)

func (*ContentNodes) Upsert

func (s *ContentNodes) Upsert(accountId string, db *sql.DB) (err error)

func (*ContentNodes) Validate

func (s *ContentNodes) Validate() (err error)

type Deleter

type Deleter interface {
	Delete(db *sql.DB) (err error)
}

type ForeignKeyUpdater

type ForeignKeyUpdater interface {
	ForeignKeyUpdate(db *sql.DB) (err error)
}

type Image

type Image struct {
	// Image struct differs from base data, it creates the id
	// from Md5Hasher of account_id, url. Note: the image.Url is required
	Id        string `json:"id" validate:"omitempty"`
	ParentId  string `json:"parentId" validate:"omitempty,uuid4"`
	Type      string `json:"type" validate:"omitempty,lte=20"`
	AccountId string
	Document  string
	AllIdNodes
	ImageProcessingInfo
}

func (*Image) Construct

func (s *Image) Construct(accountId string)

func (*Image) Download

func (s *Image) Download() (err error)

func (*Image) RecordValidate

func (s *Image) RecordValidate(record_id string, db *sql.DB) (exists int8, err error)

func (*Image) RemoveTempFile

func (s *Image) RemoveTempFile() (err error)

func (*Image) Resize

func (s *Image) Resize() (err error)

func (*Image) ResizedImageUpsert

func (s *Image) ResizedImageUpsert(accountId string, db *sql.DB) (err error)

func (*Image) UploadToSpaces

func (s *Image) UploadToSpaces() (err error)

type ImageIdNodes

type ImageIdNodes struct {
	Nodes []ImageIds `json:"imageIdNodes" validate:"dive,omitempty"`
	// contains filtered or unexported fields
}

func (*ImageIdNodes) Upsert

func (s *ImageIdNodes) Upsert(accountId string, db *sql.DB) (err error)

type ImageIds

type ImageIds struct {
	Id         string `json:"id" validate:"omitempty"`
	Attributes string `json:"attributes" validate:"omitempty,json"`
}

type ImageNodes

type ImageNodes struct {
	Nodes []*Image `json:"imageNodes" validate:"dive"`
	Gjson gjson.Result
}

func (*ImageNodes) ForeignKeyUpdate

func (s *ImageNodes) ForeignKeyUpdate(db *sql.DB) (err error)

func (*ImageNodes) Load

func (s *ImageNodes) Load(fileBuffer *[]byte) (err error)

func (*ImageNodes) PreProcess

func (s *ImageNodes) PreProcess(accountId string, db *sql.DB) (err error)

func (*ImageNodes) RelatedTableUpsert

func (s *ImageNodes) RelatedTableUpsert(accountId string, db *sql.DB) (err error)

func (*ImageNodes) Upsert

func (s *ImageNodes) Upsert(accountId string, db *sql.DB) (err error)

func (*ImageNodes) Validate

func (s *ImageNodes) Validate() (err error)

type ImageProcessingInfo

type ImageProcessingInfo struct {
	Url            string `json:"url" validate:"required,url"`
	Process        uint8  `json:"process" validate:"omitempty,number,oneof=0 1"`
	TempFileDir    string `json:"-"` // constructed :: location to download temp files
	UploadPrefix   string `json:"-"` // constructed :: eg. "media"
	VanityUrl      string `json:"-"` // constructed
	AccountDir     string `json:"-"` // constructed :: eg. "98c56d78fe3a"
	Date           string `json:"-"` // constructed :: eg. "2020-05-04"
	DoBucket       string `json:"-"` // constructed
	DoCacheControl string `json:"-"` // constructed eg. "max-age=60"
	DoContentType  string `json:"-"` // constructed eg. "image/webp"
	DoEndpointUrl  string `json:"-"` // constructed
	DoAccessKey    string `json:"-"` // constructed
	DoSecret       string `json:"-"` // constructed
	DoRegionName   string `json:"-"` // constructed
	BaseFileName   string `json:"-"`

	ImgSizes      []ImgSize      `json:"-"`
	ResizedImages []ResizedImage `json:"-"`
	// contains filtered or unexported fields
}

type ImgSize

type ImgSize struct {
	// contains filtered or unexported fields
}

type Item

type Item struct {
	BaseData
	AllIdNodes
	PlaceId string `json:"placeId" validate:"omitempty"`
}

type ItemIdNodes

type ItemIdNodes struct {
	Nodes []ItemIds `json:"itemIdNodes" validate:"dive,omitempty"`
	// contains filtered or unexported fields
}

func (*ItemIdNodes) Upsert

func (s *ItemIdNodes) Upsert(accountId string, db *sql.DB) (err error)

type ItemIds

type ItemIds struct {
	BaseIdData
}

type ItemNodes

type ItemNodes struct {
	Nodes []*Item `json:"itemNodes" validate:"dive"`
	Gjson gjson.Result
}

func (*ItemNodes) Delete

func (s *ItemNodes) Delete(db *sql.DB) (err error)

func (*ItemNodes) ForeignKeyUpdate

func (s *ItemNodes) ForeignKeyUpdate(db *sql.DB) (err error)

func (*ItemNodes) Load

func (s *ItemNodes) Load(fileBuffer *[]byte) (err error)

func (*ItemNodes) RelatedTableUpsert

func (s *ItemNodes) RelatedTableUpsert(accountId string, db *sql.DB) (err error)

func (*ItemNodes) Upsert

func (s *ItemNodes) Upsert(accountId string, db *sql.DB) (err error)

func (*ItemNodes) Validate

func (s *ItemNodes) Validate() (err error)

type JoinTable

type JoinTable struct {
	// contains filtered or unexported fields
}

func NewJoinTable

func NewJoinTable(ascCol, ascId, nodeCol, nodeId, nodeAttr string) *JoinTable

func (*JoinTable) Upsert

func (s *JoinTable) Upsert(accountId string, db *sql.DB) (err error)

type LoaderValidator

type LoaderValidator interface {
	// contains filtered or unexported methods
}

type Person

type Person struct {
	BaseData
	AllIdNodes
	PlaceId string `json:"placeId" validate:"omitempty,uuid4"`
}

type PersonIdNodes

type PersonIdNodes struct {
	Nodes []PersonIds `json:"personIdNodes" validate:"dive,omitempty"`
	// contains filtered or unexported fields
}

func (*PersonIdNodes) Upsert

func (s *PersonIdNodes) Upsert(accountId string, db *sql.DB) (err error)

type PersonIds

type PersonIds struct {
	BaseIdData
}

type PersonNodes

type PersonNodes struct {
	Nodes []*Person `json:"personNodes" validate:"dive"`
	Gjson gjson.Result
}

func (*PersonNodes) Delete

func (s *PersonNodes) Delete(db *sql.DB) (err error)

func (*PersonNodes) ForeignKeyUpdate

func (s *PersonNodes) ForeignKeyUpdate(db *sql.DB) (err error)

func (*PersonNodes) Load

func (s *PersonNodes) Load(fileBuffer *[]byte) (err error)

func (*PersonNodes) RelatedTableUpsert

func (s *PersonNodes) RelatedTableUpsert(accountId string, db *sql.DB) (err error)

func (*PersonNodes) Upsert

func (s *PersonNodes) Upsert(accountId string, db *sql.DB) (err error)

func (*PersonNodes) Validate

func (s *PersonNodes) Validate() (err error)

type Place

type Place struct {
	BaseData
	AllIdNodes
}

type PlaceIdNodes

type PlaceIdNodes struct {
	Nodes []PlaceIds `json:"placeIdNodes" validate:"dive,omitempty"`
	// contains filtered or unexported fields
}

func (*PlaceIdNodes) Upsert

func (s *PlaceIdNodes) Upsert(accountId string, db *sql.DB) (err error)

type PlaceIds

type PlaceIds struct {
	BaseIdData
}

type PlaceNodes

type PlaceNodes struct {
	Nodes []*Place `json:"placeNodes" validate:"dive"`
	Gjson gjson.Result
}

func (*PlaceNodes) Delete

func (s *PlaceNodes) Delete(db *sql.DB) (err error)

func (*PlaceNodes) ForeignKeyUpdate

func (s *PlaceNodes) ForeignKeyUpdate(db *sql.DB) (err error)

func (*PlaceNodes) Load

func (s *PlaceNodes) Load(fileBuffer *[]byte) (err error)

func (*PlaceNodes) RelatedTableUpsert

func (s *PlaceNodes) RelatedTableUpsert(accountId string, db *sql.DB) (err error)

func (*PlaceNodes) Upsert

func (s *PlaceNodes) Upsert(accountId string, db *sql.DB) (err error)

func (*PlaceNodes) Validate

func (s *PlaceNodes) Validate() (err error)

type PreProcessor

type PreProcessor interface {
	PreProcess(accountId string, db *sql.DB) (err error)
}

type RelatedTableUpserter

type RelatedTableUpserter interface {
	RelatedTableUpsert(accountId string, db *sql.DB) (err error)
}

type ResizedImage

type ResizedImage struct {
	// contains filtered or unexported fields
}

type S3PutObjectAPI

type S3PutObjectAPI interface {
	PutObject(ctx context.Context,
		params *s3.PutObjectInput,
		optFns ...func(*s3.Options)) (*s3.PutObjectOutput, error)
}

S3PutObjectAPI defines the interface for the PutObject function. We use this interface to test the function using a mocked service.

type Upserter

type Upserter interface {
	Upsert(accountId string, db *sql.DB) (err error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL