go-mongo/models/models_gen.go

256 lines
7.4 KiB
Go

// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package models
import (
"bytes"
"fmt"
"io"
"strconv"
"time"
"go.mongodb.org/mongo-driver/bson/primitive"
)
type Base interface {
IsBase()
GetID() primitive.ObjectID
GetCreatedAt() time.Time
GetUpdatedAt() time.Time
GetCreatedBy() *User
GetUpdatedBy() *User
GetOwner() *User
}
type Category struct {
ID primitive.ObjectID `json:"id,omitempty" bson:"_id,omitempty"`
Title []*Translated `json:"title" bson:"title,omitempty"`
Body []*Translated `json:"body,omitempty" bson:"body,omitempty"`
// #bson:ignore
Parent *Category `json:"parent,omitempty,omitempty" bson:"-"`
ParentID *primitive.ObjectID `json:"parentId,omitempty" bson:"parentid,omitempty"`
CreatedAt time.Time `json:"createdAt" bson:"createdat,omitempty"`
UpdatedAt time.Time `json:"updatedAt" bson:"updatedat,omitempty"`
// #bson:ignore
CreatedBy *User `json:"createdBy,omitempty" bson:"-"`
CreatedByID primitive.ObjectID `json:"createdById" bson:"createdbyid,omitempty"`
// #bson:ignore
UpdatedBy *User `json:"updatedBy,omitempty" bson:"-"`
UpdatedByID primitive.ObjectID `json:"updatedById" bson:"updatedbyid,omitempty"`
// #bson:ignore
Owner *User `json:"owner,omitempty,omitempty" bson:"-"`
OwnerID primitive.ObjectID `json:"ownerId" bson:"ownerid,omitempty"`
}
func (Category) IsBase() {}
func (this Category) GetID() primitive.ObjectID { return this.ID }
func (this Category) GetCreatedAt() time.Time { return this.CreatedAt }
func (this Category) GetUpdatedAt() time.Time { return this.UpdatedAt }
func (this Category) GetCreatedBy() *User { return this.CreatedBy }
func (this Category) GetUpdatedBy() *User { return this.UpdatedBy }
func (this Category) GetOwner() *User { return this.Owner }
type CreateCategoryInput struct {
Title []*TranslatedInput `json:"title" bson:"title,omitempty"`
Body []*TranslatedInput `json:"body,omitempty" bson:"body,omitempty"`
ParentID *primitive.ObjectID `json:"parentId,omitempty" bson:"parentid,omitempty"`
}
type CreateTodoInput struct {
Title string `json:"title" bson:"title,omitempty"`
Completed *bool `json:"completed,omitempty" bson:"completed,omitempty"`
}
type CreateUserInput struct {
Email *string `json:"email,omitempty" bson:"email,omitempty"`
Phone *string `json:"phone,omitempty" bson:"phone,omitempty"`
Status *Status `json:"status,omitempty" bson:"status,omitempty"`
Password string `json:"password" bson:"password,omitempty"`
}
type LoginInput struct {
Identity string `json:"identity" bson:"identity,omitempty"`
Password string `json:"password" bson:"password,omitempty"`
}
type LoginResponse struct {
User *User `json:"user" bson:"user,omitempty"`
AccessToken string `json:"accessToken" bson:"accesstoken,omitempty"`
RefreshToken string `json:"refreshToken" bson:"refreshtoken,omitempty"`
}
type Mutation struct {
}
type Query struct {
}
type Subscription struct {
}
type Todo struct {
ID primitive.ObjectID `json:"id,omitempty" bson:"_id,omitempty"`
Title *string `json:"title,omitempty" bson:"title,omitempty"`
Completed *bool `json:"completed,omitempty" bson:"completed,omitempty"`
CreatedAt time.Time `json:"createdAt" bson:"createdat,omitempty"`
UpdatedAt time.Time `json:"updatedAt" bson:"updatedat,omitempty"`
// #bson:ignore
CreatedBy *User `json:"createdBy,omitempty" bson:"-"`
CreatedByID primitive.ObjectID `json:"createdById" bson:"createdbyid,omitempty"`
// #bson:ignore
UpdatedBy *User `json:"updatedBy,omitempty" bson:"-"`
UpdatedByID primitive.ObjectID `json:"updatedById" bson:"updatedbyid,omitempty"`
// #bson:ignore
Owner *User `json:"owner,omitempty,omitempty" bson:"-"`
OwnerID primitive.ObjectID `json:"ownerId" bson:"ownerid,omitempty"`
}
func (Todo) IsBase() {}
func (this Todo) GetID() primitive.ObjectID { return this.ID }
func (this Todo) GetCreatedAt() time.Time { return this.CreatedAt }
func (this Todo) GetUpdatedAt() time.Time { return this.UpdatedAt }
func (this Todo) GetCreatedBy() *User { return this.CreatedBy }
func (this Todo) GetUpdatedBy() *User { return this.UpdatedBy }
func (this Todo) GetOwner() *User { return this.Owner }
type Translated struct {
Value string `json:"value" bson:"value,omitempty"`
IsPrimary bool `json:"isPrimary" bson:"isprimary,omitempty"`
Language string `json:"language" bson:"language,omitempty"`
}
type TranslatedInput struct {
Value string `json:"value" bson:"value,omitempty"`
IsPrimary bool `json:"isPrimary" bson:"isprimary,omitempty"`
Language string `json:"language" bson:"language,omitempty"`
}
type User struct {
ID primitive.ObjectID `json:"id,omitempty" bson:"_id,omitempty"`
Phone *string `json:"phone,omitempty" bson:"phone,omitempty"`
Email *string `json:"email,omitempty" bson:"email,omitempty"`
Type *string `json:"type,omitempty" bson:"type,omitempty"`
Status *string `json:"status,omitempty" bson:"status,omitempty"`
Verified *bool `json:"verified,omitempty" bson:"verified,omitempty"`
Password *string `json:"-" bson:"password,omitempty"`
Token *string `json:"-" bson:"token,omitempty"`
}
type Role string
const (
RoleAdmin Role = "ADMIN"
RoleUser Role = "USER"
)
var AllRole = []Role{
RoleAdmin,
RoleUser,
}
func (e Role) IsValid() bool {
switch e {
case RoleAdmin, RoleUser:
return true
}
return false
}
func (e Role) String() string {
return string(e)
}
func (e *Role) UnmarshalGQL(v any) error {
str, ok := v.(string)
if !ok {
return fmt.Errorf("enums must be strings")
}
*e = Role(str)
if !e.IsValid() {
return fmt.Errorf("%s is not a valid Role", str)
}
return nil
}
func (e Role) MarshalGQL(w io.Writer) {
fmt.Fprint(w, strconv.Quote(e.String()))
}
func (e *Role) UnmarshalJSON(b []byte) error {
s, err := strconv.Unquote(string(b))
if err != nil {
return err
}
return e.UnmarshalGQL(s)
}
func (e Role) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
e.MarshalGQL(&buf)
return buf.Bytes(), nil
}
type Status string
const (
StatusActive Status = "Active"
StatusDeactivated Status = "Deactivated"
StatusBlocked Status = "Blocked"
StatusDraft Status = "Draft"
StatusPending Status = "Pending"
StatusClosed Status = "Closed"
)
var AllStatus = []Status{
StatusActive,
StatusDeactivated,
StatusBlocked,
StatusDraft,
StatusPending,
StatusClosed,
}
func (e Status) IsValid() bool {
switch e {
case StatusActive, StatusDeactivated, StatusBlocked, StatusDraft, StatusPending, StatusClosed:
return true
}
return false
}
func (e Status) String() string {
return string(e)
}
func (e *Status) UnmarshalGQL(v any) error {
str, ok := v.(string)
if !ok {
return fmt.Errorf("enums must be strings")
}
*e = Status(str)
if !e.IsValid() {
return fmt.Errorf("%s is not a valid Status", str)
}
return nil
}
func (e Status) MarshalGQL(w io.Writer) {
fmt.Fprint(w, strconv.Quote(e.String()))
}
func (e *Status) UnmarshalJSON(b []byte) error {
s, err := strconv.Unquote(string(b))
if err != nil {
return err
}
return e.UnmarshalGQL(s)
}
func (e Status) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
e.MarshalGQL(&buf)
return buf.Bytes(), nil
}