Documentation ¶
Index ¶
- func Db(r *http.Request) *gorm.DB
- func GetByIdQuery(db *gorm.DB, r *http.Request) *gorm.DB
- func Paginate[T any](query *gorm.DB, r *http.Request, paginationOptions *utils.PaginationParams, ...) (*utils.PaginatedResponse, error)
- func PaginateQuery(db *gorm.DB, paginationParams *utils.PaginationParams) *gorm.DB
- type Answer
- type AnswerOfQuestion
- type AppModel
- func (m AppModel) AfterCreateCtx(ctx context.Context, tx *gorm.DB) error
- func (m AppModel) AfterDeleteCtx(ctx context.Context, tx *gorm.DB) error
- func (m AppModel) AfterUpdateCtx(ctx context.Context, tx *gorm.DB) error
- func (m AppModel) BeforeCreateCtx(ctx context.Context, tx *gorm.DB) error
- func (m AppModel) BeforeDeleteCtx(ctx context.Context, tx *gorm.DB) error
- func (m AppModel) BeforeUpdateCtx(ctx context.Context, tx *gorm.DB) error
- func (m AppModel) DeleteQuery(db *gorm.DB, r *http.Request) *gorm.DB
- func (m AppModel) GetAllQuery(db *gorm.DB, r *http.Request) *gorm.DB
- func (m AppModel) GetID() uint
- func (m AppModel) GetQuery(db *gorm.DB, r *http.Request) *gorm.DB
- func (m AppModel) UpdateQuery(db *gorm.DB, r *http.Request) *gorm.DB
- func (m AppModel) Validate(r *http.Request) error
- type Athlete
- type AthleteAnswer
- type AthleteResponse
- type AthletesIdsAnswer
- type Discipline
- type DisciplineResponse
- type Event
- type Pokemon
- type Question
- type Role
- type User
- type UserResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PaginateQuery ¶
Types ¶
type Answer ¶
type Answer struct { AppModel UserID uint `json:"user_id" gorm:"not null" validate:"required"` QuestionID uint `json:"question_id" gorm:"not null" validate:"required,id_of=question"` Content AnswerOfQuestion `json:"content" gorm:"not null" validate:"required"` Points uint `json:"points" gorm:"not null;default:0" validate:"eq=0"` // validation is set so it is not possible to set points manually PointsGrantedAt *time.Time `json:"points_granted_at"` }
func (Answer) BuildResponse ¶
type AnswerOfQuestion ¶
func (*AnswerOfQuestion) Validate ¶
func (a *AnswerOfQuestion) Validate(questionType string) error
type AppModel ¶
type AppModel struct { ID uint `gorm:"primarykey" json:"id"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
defines the base model for all models in the application
func (AppModel) AfterCreateCtx ¶
func (AppModel) AfterDeleteCtx ¶
func (AppModel) AfterUpdateCtx ¶
func (AppModel) BeforeCreateCtx ¶
func (AppModel) BeforeDeleteCtx ¶
func (AppModel) BeforeUpdateCtx ¶
type Athlete ¶
type Athlete struct { AppModel FirstName *string `json:"first_name"` LastName *string `json:"last_name"` Birthday *datatypes.Date `json:"birthday"` Country *string `json:"country"` Gender string `json:"gender" gorm:"not null"` Disciplines []Discipline `json:"disciplines" gorm:"many2many:athletes_disciplines;constraint:OnDelete:CASCADE"` }
func (Athlete) BuildResponse ¶
type AthleteAnswer ¶
type AthleteAnswer struct {
Value string `json:"value" validate:"required"`
}
type AthleteResponse ¶
type AthletesIdsAnswer ¶
type Discipline ¶
type Discipline struct { AppModel Name string `json:"name" gorm:"not null"` Type string `json:"type" gorm:"not null"` Athletes []Athlete `json:"athletes" gorm:"many2many:athletes_disciplines;constraint:OnDelete:CASCADE"` }
func (Discipline) BuildResponse ¶
func (m Discipline) BuildResponse() any
type DisciplineResponse ¶
type Event ¶
type Event struct { AppModel Name string `json:"name" gorm:"not null" validate:"required"` Description *string `json:"description"` Deadline time.Time `json:"deadline" gorm:"not null" validate:"required"` Questions []Question `json:"questions,omitempty" gorm:"foreignKey:EventID;constraint:OnDelete:CASCADE"` }
func (Event) BuildResponse ¶
type Pokemon ¶
type Pokemon struct { AppModel PokemonName string `json:"pokemon_name" validate:"required,oneof=D Pikachu Bulbasaur Charmander Squirtle,min=2,max=100"` Age int `json:"age" validate:"required,gte=0,lte=130" gorm:"type:int"` Email string `json:"email" validate:"required,email" gorm:"not null;type:varchar(100)"` Attack string `json:"attack" validate:"required,oneof=Thunderbolt Ember Vine_Whip Water_Gun,min=2,max=100" gorm:"not null"` }
func (Pokemon) BuildResponse ¶
type Question ¶
type Question struct { AppModel EventID uint `json:"event_id" gorm:"not null" validate:"required,id_of=event"` Content string `json:"content" gorm:"not null" validate:"required"` CorrectAnswer *AnswerOfQuestion `json:"correct_answer"` Type string `json:"type" gorm:"not null" validate:"oneof=athlete country"` Answers []Answer `json:"answers,omitempty" gorm:"foreignKey:QuestionID;constraint:OnDelete:CASCADE"` Points uint `json:"points" gorm:"not null;default:1" validate:"required,gte=1"` }
func (Question) BeforeUpdateCtx ¶
func (Question) BuildResponse ¶
type User ¶
type User struct { AppModel Email string `json:"email" validate:"required,email" gorm:"not null;unique"` Password string `json:"password" validate:"required,min=6" gorm:"not null"` Roles []Role `json:"roles" gorm:"many2many:user_roles;constraint:OnDelete:CASCADE"` Answers []Answer `json:"answers,omitempty" gorm:"foreignKey:UserID;constraint:OnDelete:CASCADE"` }
func (User) BuildResponse ¶
Click to show internal directories.
Click to hide internal directories.