mirror of
https://github.com/photoprism/photoprism.git
synced 2026-07-18 00:59:38 +00:00
Mirror the lens make/model editing surface for cameras: entity UpdateMakeModel/SaveForm, form validation, query, search, the GET/PUT /api/v1/cameras endpoints, and the cameras CLI command, plus a cameras ACL resource and scope. Also tidy the lens surface for parity: self-validating SaveForm, empty make/model guard, X-Count search header, service-role grant, the empty-id/slug docs, and order cameras before lenses everywhere.
35 lines
606 B
Go
35 lines
606 B
Go
package query
|
|
|
|
import (
|
|
"github.com/photoprism/photoprism/internal/entity"
|
|
)
|
|
|
|
// FindCameraBySlug returns an existing entity if exists.
|
|
func FindCameraBySlug(slug string) *entity.Camera {
|
|
if slug == "" {
|
|
return nil
|
|
}
|
|
|
|
c := entity.Camera{}
|
|
|
|
if err := Db().Where("camera_slug = ?", slug).First(&c).Error; err != nil {
|
|
return nil
|
|
}
|
|
|
|
return &c
|
|
}
|
|
|
|
// FindCameraByID returns an existing entity if exists.
|
|
func FindCameraByID(id uint) *entity.Camera {
|
|
if id == 0 {
|
|
return nil
|
|
}
|
|
|
|
c := entity.Camera{}
|
|
|
|
if err := Db().Where("id = ?", id).First(&c).Error; err != nil {
|
|
return nil
|
|
}
|
|
|
|
return &c
|
|
}
|