photoprism/internal/form/photo.go
Michael Mayer 4efa383c57 API: Proof-of-concept for form handling
We don't want to directly write to models so that only selected fields can be changed and values can be validated for security reasons.

Signed-off-by: Michael Mayer <michael@liquidbytes.net>
2020-02-02 03:36:00 +01:00

46 lines
1.6 KiB
Go

package form
import (
"time"
"github.com/ulule/deepcopier"
)
// Photo represents a photo edit form.
type Photo struct {
TakenAt time.Time `json:"TakenAt"`
PhotoTitle string `json:"PhotoTitle"`
PhotoDescription string `json:"PhotoDescription"`
PhotoNotes string `json:"PhotoNotes"`
PhotoArtist string `json:"PhotoArtist"`
PhotoCopyright string `json:"PhotoCopyright"`
PhotoFavorite bool `json:"PhotoFavorite"`
PhotoPrivate bool `json:"PhotoPrivate"`
PhotoNSFW bool `json:"PhotoNSFW"`
PhotoStory bool `json:"PhotoStory"`
PhotoLat float64 `json:"PhotoLat"`
PhotoLng float64 `json:"PhotoLng"`
PhotoAltitude int `json:"PhotoAltitude"`
PhotoFocalLength int `json:"PhotoFocalLength"`
PhotoIso int `json:"PhotoIso"`
PhotoFNumber float64 `json:"PhotoFNumber"`
PhotoExposure string `json:"PhotoExposure"`
CameraID uint `json:"CameraID"`
LensID uint `json:"LensID"`
LocationID string `json:"LocationID"`
PlaceID string `json:"PlaceID"`
PhotoCountry string `json:"PhotoCountry"`
TimeZone string `json:"TimeZone"`
TakenAtLocal time.Time `json:"TakenAtLocal"`
ModifiedTitle bool `json:"ModifiedTitle"`
ModifiedDetails bool `json:"ModifiedDetails"`
ModifiedLocation bool `json:"ModifiedLocation"`
ModifiedDate bool `json:"ModifiedDate"`
}
func NewPhoto(m interface{}) (f Photo, err error) {
err = deepcopier.Copy(m).To(&f)
return f, err
}