models

package
v0.0.0-...-921fe37 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comment

type Comment struct {
	ID      uint `json:"id" gorm:"primaryKey"`
	UserID  uint `json:"user_id"`
	PhotoID uint `json:"photo_id"`

	Message string `json:"message" valid:"required~Comment message is required" example:"Sheesh!" gorm:"not null"`

	User  *User  `json:"user,omitempty"`
	Photo *Photo `json:"photo,omitempty"`

	CreatedAt *time.Time `json:"created_at,omitempty"`
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
}

func (*Comment) BeforeCreate

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

func (*Comment) BeforeUpdate

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

type CommentRepo

type CommentRepo interface {
	Fetch(context.Context, *[]Comment, uint) error
	Store(context.Context, *Comment) error
	GetByUserID(context.Context, *Comment, uint) error
	Update(context.Context, Comment, uint) (Photo, error)
	Delete(context.Context, uint) error
}

type CommentUsecase

type CommentUsecase interface {
	Fetch(context.Context, *[]Comment, uint) error
	Store(context.Context, *Comment) error
	GetByUserID(context.Context, *Comment, uint) error
	Update(context.Context, Comment, uint) (Photo, error)
	Delete(context.Context, uint) error
}

type Photo

type Photo struct {
	ID     uint `json:"id" gorm:"primaryKey"`
	UserID uint `json:"user_id"`

	Title    string `json:"title" valid:"required~Photo title is required" example:"My Sweet Photo" gorm:"not null"`
	PhotoUrl string `` /* 137-byte string literal not displayed */
	Caption  string `json:"caption" example:"Beautiful as it is"`

	User     *User      `json:"user,omitempty"`
	Comments *[]Comment `json:"-" gorm:"constraint:OnDelete:SET NULL;"`

	CreatedAt *time.Time `json:"created_at,omitempty"`
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
}

func (*Photo) BeforeCreate

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

func (*Photo) BeforeUpdate

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

type PhotoRepo

type PhotoRepo interface {
	Fetch(context.Context, *[]Photo) error
	Store(context.Context, *Photo) error
	GetByID(context.Context, *Photo, uint) error
	GetByUserID(context.Context, *Photo, uint) error
	Update(context.Context, Photo, uint) (Photo, error)
	Delete(context.Context, uint) error
}

type PhotoUsecase

type PhotoUsecase interface {
	Fetch(context.Context, *[]Photo) error
	Store(context.Context, *Photo) error
	GetByID(context.Context, *Photo, uint) error
	GetByUserID(context.Context, *Photo, uint) error
	Update(context.Context, Photo, uint) (Photo, error)
	Delete(context.Context, uint) error
}

type SocialMedia

type SocialMedia struct {
	ID     uint `json:"id" gorm:"primaryKey"`
	UserID uint `json:"user_id"`

	Name           string `json:"name" valid:"required~Social media name is required" example:"johndee13" gorm:"not null"`
	SocialMediaUrl string `json:"social_media_url" valid:"required~Social media url is required"  example:"johndee13url" gorm:"not null"`

	User *User `json:"user,omitempty"`

	CreatedAt *time.Time `json:"created_at,omitempty"`
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
}

func (*SocialMedia) BeforeCreate

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

func (*SocialMedia) BeforeUpdate

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

type SocialMediaRepo

type SocialMediaRepo interface {
	Fetch(context.Context, *[]SocialMedia, uint) error
	Store(context.Context, *SocialMedia) error
	GetByUserID(context.Context, *SocialMedia, uint) error
	Update(context.Context, SocialMedia, uint) (SocialMedia, error)
	Delete(context.Context, uint) error
}

type SocialMediaUsecase

type SocialMediaUsecase interface {
	Fetch(context.Context, *[]SocialMedia, uint) error
	Store(context.Context, *SocialMedia) error
	GetByUserID(context.Context, *SocialMedia, uint) error
	Update(context.Context, SocialMedia, uint) (SocialMedia, error)
	Delete(context.Context, uint) error
}

type User

type User struct {
	ID uint `json:"id" gorm:"primaryKey"`

	Username        string `json:"username" valid:"required~Username is required" example:"Johndee" gorm:"not null;uniqueIndex;"`
	Email           string `` /* 131-byte string literal not displayed */
	Password        string `` /* 166-byte string literal not displayed */
	Age             int    `` /* 145-byte string literal not displayed */
	ProfileImageUrl string `json:"profile_image_url,omitempty" example:"https://avatars.dicebear.com/api/identicon/your-custom-seed.svg"`

	Photos      *[]Photo     `json:"-" gorm:"constraint:OnDelete:SET NULL;"`
	Comments    *[]Comment   `json:"-" gorm:"constraint:OnDelete:SET NULL;"`
	SocialMedia *SocialMedia `json:"-" gorm:"constraint:OnDelete:SET NULL;"`

	CreatedAt *time.Time `json:"created_at,omitempty"`
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
}

func (*User) BeforeCreate

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

func (*User) BeforeUpdate

func (u *User) BeforeUpdate(db *gorm.DB) (err error)

type UserRepo

type UserRepo interface {
	Register(context.Context, *User) error
	Login(context.Context, *User) error
	Update(context.Context, User, uint) (User, error)
	Delete(context.Context, uint) error
}

type UserUsecase

type UserUsecase interface {
	Register(context.Context, *User) error
	Login(context.Context, *User) error
	Update(context.Context, User, uint) (User, error)
	Delete(context.Context, uint) error
}

Jump to

Keyboard shortcuts

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