models

package
v0.0.0-...-90537fb Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Answer

type Answer struct {
	ID         uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()"`
	QuestionID uuid.UUID `gorm:"type:uuid;not null"`
	Value      string    `gorm:"type:text"`
	ResponseID uuid.UUID `gorm:"type:uuid;not null"`
}

type AnswerRequest

type AnswerRequest struct {
	QuestionID uuid.UUID `validate:"required"`
	Value      string    `validate:"required"`
}

type Form

type Form struct {
	ID          uuid.UUID  `gorm:"type:uuid;primary_key;default:uuid_generate_v4()"`
	Name        string     `gorm:"type:varchar(255);not null"`
	Description string     `gorm:"type:varchar(255);"`
	Code        string     `gorm:"type:varchar(20);not null;unique"`
	Questions   []Question `gorm:"foreignKey:FormID"`
	Responses   []Response `gorm:"foreignKey:FormID"`
	UserID      uuid.UUID  `gorm:"type:uuid;not null"`
	Multiple    bool       `gorm:"type:boolean;not null"`
	CreatedAt   time.Time  `gorm:"autoCreateTime"`
	UpdatedAt   time.Time  `gorm:"autoUpdateTime"`
}

func (Form) ToHuhForm

func (f Form) ToHuhForm() *huh.Form

func (*Form) ToItem

func (f *Form) ToItem() Item

type FormRequest

type FormRequest struct {
	Name        string `validate:"required"`
	Description string
	Questions   []QuestionRequest `validate:"required"`
	Code        string            `validate:"required"`
	Multiple    bool
}

func (*FormRequest) ToForm

func (f *FormRequest) ToForm(userID uuid.UUID) Form

type Item

type Item struct {
	ID   string
	Name string
	Desc string
}

func FormsToItems

func FormsToItems(forms []Form) []Item

func (Item) Description

func (i Item) Description() string

func (Item) FilterValue

func (i Item) FilterValue() string

func (Item) Title

func (i Item) Title() string

type Option

type Option struct {
	ID         uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()"`
	QuestionID uuid.UUID `gorm:"type:uuid;not null"`
	Text       string    `gorm:"type:varchar(255);not null"`
}

type OptionRequest

type OptionRequest struct {
	Text string
}

func (*OptionRequest) ToOption

func (o *OptionRequest) ToOption() Option

type Question

type Question struct {
	ID       uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()"`
	FormID   uuid.UUID `gorm:"type:uuid;not null"`
	Text     string    `gorm:"type:varchar(255);not null"`
	Type     string    `gorm:"type:varchar(255);not null"`
	Options  []Option  `gorm:"foreignKey:QuestionID"`
	Required bool      `gorm:"type:boolean;not null"`
}

type QuestionRequest

type QuestionRequest struct {
	Text     string `validate:"required,max=255,min=1"`
	Type     string `validate:"required,max=255,min=1"`
	Options  []OptionRequest
	Required bool `validate:"required"`
}

func (*QuestionRequest) ToQuestion

func (q *QuestionRequest) ToQuestion() Question

type Response

type Response struct {
	ID        uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()"`
	FormID    uuid.UUID `gorm:"type:uuid;not null"`
	UserID    uuid.UUID `gorm:"type:uuid;not null"`
	Answers   []Answer  `gorm:"foreignKey:ResponseID"`
	CreatedAt time.Time `gorm:"autoCreateTime"`
	UpdatedAt time.Time `gorm:"autoUpdateTime"`
}

type ResponseRequest

type ResponseRequest struct {
	Answers []Answer `validate:"required"`
}

func (*ResponseRequest) ToResponse

func (r *ResponseRequest) ToResponse(formID uuid.UUID, userID uuid.UUID) Response

type User

type User struct {
	ID        uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()"`
	Email     string    `gorm:"type:varchar(255);"`
	Name      string    `gorm:"type:varchar(255);"`
	Forms     []Form    `gorm:"foreignKey:UserID"`
	PubKey    string    `gorm:"type:varchar(1024);not null;unique"`
	CreatedAt time.Time `gorm:"autoCreateTime"`
	UpdatedAt time.Time `gorm:"autoUpdateTime"`
}

type UserRequest

type UserRequest struct {
	Email  string
	Name   string
	PubKey string
}

func (*UserRequest) ToUser

func (u *UserRequest) ToUser() User

Jump to

Keyboard shortcuts

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