mirror of
https://github.com/photoprism/photoprism.git
synced 2026-07-21 01:06:10 +00:00
Adds the ability to override a lens's Make/Model (e.g. fixing Pentax lenses that ExifTool decodes as `4 38`) via a new photoprism lenses update CLI command and a `PUT /api/v1/lenses/:id endpoint`, plus a `GET /api/v1/lenses` search endpoint, a new lenses ACL resource, and an lenses ls list command.
35 lines
588 B
Go
35 lines
588 B
Go
package query
|
|
|
|
import (
|
|
"github.com/photoprism/photoprism/internal/entity"
|
|
)
|
|
|
|
// FindLensBySlug returns an existing entity if exists.
|
|
func FindLensBySlug(slug string) *entity.Lens {
|
|
if slug == "" {
|
|
return nil
|
|
}
|
|
|
|
l := entity.Lens{}
|
|
|
|
if err := Db().Where("lens_slug = ?", slug).First(&l).Error; err != nil {
|
|
return nil
|
|
}
|
|
|
|
return &l
|
|
}
|
|
|
|
// FindLensByID returns an existing entity if exists.
|
|
func FindLensByID(id uint) *entity.Lens {
|
|
if id == 0 {
|
|
return nil
|
|
}
|
|
|
|
l := entity.Lens{}
|
|
|
|
if err := Db().Where("id = ?", id).First(&l).Error; err != nil {
|
|
return nil
|
|
}
|
|
|
|
return &l
|
|
}
|