31 lines
805 B
Go
31 lines
805 B
Go
package db
|
|
|
|
import (
|
|
"github.com/google/uuid"
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
"reichard.io/imagini/internal/models"
|
|
)
|
|
|
|
func (dbm *DBManager) CreateDevice (device models.Device) (models.Device, error) {
|
|
log.Info("[db] Creating device: ", device.Name)
|
|
device.RefreshKey = uuid.New().String()
|
|
err := dbm.db.Create(&device).Error
|
|
return device, err
|
|
}
|
|
|
|
func (dbm *DBManager) Device (device models.Device) (models.Device, error) {
|
|
var foundDevice models.Device
|
|
var count int64
|
|
err := dbm.db.Where(&device).First(&foundDevice).Count(&count).Error
|
|
return foundDevice, err
|
|
}
|
|
|
|
func (dbm *DBManager) DeleteDevice (user models.Device) error {
|
|
return nil
|
|
}
|
|
|
|
func (dbm *DBManager) UpdateRefreshToken (device models.Device, refreshToken string) error {
|
|
return nil
|
|
}
|