Documentation
¶
Index ¶
- func VerifyPassword(hashedPassword, password string) error
- type Comment
- func (c *Comment) DeleteAComment(db *gorm.DB) (int64, error)
- func (c *Comment) DeleteTripComments(db *gorm.DB, pid uint64) (int64, error)
- func (c *Comment) DeleteUserComments(db *gorm.DB, uid uint64) (int64, error)
- func (c *Comment) GetComments(db *gorm.DB, pid uint64) (*[]Comment, error)
- func (c *Comment) Prepare()
- func (c *Comment) SaveComment(db *gorm.DB) (*Comment, error)
- func (c *Comment) UpdateAComment(db *gorm.DB) (*Comment, error)
- func (c *Comment) Validate(action string) map[string]string
- type Like
- func (l *Like) DeleteLike(db *gorm.DB) (*Like, error)
- func (l *Like) DeleteTripLikes(db *gorm.DB, pid uint64) (int64, error)
- func (l *Like) DeleteUserLikes(db *gorm.DB, uid uint64) (int64, error)
- func (l *Like) GetLikesInfo(db *gorm.DB, pid uint64) (*[]Like, error)
- func (l *Like) SaveLike(db *gorm.DB) (*Like, error)
- type ResetPassword
- type Trip
- func (t *Trip) BeforeSave(scope *gorm.Scope) error
- func (t *Trip) BeforeUpdate(scope *gorm.Scope) error
- func (t *Trip) DeleteATrip(db *gorm.DB, pid uint64, uid uint64) (int64, error)
- func (t *Trip) DeleteUserTrips(db *gorm.DB, uid uint64) (int64, error)
- func (t *Trip) FindAllTrips(db *gorm.DB) (*[]Trip, error)
- func (t *Trip) FindTripByID(db *gorm.DB, pid uint64) (*Trip, error)
- func (t *Trip) FindUserTrips(db *gorm.DB, uid uint64) (*[]Trip, error)
- func (t *Trip) Prepare()
- func (t *Trip) SaveTrip(db *gorm.DB) (*Trip, error)
- func (t *Trip) TableName() string
- func (t *Trip) UpdateATrip(db *gorm.DB, pid uint64) (*Trip, error)
- func (t *Trip) Validate() map[string]string
- type User
- func (u *User) AfterFind() (err error)
- func (u *User) BeforeSave() error
- func (u *User) BeforeUpdate(scope *gorm.Scope) error
- func (u *User) DeleteAUser(db *gorm.DB, uid uint64) (int64, error)
- func (u *User) FindAllUsers(db *gorm.DB) (*[]User, error)
- func (u *User) FindUserByID(db *gorm.DB, uid uint64) (*User, error)
- func (u *User) Prepare()
- func (u *User) SaveUser(db *gorm.DB) (*User, error)
- func (u *User) TableName() string
- func (u *User) UpdateAUser(db *gorm.DB, uid uint64) (*User, error)
- func (u *User) UpdateAUserAvatar(db *gorm.DB, uid uint64) (*User, error)
- func (u *User) UpdatePassword(db *gorm.DB) error
- func (u *User) Validate(action string) map[string]string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func VerifyPassword ¶
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 ¶
DeleteAComment : function to delete a comment
func (*Comment) DeleteTripComments ¶
DeleteTripComments : When a post is deleted, we also delete the comments that the post had
func (*Comment) DeleteUserComments ¶
DeleteUserComments : When a user is deleted, we also delete the comments that the user had
func (*Comment) GetComments ¶
GetComments : function to get all the comments for a trip and a user
func (*Comment) SaveComment ¶
SaveComment : function to save a comment linked to a user
func (*Comment) UpdateAComment ¶
UpdateAComment : funtion to update a comment
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 ¶
DeleteLike : function to delete a like of a trip
func (*Like) DeleteTripLikes ¶
DeleteTripLikes : When a trip is deleted, we also delete the likes that the trip had
func (*Like) DeleteUserLikes ¶
DeleteUserLikes : When a user is deleted, we also delete the likes that the user had
func (*Like) GetLikesInfo ¶
GetLikesInfo : get the infos
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 ¶
BeforeSave : Method before Save
func (*Trip) BeforeUpdate ¶
BeforeUpdate is gorm hook that is triggered on every updated on vote struct
func (*Trip) DeleteATrip ¶
DeleteATrip : function to delete a trip
func (*Trip) DeleteUserTrips ¶
DeleteUserTrips : When a user is deleted, we also delete the trip that the user had
func (*Trip) FindAllTrips ¶
FindAllTrips : function to find all trips
func (*Trip) FindTripByID ¶
FindTripByID : function to find a trip with an ID
func (*Trip) FindUserTrips ¶
FindUserTrips : function to get all trips for a user
func (*Trip) UpdateATrip ¶
UpdateATrip : function to update a trip
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) BeforeSave ¶
BeforeSave : call package security to hash the password
func (*User) BeforeUpdate ¶
BeforeUpdate is gorm hook that is triggered on every updated on user struct
func (*User) DeleteAUser ¶
DeleteAUser : function to delete the user
func (*User) FindAllUsers ¶
FindAllUsers : function to find all users
func (*User) FindUserByID ¶
FindUserByID : function to find a user with an ID
func (*User) UpdateAUser ¶
UpdateAUser : update an user
func (*User) UpdateAUserAvatar ¶
UpdateAUserAvatar : update an avatar user
func (*User) UpdatePassword ¶
UpdatePassword : funtion to update the password