32 lines
710 B
Go
32 lines
710 B
Go
package dao
|
|
|
|
import (
|
|
"github.com/nose7en/ToyBoomServer/defs"
|
|
"github.com/nose7en/ToyBoomServer/storage"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type Query interface {
|
|
GetUserByAppleUserID(appleUserID string) (defs.UserGettable, error)
|
|
GetUserByID(userID int64) (defs.UserGettable, error)
|
|
}
|
|
|
|
type Mutation interface {
|
|
FirstOrCreateUser(user defs.UserGettable) (defs.UserGettable, error)
|
|
}
|
|
|
|
var _ Query = (*queryImpl)(nil)
|
|
var _ Mutation = (*mutationImpl)(nil)
|
|
|
|
type queryImpl struct{ db *gorm.DB }
|
|
|
|
type mutationImpl struct{ db *gorm.DB }
|
|
|
|
func NewQuery() Query {
|
|
return &queryImpl{db: storage.GetDBManager().GetDefaultDB()}
|
|
}
|
|
|
|
func NewMutation() Mutation {
|
|
return &mutationImpl{db: storage.GetDBManager().GetDefaultDB()}
|
|
}
|