Moved gorm models to separate package

This commit is contained in:
Michael Mayer 2018-09-16 19:09:40 +02:00
parent 3c7b5a39c2
commit d925d59e67
14 changed files with 36 additions and 27 deletions

View File

@ -13,7 +13,7 @@ PhotoPrism
[issues]: https://github.com/photoprism/photoprism/issues
[ci]: https://travis-ci.org/photoprism/photoprism
PhotoPrism is a server-based application for automatically tagging, searching and organizing large amounts of JPEG and RAW files.
PhotoPrism is a server-based application for automatically tagging, searching and organizing digital photo collections.
It is functionally similar to popular cloud services such as [Flickr](https://www.flickr.com/) or [Google Photos](https://photos.google.com/).
Originals are stored in the file system in a structured way for easy backup and reliable long-term accessibility.

View File

@ -1,4 +1,4 @@
package photoprism
package models
import (
"github.com/jinzhu/gorm"

View File

@ -1,4 +1,4 @@
package photoprism
package models
import (
"github.com/gosimple/slug"

View File

@ -1,4 +1,4 @@
package photoprism
package models
import (
"github.com/jinzhu/gorm"

View File

@ -0,0 +1,22 @@
package models
import (
"github.com/jinzhu/gorm"
)
type Location struct {
gorm.Model
LocDisplayName string
LocLat float64
LocLong float64
LocCategory string
LocType string
LocName string
LocCity string
LocPostcode string
LocCounty string
LocState string
LocCountry string
LocCountryCode string
LocFavorite bool
}

View File

@ -1,4 +1,4 @@
package photoprism
package models
import (
"github.com/jinzhu/gorm"

View File

@ -1,4 +1,4 @@
package photoprism
package models
import (
"github.com/gosimple/slug"

View File

@ -7,6 +7,7 @@ import (
_ "github.com/jinzhu/gorm/dialects/postgres"
_ "github.com/jinzhu/gorm/dialects/sqlite"
"github.com/kylelemons/go-gypsy/yaml"
. "github.com/photoprism/photoprism/internal/models"
"github.com/urfave/cli"
"log"
"os"

View File

@ -3,6 +3,7 @@ package photoprism
import (
"fmt"
"github.com/jinzhu/gorm"
. "github.com/photoprism/photoprism/internal/models"
"log"
"os"
"path/filepath"

View File

@ -5,6 +5,7 @@ import (
"fmt"
"github.com/brett-lempereur/ish"
"github.com/djherbis/times"
. "github.com/photoprism/photoprism/internal/models"
"github.com/pkg/errors"
"github.com/steakknife/hamming"
"image"

View File

@ -2,30 +2,13 @@ package photoprism
import (
"encoding/json"
"errors"
"fmt"
"github.com/jinzhu/gorm"
. "github.com/photoprism/photoprism/internal/models"
"github.com/pkg/errors"
"net/http"
"strconv"
)
type Location struct {
gorm.Model
LocDisplayName string
LocLat float64
LocLong float64
LocCategory string
LocType string
LocName string
LocCity string
LocPostcode string
LocCounty string
LocState string
LocCountry string
LocCountryCode string
LocFavorite bool
}
type OpenstreetmapAddress struct {
Town string `json:"town"`
City string `json:"city"`

View File

@ -2,7 +2,8 @@ package photoprism
import (
"github.com/jinzhu/gorm"
"github.com/photoprism/photoprism/internal/forms"
. "github.com/photoprism/photoprism/internal/forms"
. "github.com/photoprism/photoprism/internal/models"
"strings"
"time"
)
@ -76,7 +77,7 @@ func NewSearch(originalsPath string, db *gorm.DB) *Search {
return instance
}
func (s *Search) Photos(form forms.PhotoSearchForm) ([]PhotoSearchResult, int, error) {
func (s *Search) Photos(form PhotoSearchForm) ([]PhotoSearchResult, int, error) {
q := s.db.NewScope(nil).DB()
q = q.Table("photos").
Select(`SQL_CALC_FOUND_ROWS photos.*,