WIP
This commit is contained in:
22
internal/models/api.go
Normal file
22
internal/models/api.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package models
|
||||
|
||||
type APICredentials struct {
|
||||
User string `json:"user"`
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
type APIMeta struct {
|
||||
Count int `json:"count"`
|
||||
Page int `json:"page"`
|
||||
}
|
||||
|
||||
type APIError struct {
|
||||
Message string `json:"message"`
|
||||
Code int `json:"code"`
|
||||
}
|
||||
|
||||
type APIResponse struct {
|
||||
Data []interface{} `json:"data"`
|
||||
Meta APIMeta `json:"meta"`
|
||||
Error APIError `json:"error"`
|
||||
}
|
||||
45
internal/models/db.go
Normal file
45
internal/models/db.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
type ServerSetting struct {
|
||||
gorm.Model
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Value string `json:"value"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
gorm.Model
|
||||
Email string `json:"email" gorm:"unique;not null"`
|
||||
Username string `json:"username" gorm:"unique;not null"`
|
||||
FirstName string `json:"first_name"`
|
||||
LastName string `json:"last_name"`
|
||||
AuthType string `json:"auth_type"`
|
||||
HashedPassword string `json:"hashed_password"`
|
||||
}
|
||||
|
||||
type MediaItem struct {
|
||||
gorm.Model
|
||||
User User `json:"user" gorm:"ForeignKey:ID"`
|
||||
EXIFDate time.Time `json:"exif_date"`
|
||||
Latitude string `json:"latitude"`
|
||||
Longitude string `json:"longitude"`
|
||||
MediaType uint `json:"media_type"`
|
||||
RelPath string `json:"rel_path"`
|
||||
Tags []Tag `json:"tags" gorm:"many2many:media_tags;"`
|
||||
Albums []Album `json:"albums" gorm:"many2many:media_albums;"`
|
||||
}
|
||||
|
||||
type Tag struct {
|
||||
gorm.Model
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type Album struct {
|
||||
gorm.Model
|
||||
Name string `json:"name"`
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
type ServerSetting struct {
|
||||
gorm.Model
|
||||
Name string
|
||||
Description string
|
||||
Value string
|
||||
}
|
||||
|
||||
type User struct {
|
||||
gorm.Model
|
||||
Email string `gorm:"unique;not null"`
|
||||
Username string `gorm:"unique;not null"`
|
||||
FirstName string
|
||||
LastName string
|
||||
AuthType string
|
||||
HashedPassword string
|
||||
}
|
||||
|
||||
type MediaItem struct {
|
||||
gorm.Model
|
||||
User User `gorm:"ForeignKey:ID"`
|
||||
EXIFDate time.Time
|
||||
Latitude string
|
||||
Longitude string
|
||||
MediaType uint
|
||||
RelPath string
|
||||
Tags []Tag `gorm:"many2many:media_tags;"`
|
||||
Albums []Album `gorm:"many2many:media_albums;"`
|
||||
}
|
||||
|
||||
type Tag struct {
|
||||
gorm.Model
|
||||
Name string
|
||||
}
|
||||
|
||||
type Album struct {
|
||||
gorm.Model
|
||||
Name string
|
||||
}
|
||||
Reference in New Issue
Block a user