models

package
v0.0.0-...-d702761 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 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 Base

type Base struct {
	ID        uint       `gorm:"primaryKey" json:"id"`
	CreatedAt *time.Time `json:"created_at,omitempty"`
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
}

type Comment

type Comment struct {
	Base
	Message string `gorm:"not null" json:"message" form:"message" valid:"required~message is required"`
	UserID  uint
	PhotoID uint
	User    User
	Photo   Photo
}

func (*Comment) BeforeCreate

func (c *Comment) BeforeCreate(tx *gorm.DB) (err error)

func (*Comment) BeforeUpdate

func (c *Comment) BeforeUpdate(tx *gorm.DB) (err error)

type CommentCreateInput

type CommentCreateInput struct {
	Message string `json:"message" form:"message" valid:"required~message is required"`
	UserID  uint   `valid:"required~user ID is required"`
	PhotoID uint   `valid:"required~photo ID is required"`
}

type CommentCreateInputSwagger

type CommentCreateInputSwagger struct {
	Message string `json:"message" form:"message"`
}

type CommentCreateOutput

type CommentCreateOutput struct {
	Base
	Message string `json:"message"`
	UserID  uint   `json:"user_id"`
	PhotoID uint   `json:"photo_id"`
}

type CommentGetOutput

type CommentGetOutput struct {
	Base
	Message string             `json:"message"`
	User    UserRegisterOutput `json:"user"`
}

type CommentUpdateInput

type CommentUpdateInput struct {
	ID      uint   `valid:"required~ID is required"`
	Message string `json:"message" form:"message" valid:"required~message is required"`
	UserID  uint   `valid:"required~user ID is required"`
	PhotoID uint   `valid:"required~photo ID is required"`
}

type CommentUpdateInputSwagger

type CommentUpdateInputSwagger = CommentCreateInputSwagger

type CommentUpdateOutput

type CommentUpdateOutput = CommentCreateOutput

type DeleteResponse

type DeleteResponse struct {
	Message string `json:"message"`
}

type ErrorResponse

type ErrorResponse struct {
	Error   string `json:"error"`
	Message string `json:"message"`
}

type Photo

type Photo struct {
	Base
	Title    string `gorm:"not null"`
	Caption  string `gorm:"not null"`
	PhotoURL string `gorm:"not null"`
	UserID   uint
	User     User
	Comments []Comment `gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
}

func (*Photo) BeforeCreate

func (p *Photo) BeforeCreate(tx *gorm.DB) (err error)

func (*Photo) BeforeUpdate

func (p *Photo) BeforeUpdate(tx *gorm.DB) (err error)

type PhotoCreateInput

type PhotoCreateInput struct {
	Title    string `form:"title" valid:"required~title is required"`
	Caption  string `form:"caption" valid:"required~caption is required"`
	PhotoURL string `form:"photo_url" valid:"required~photo URL is required"`
	UserID   uint   `valid:"required~user ID is required"`
}

type PhotoCreateInputSwagger

type PhotoCreateInputSwagger struct {
	Title   string `form:"title"`
	Caption string `form:"caption"`
}

this struct only used for swagger docs to generate desired input

type PhotoCreateOutput

type PhotoCreateOutput struct {
	Base
	Title    string `json:"title"`
	Caption  string `json:"caption"`
	PhotoURL string `json:"photo_url"`
	UserID   uint   `json:"user_id"`
}

type PhotoGetOutput

type PhotoGetOutput struct {
	Base
	Title    string             `json:"title"`
	Caption  string             `json:"caption"`
	PhotoURL string             `json:"photo_url"`
	User     UserRegisterOutput `json:"user"`
}

type PhotoUpdateInput

type PhotoUpdateInput struct {
	ID       uint   `valid:"required~ID is required"`
	Title    string `form:"title" valid:"required~title is required"`
	Caption  string `form:"caption" valid:"required~caption is required"`
	PhotoURL string `form:"photo_url" valid:"required~photo URL is required"`
	UserID   uint   `valid:"required~user ID is required"`
}

type PhotoUpdateInputSwagger

type PhotoUpdateInputSwagger = PhotoCreateInputSwagger

type PhotoUpdateOutput

type PhotoUpdateOutput = PhotoCreateOutput

type SocialMedia

type SocialMedia struct {
	Base
	Name           string `gorm:"not null"`
	SocialMediaURL string `gorm:"not null;uniqueIndex"`
	UserID         uint
	User           User
}

func (*SocialMedia) BeforeCreate

func (s *SocialMedia) BeforeCreate(tx *gorm.DB) (err error)

func (*SocialMedia) BeforeUpdate

func (s *SocialMedia) BeforeUpdate(tx *gorm.DB) (err error)

type SocialMediaCreateInput

type SocialMediaCreateInput struct {
	Name           string `json:"name" form:"name" valid:"required~name is required"`
	SocialMediaURL string `json:"social_media_url" form:"social_media_url" valid:"required~social media URL is required"`
	UserID         uint   `valid:"required~user ID is required"`
}

type SocialMediaCreateInputSwagger

type SocialMediaCreateInputSwagger struct {
	Name           string `json:"name" form:"name"`
	SocialMediaURL string `json:"social_media_url" form:"social_media_url"`
}

type SocialMediaCreateOutput

type SocialMediaCreateOutput struct {
	Base
	Name           string `json:"name" form:"name"`
	SocialMediaURL string `json:"social_media_url" form:"social_media_url"`
	UserID         uint   `json:"user_id"`
}

type SocialMediaGetOutput

type SocialMediaGetOutput struct {
	Base
	Name           string             `json:"name" form:"name"`
	SocialMediaURL string             `json:"social_media_url" form:"social_media_url"`
	User           UserRegisterOutput `json:"user"`
}

type SocialMediaUpdateInput

type SocialMediaUpdateInput struct {
	ID             uint   `valid:"required~ID is required"`
	Name           string `json:"name" form:"name" valid:"required~name is required"`
	SocialMediaURL string `json:"social_media_url" form:"social_media_url" valid:"required~social media URL is required"`
	UserID         uint   `valid:"required~user ID is required"`
}

type SocialMediaUpdateInputSwagger

type SocialMediaUpdateInputSwagger = SocialMediaCreateInputSwagger

type SocialMediaUpdateOutput

type SocialMediaUpdateOutput = SocialMediaCreateOutput

type User

type User struct {
	Base
	Username     string        `gorm:"not null;uniqueIndex"`
	Email        string        `gorm:"not null;uniqueIndex"`
	Password     string        `gorm:"not null"`
	Age          int           `gorm:"not null"`
	Photos       []Photo       `gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
	Comments     []Comment     `gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
	SocialMedias []SocialMedia `gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
}

func (*User) BeforeCreate

func (u *User) BeforeCreate(tx *gorm.DB) (err error)

type UserLoginInput

type UserLoginInput struct {
	Email    string `json:"email" form:"email"`
	Password string `json:"password" form:"password"`
}

type UserLoginOutput

type UserLoginOutput struct {
	Token string `json:"token"`
}

type UserRegisterInput

type UserRegisterInput struct {
	Username string `json:"username" form:"username" valid:"required~username is required"`
	Email    string `json:"email" form:"email" valid:"required~email is required,email~invalid email format"`
	Password string `` /* 140-byte string literal not displayed */
	Age      int    `json:"age" form:"age" valid:"required~age is required,range(8|99)~user must be at least 8 years old"`
}

type UserRegisterOutput

type UserRegisterOutput struct {
	Base
	Username string `json:"username"`
	Email    string `json:"email"`
	Age      int    `json:"age"`
}

Jump to

Keyboard shortcuts

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