models

package
v0.0.0-...-04c0be3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidEmail

func IsValidEmail(email string) bool

Checks if an email is valid

func MatchesHash

func MatchesHash(password, hash string) bool

Check if a password matches a hash

Types

type AuthCredentials

type AuthCredentials struct {
	Email    string `json:"email" validate:"required"`
	Password string `json:"password" validate:"required"`
	Name     string `json:"name"`
	Username string `json:"username"`
}

type AuthRepository

type AuthRepository interface {
	RegisterUser(ctx context.Context, registerData *AuthCredentials) (*User, error)
	GetUser(ctx context.Context, query interface{}, args ...interface{}) (*User, error)
}

type AuthService

type AuthService interface {
	Login(ctx context.Context, loginData *AuthCredentials) (string, *User, error)
	Register(ctx context.Context, registerData *AuthCredentials) (string, *User, error)
}

type Character

type Character struct {
	ID               uuid.UUID     `json:"id" gorm:"type:uuid;primaryKey;default:uuid_generate_v4()"`
	Name             string        `json:"name" gorm:"type:varchar(255)"`
	Description      string        `json:"description" gorm:"type:text"`
	FruitMultipliers utils.JSONMap `json:"fruit_multipliers" gorm:"type:jsonb"` // JSONB for PostgreSQL
	LevelImages      utils.JSONMap `json:"level_images" gorm:"type:jsonb"`      // JSONB for PostgreSQL
	CreatedAt        time.Time     `json:"created_at"`
	UpdatedAt        time.Time     `json:"updated_at"`
}

type CharacterRepository

type CharacterRepository interface {
	GetMany(ctx context.Context) ([]*Character, error)
	GetOne(ctx context.Context, characterId uuid.UUID) (*Character, error)
	CreateOne(ctx context.Context, character *Character) (*Character, error)
	UpdateOne(ctx context.Context, characterId uuid.UUID, updateData map[string]interface{}) (*Character, error)
	DeleteOne(ctx context.Context, characterId uuid.UUID) error
}

type DailyQuest

type DailyQuest struct {
	ID           uuid.UUID           `json:"id" gorm:"type:uuid;primaryKey;default:uuid_generate_v4()"`
	RewardID     uuid.UUID           `json:"rewardId" gorm:"type:uuid;not null;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;references:ID"`
	Name         string              `json:"name" gorm:"type:text; not null"`
	Description  string              `json:"description" gorm:"type:text"`
	Requirements utils.NestedJSONMap `json:"requirements" gorm:"type:jsonb; not null"`
	Type         string              `json:"type" gorm:"type:text"`
	QuestDate    string              `json:"quest_date" gorm:"type:text"`
	Reward       Reward              `gorm:"foreignKey:RewardID;references:ID"`
	CreatedAt    time.Time           `json:"created_at"`
	UpdatedAt    time.Time           `json:"updated_at"`
}

type DailyQuestRepository

type DailyQuestRepository interface {
	GetMany(ctx context.Context) ([]*DailyQuest, error)
	GetOne(ctx context.Context, dailyQuestId uuid.UUID) (*DailyQuest, error)
	CreateOne(ctx context.Context, dailyQuest *DailyQuest) (*DailyQuest, error)
	UpdateOne(ctx context.Context, dailyQuestId uuid.UUID, updateData map[string]interface{}) (*DailyQuest, error)
	DeleteOne(ctx context.Context, dailyQuestId uuid.UUID) error
	GetByDate(ctx context.Context, questDate string) ([]*DailyQuest, error)
}

type Item

type Item struct {
	ID               uuid.UUID     `json:"id" gorm:"type:uuid;primaryKey;default:uuid_generate_v4()"`
	Name             string        `json:"name" gorm:"type:varchar(255)"`
	Description      string        `json:"description" gorm:"type:text"`
	ItemType         string        `json:"item_type" gorm:"type:text"`
	UnlockConditions utils.JSONMap `json:"unlock_conditions" gorm:"type:jsonb"`
	LevelImages      utils.JSONMap `json:"level_images" gorm:"type:jsonb"`
	CreatedAt        time.Time     `json:"created_at"`
	UpdatedAt        time.Time     `json:"updated_at"`
}

type ItemRepository

type ItemRepository interface {
	GetMany(ctx context.Context) ([]*Item, error)
	GetOne(ctx context.Context, itemId uuid.UUID) (*Item, error)
	CreateOne(ctx context.Context, item *Item) (*Item, error)
	UpdateOne(ctx context.Context, itemId uuid.UUID, updateData map[string]interface{}) (*Item, error)
}

type Quiz

type Quiz struct {
	ID          uuid.UUID           `json:"id" gorm:"type:uuid;primaryKey;default:uuid_generate_v4()"`
	Title       string              `json:"title" gorm:"type:text"`
	Description string              `json:"description" gorm:"type:text"`
	Content     utils.NestedJSONMap `json:"content" gorm:"type:jsonb"`
	CreatedAt   time.Time           `json:"created_at"`
	UpdatedAt   time.Time           `json:"updated_at"`
}

type QuizRepository

type QuizRepository interface {
	GetMany(ctx context.Context) ([]*Quiz, error)
	GetOne(ctx context.Context, quizId uuid.UUID) (*Quiz, error)
	CreateOne(ctx context.Context, quiz *Quiz) (*Quiz, error)
	UpdateOne(ctx context.Context, quizId uuid.UUID, updateData map[string]interface{}) (*Quiz, error)
	DeleteOne(ctx context.Context, quizId uuid.UUID) error
}

type Reward

type Reward struct {
	ID          uuid.UUID           `json:"id" gorm:"type:uuid;primaryKey;default:uuid_generate_v4()"`
	Name        string              `json:"name" gorm:"type:text; not null"`
	Description string              `json:"description" gorm:"type:text; not null"`
	Type        string              `json:"type" gorm:"type:text; not null"`
	Details     utils.NestedJSONMap `json:"details" gorm:"type:jsonb"`
	CreatedAt   time.Time           `json:"created_at"`
	UpdatedAt   time.Time           `json:"updated_at"`
}

type RewardRepository

type RewardRepository interface {
	GetMany(ctx context.Context) ([]*Reward, error)
	GetOne(ctx context.Context, rewardId uuid.UUID) (*Reward, error)
	CreateOne(ctx context.Context, reward *Reward) (*Reward, error)
	UpdateOne(ctx context.Context, rewardId uuid.UUID, updateData map[string]interface{}) (*Reward, error)
	DeleteOne(ctx context.Context, rewardId uuid.UUID) error
}

type Task

type Task struct {
	ID           uuid.UUID           `json:"id" gorm:"type:uuid;primaryKey;default:uuid_generate_v4()"`
	RewardID     uuid.UUID           `json:"rewardId" gorm:"type:uuid;not null;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;references:ID"`
	Name         string              `json:"name" gorm:"type:text; not null"`
	Description  string              `json:"description" gorm:"type:text"`
	Requirements utils.NestedJSONMap `json:"requirements" gorm:"type:jsonb; not null"`
	Type         string              `json:"type" gorm:"type:text"`
	Reward       Reward              `gorm:"foreignKey:RewardID;references:ID"`
	CreatedAt    time.Time           `json:"created_at"`
	UpdatedAt    time.Time           `json:"updated_at"`
}

type TaskRepository

type TaskRepository interface {
	GetMany(ctx context.Context) ([]*Task, error)
	GetOne(ctx context.Context, taskId uuid.UUID) (*Task, error)
	CreateOne(ctx context.Context, task *Task) (*Task, error)
	UpdateOne(ctx context.Context, taskId uuid.UUID, updateData map[string]interface{}) (*Task, error)
	DeleteOne(ctx context.Context, taskId uuid.UUID) error
}

type User

type User struct {
	ID        uuid.UUID `json:"id" gorm:"type:uuid;primaryKey;default:uuid_generate_v4()"`
	Username  string    `json:"username" gorm:"unique; not null"`
	Email     string    `json:"email" gorm:"unique"`
	Name      string    `json:"name" gorm:"not null"`
	Role      UserRole  `json:"role" gorm:"text;default:player"`
	Password  string    `json:"-"` // Do not compute the password in json
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type UserKid

type UserKid struct {
	ID                uuid.UUID     `json:"id" gorm:"type:uuid;primaryKey;default:uuid_generate_v4()"`
	UserID            uuid.UUID     `json:"userId" gorm:"type:uuid;not null;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;references:ID"`   // Kid's user ID
	ParentID          uuid.UUID     `json:"parentId" gorm:"type:uuid;not null;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;references:ID"` // Parent's user ID
	CurrentFruitStats utils.JSONMap `json:"current_fruit_stats" gorm:"type:jsonb"`
	BibleProgress     utils.JSONMap `json:"bible_progress" gorm:"type:jsonb"`
	CreatedAt         time.Time     `json:"created_at"`
	UpdatedAt         time.Time     `json:"updated_at"`
	User              User          `gorm:"foreignKey:UserID;references:ID"`   // Establish relation to User for UserID
	Parent            User          `gorm:"foreignKey:ParentID;references:ID"` // Establish relation to User for ParentID
}

type UserKidRepository

type UserKidRepository interface {
	GetAllParentKids(ctx context.Context, parentId uuid.UUID) ([]*UserKid, error)
	GetOne(ctx context.Context, userKidId uuid.UUID) (*UserKid, error)
	CreateOne(ctx context.Context, userKid *UserKid) (*UserKid, error)
	UpdateOne(ctx context.Context, userKidId uuid.UUID, updateData map[string]interface{}) (*UserKid, error)
	DeleteOne(ctx context.Context, userKidId uuid.UUID) error
}

type UserRole

type UserRole string
const (
	Parent UserRole = "parent"
	Kid    UserRole = "kid"
	Player UserRole = "player"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL