models

package
v0.0.0-...-d4a52ae Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func VerifyPassword

func VerifyPassword(hashedPassword, password string) error

VerifyPassword : This method compare the password with the hash

Types

type Comment

type Comment struct {
	ID        uint64    `gorm:"primary_key;auto_increment" json:"id"`
	UserID    uint64    `gorm:"not null" json:"user_id"`
	TripID    uint64    `gorm:"not null" json:"trip_id"`
	Body      string    `gorm:"text;not null;" json:"body"`
	User      User      `json:"user"`
	CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"updated_at"`
	// contains filtered or unexported fields
}

Comment struct

func (*Comment) DeleteAComment

func (c *Comment) DeleteAComment(db *gorm.DB) (int64, error)

DeleteAComment : function to delete a comment

func (*Comment) DeleteTripComments

func (c *Comment) DeleteTripComments(db *gorm.DB, pid uint64) (int64, error)

DeleteTripComments : When a post is deleted, we also delete the comments that the post had

func (*Comment) DeleteUserComments

func (c *Comment) DeleteUserComments(db *gorm.DB, uid uint64) (int64, error)

DeleteUserComments : When a user is deleted, we also delete the comments that the user had

func (*Comment) GetComments

func (c *Comment) GetComments(db *gorm.DB, pid uint64) (*[]Comment, error)

GetComments : function to get all the comments for a trip and a user

func (*Comment) Prepare

func (c *Comment) Prepare()

Prepare : prepare statements

func (*Comment) SaveComment

func (c *Comment) SaveComment(db *gorm.DB) (*Comment, error)

SaveComment : function to save a comment linked to a user

func (*Comment) UpdateAComment

func (c *Comment) UpdateAComment(db *gorm.DB) (*Comment, error)

UpdateAComment : funtion to update a comment

func (*Comment) Validate

func (c *Comment) Validate(action string) map[string]string

Validate : validation rules

type Like

type Like struct {
	ID        uint64    `gorm:"primary_key;auto_increment" json:"id"`
	UserID    uint64    `gorm:"not null" json:"user_id"`
	TripID    uint64    `gorm:"not null" json:"trip_id"`
	CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"updated_at"`
}

Like struct

func (*Like) DeleteLike

func (l *Like) DeleteLike(db *gorm.DB) (*Like, error)

DeleteLike : function to delete a like of a trip

func (*Like) DeleteTripLikes

func (l *Like) DeleteTripLikes(db *gorm.DB, pid uint64) (int64, error)

DeleteTripLikes : When a trip is deleted, we also delete the likes that the trip had

func (*Like) DeleteUserLikes

func (l *Like) DeleteUserLikes(db *gorm.DB, uid uint64) (int64, error)

DeleteUserLikes : When a user is deleted, we also delete the likes that the user had

func (*Like) GetLikesInfo

func (l *Like) GetLikesInfo(db *gorm.DB, pid uint64) (*[]Like, error)

GetLikesInfo : get the infos

func (*Like) SaveLike

func (l *Like) SaveLike(db *gorm.DB) (*Like, error)

SaveLike : function to like a trip

type ResetPassword

type ResetPassword struct {
	gorm.Model
	Email string `gorm:"size:100;not null;" json:"email"`
	Token string `gorm:"size:255;not null;" json:"token"`
}

ResetPassword struct

func (*ResetPassword) DeleteDetails

func (resetPassword *ResetPassword) DeleteDetails(db *gorm.DB) (int64, error)

DeleteDetails : Supprime un resetPassword

func (*ResetPassword) Prepare

func (resetPassword *ResetPassword) Prepare()

Prepare : prepare statements

func (*ResetPassword) SaveDetails

func (resetPassword *ResetPassword) SaveDetails(db *gorm.DB) (*ResetPassword, error)

SaveDetails : Créer un nouveau ResetPassword

type Trip

type Trip struct {
	UUID         uuid.UUID `gorm:"type:uuid;unique_index;" json:"uuid"`
	ID           uint64    `gorm:"primary_key;auto_increment" json:"id"`
	Country      string    `gorm:"size:255;not null;" json:"country"`
	Title        string    `gorm:"size:255;not null;unique" json:"title"`
	Description  string    `gorm:"text;not null;" json:"description"`
	StartDate    time.Time `gorm:"not null;" json:"start_date"`
	EndDate      time.Time `gorm:"not null;" json:"end_date"`
	NbDays       int       `gorm:"not null;" json:"nb_days"`
	MiddleAge    int       `gorm:"not null;" json:"middle_age"`
	NbTraveler   int       `gorm:"not null;" json:"nb_traveler"`
	ImageTrip    string    `gorm:"size:255;null;" json:"image_trip"`
	Program      string    `gorm:"text;null;" json:"program"`
	ImageProgram string    `gorm:"size:255;null;" json:"image_program"`
	Lodging      string    `gorm:"text;null;" json:"lodging"`
	Budget       int       `gorm:"not null;" json:"budget"`
	Author       User      `json:"author"`
	AuthorID     uint64    `gorm:"not null" json:"author_id"`
	CreatedAt    time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt    time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"updated_at"`
}

Trip Struct

func (*Trip) BeforeSave

func (t *Trip) BeforeSave(scope *gorm.Scope) error

BeforeSave : Method before Save

func (*Trip) BeforeUpdate

func (t *Trip) BeforeUpdate(scope *gorm.Scope) error

BeforeUpdate is gorm hook that is triggered on every updated on vote struct

func (*Trip) DeleteATrip

func (t *Trip) DeleteATrip(db *gorm.DB, pid uint64, uid uint64) (int64, error)

DeleteATrip : function to delete a trip

func (*Trip) DeleteUserTrips

func (t *Trip) DeleteUserTrips(db *gorm.DB, uid uint64) (int64, error)

DeleteUserTrips : When a user is deleted, we also delete the trip that the user had

func (*Trip) FindAllTrips

func (t *Trip) FindAllTrips(db *gorm.DB) (*[]Trip, error)

FindAllTrips : function to find all trips

func (*Trip) FindTripByID

func (t *Trip) FindTripByID(db *gorm.DB, pid uint64) (*Trip, error)

FindTripByID : function to find a trip with an ID

func (*Trip) FindUserTrips

func (t *Trip) FindUserTrips(db *gorm.DB, uid uint64) (*[]Trip, error)

FindUserTrips : function to get all trips for a user

func (*Trip) Prepare

func (t *Trip) Prepare()

Prepare : prepare a trip A FINIR

func (*Trip) SaveTrip

func (t *Trip) SaveTrip(db *gorm.DB) (*Trip, error)

SaveTrip : Method Save Trip, triggered on every saved on trip struct

func (*Trip) TableName

func (t *Trip) TableName() string

TableName : Gorm related

func (*Trip) UpdateATrip

func (t *Trip) UpdateATrip(db *gorm.DB, pid uint64) (*Trip, error)

UpdateATrip : function to update a trip

func (*Trip) Validate

func (t *Trip) Validate() map[string]string

Validate : function to check the data

type User

type User struct {
	UUID             uuid.UUID `gorm:"type:uuid;unique_index;" json:"uuid"`
	ID               uint64    `gorm:"primary_key;auto_increment" json:"id"`
	Firstname        string    `valid:"required,alpha,length(2|255)" json:"firstname"`
	Lastname         string    `valid:"required,alpha,length(2|255)" json:"lastname"`
	Email            string    `gorm:"size:100;not null;unique" valid:"email" json:"email"`
	Password         string    `gorm:"size:100;not null;" json:"password"`
	Accesslevel      int       `valid:"range(0|1),numeric" json:"access_level"`
	Dateofbirth      time.Time `gorm:"null;" json:"date_of_birth"`
	Sexe             string    `gorm:"size:100;not null;" json:"sexe"`
	City             string    `gorm:"size:150;null;" json:"city"`
	PhoneNumber      string    `gorm:"size:15;null" json:"phone_number"`
	DepartureAirport string    `gorm:"size:250;null;" json:"departure_airport"`
	Description      string    `gorm:"text;null;" json:"description"`
	AvatarPath       string    `gorm:"size:255;null;" json:"avatar_path"`
	CreatedAt        time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt        time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"updated_at"`
}

User Struct

func (*User) AfterFind

func (u *User) AfterFind() (err error)

AfterFind : values of return

func (*User) BeforeSave

func (u *User) BeforeSave() error

BeforeSave : call package security to hash the password

func (*User) BeforeUpdate

func (u *User) BeforeUpdate(scope *gorm.Scope) error

BeforeUpdate is gorm hook that is triggered on every updated on user struct

func (*User) DeleteAUser

func (u *User) DeleteAUser(db *gorm.DB, uid uint64) (int64, error)

DeleteAUser : function to delete the user

func (*User) FindAllUsers

func (u *User) FindAllUsers(db *gorm.DB) (*[]User, error)

FindAllUsers : function to find all users

func (*User) FindUserByID

func (u *User) FindUserByID(db *gorm.DB, uid uint64) (*User, error)

FindUserByID : function to find a user with an ID

func (*User) Prepare

func (u *User) Prepare()

Prepare : prepare statements

func (*User) SaveUser

func (u *User) SaveUser(db *gorm.DB) (*User, error)

SaveUser : Method Save User, triggered on every saved on user struct

func (*User) TableName

func (u *User) TableName() string

TableName : Gorm related

func (*User) UpdateAUser

func (u *User) UpdateAUser(db *gorm.DB, uid uint64) (*User, error)

UpdateAUser : update an user

func (*User) UpdateAUserAvatar

func (u *User) UpdateAUserAvatar(db *gorm.DB, uid uint64) (*User, error)

UpdateAUserAvatar : update an avatar user

func (*User) UpdatePassword

func (u *User) UpdatePassword(db *gorm.DB) error

UpdatePassword : funtion to update the password

func (*User) Validate

func (u *User) Validate(action string) map[string]string

Validate : function to check the data

Jump to

Keyboard shortcuts

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