33 lines
437 B
Go
33 lines
437 B
Go
package entities
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
const ImagesTable = "images"
|
|
|
|
type Images struct {
|
|
Id uuid.UUID `db:"id"`
|
|
Path string `db:"path"`
|
|
}
|
|
|
|
func CreateImage(path string) (image Images, err error) {
|
|
image = Images{
|
|
Id: uuid.New(),
|
|
Path: path,
|
|
}
|
|
|
|
err = image.Validate()
|
|
|
|
return
|
|
}
|
|
|
|
func (i *Images) Validate() error {
|
|
if i.Path == "" {
|
|
return errors.New("Empty image.path")
|
|
}
|
|
|
|
return nil
|
|
}
|